forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 upload => Topic started by: bgohsman on June 19, 2008, 04:13:12 pm

Title: [Solved]: Trouble Getting ImageMagick Properly Configured
Post by: bgohsman on June 19, 2008, 04:13:12 pm
Greetings,

First, I did read actually the sticky about troubleshooting uploads (not skimmed, read the whole thing). I've also searched for the error(s) that I'm receiving and read the resulting threads. That actually told me exactly what my initial problem was. I had to request the server error logs from the host and that confirmed that GD was exceeding the allotted memory. And I've worked with the hosting provider from there on setting up ImageMagick.

I should also mention that I have installed this on a couple of other servers and it all works fine. So there is something different about this particular server environment that is tripping me up (not Coppermine). And I'm going in circles trying to figure out what.

At first, I was using the GD library, which actually works just fine on smaller files. So permissions and such don't appear to be an issue. Above a certain size, however, the image would exceed the 8MB of allotted memory on the server. So I switched to ImageMagick. However, that is failing at the moment and I'm sort of scratching my head as to why. I'm hoping someone will read this and say, "Oh, yeah. It's 'bleh'". Here is what I know:

I'm on a hosted, virtual server. ImageMagick is installed in /usr/bin. I tested this by logging in via SSH and issuing the following commands:

-bash-3.00$ whereis convert
convert: /usr/bin/convert /usr/share/man/man1/convert.1.gz
-bash-3.00$ /usr/bin/convert -version
Version: ImageMagick 6.0.7 03/28/08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2004 ImageMagick Studio LLC

So I've set /usr/bin as the ImageMagic directory in the config section and chosen ImageMagick as the conversion method.

The larger file does get uploaded to the /albums/userpics/1000x directory using GD 2.x, but does not result in a "normal" or "thumb" version being created and generates the expected Internal Server Error. When ImageMagick is selected, the file doesn't even get uploaded. But at least I get a meaningful error from Coppermine (see below).

/albums is recursively set to 777
/includes is recursively set to 777

Max upload size for this web server is 2048. Set as same in config.
Max width or height for uploaded pictures: 3072
Memory limit is 8MB (which was the problem GD 2.x was running into).
Testing a 1,003KB JPG that is 3,072 pixels wide at 72dpi.

The gallery URL is:
http://www.tek-creations.com/gallery

I have setup a test user as per the sticky:
Username: test
Password: test

Debug mode is on.

No. of boxes: fixed
File upload boxes: 1
URI upload boxes: 0

All permissions granted without approval.

The following error is generated after upload:
-----------------------------------------------
The file 'albums/userpics/10002/large_test.jpg' can't be inserted in the album

Error executing ImageMagick - Return value: 127

Cmd line :
/usr/bin/convert -quality 80 -antialias -geometry 100x66 'albums/userpics/10002/large_test.jpg' 'albums/userpics/10002/thumb_large_test.jpg'


The convert program said:


File: /vservers/tekcreat/htdocs/gallery/db_input.php - Line: 402


Debug info:
-----------------------------------------------
USER:
------------------
Array
(
    [ID] => 2dbaa9713c8a5cd66746c09f746ef894
    [am] => 1
    [lang] => english
    [liv] => Array
        (
        )

)

==========================
USER DATA:
------------------
Array
(
    [user_id] => 2
    [user_name] => test
    [groups] => Array
        (
           
        )

    [disk_max] => 0
    [disk_min] => 0
    [can_rate_pictures] => 1
    [can_send_ecards] => 1
    [ufc_max] => 0
    [ufc_min] => 0
    [custom_user_upload] => 0
    [num_file_upload] => 1
    [num_URI_upload] => 0
    [can_post_comments] => 1
    [can_upload_pictures] => 1
    [can_create_albums] => 1
    [has_admin_access] => 0
    [pub_upl_need_approval] => 0
    [priv_upl_need_approval] => 0
    [group_name] => Registered
    [upload_form_config] => 0
    [group_quota] => 0
    [can_see_all_albums] => 0
    [group_id] => 2
)

==========================
Queries:
------------------
Array
(
    [album] => 2
    [MAX_FILE_SIZE] => 2097152
    [title] => Test image
    [caption] => Testing upload of 1,003KB image...
    [keywords] =>
    [event] => picture
)

==========================
Page generated in 0.098 seconds - 16 queries in 0.017 seconds - Album set : ; Meta set: ;
Title: Re: Trouble Getting ImageMagick Properly Configured
Post by: bgohsman on June 19, 2008, 04:20:38 pm
One more interesting note:

I manually uploaded my large_test.jpg file to the /userpics/10002/ directory and then ran the following command in SSH:

-bash-3.00$ /usr/bin/convert -quality 80 -antialias -geometry 100x66 '/vservers/tekcreat/htdocs/gallery/albums/userpics/10002/large_test.jpg' '/vservers/tekcreat/htdocs/gallery/albums/userpics/10002/thumb_large_test.jpg'

It generated the thumbnail without issue. This leads me to believe that my problem has to do with uploading rather than ImageMagick. This is strange since uploading works when GD 2.x is selected.
Title: Re: Trouble Getting ImageMagick Properly Configured
Post by: Nibbler on June 19, 2008, 05:00:16 pm
Are you running apache chrooted or something?

See if this works:

Code: [Select]
<?php

var_dump
(file_exists('/usr/bin/convert'));

?>

Title: Re: Trouble Getting ImageMagick Properly Configured
Post by: bgohsman on June 19, 2008, 05:05:34 pm
I ran that and received the following response:

bool(false)

I'm frankly not sure what that means, but it doesn't sound good. lol
Title: Re: Trouble Getting ImageMagick Properly Configured
Post by: Nibbler on June 19, 2008, 05:11:18 pm
It means it's not an uploading or even a Coppermine issue :)

Ask your host whether you are using chrooted apache if you don't know. Easiest thing would be to switch back to GD2 and just increase the memory limit.
Title: Re: Trouble Getting ImageMagick Properly Configured
Post by: bgohsman on June 19, 2008, 06:09:11 pm
Will do. Back to the hosting provider. Thanks!
Title: Re: Trouble Getting ImageMagick Properly Configured
Post by: bgohsman on June 19, 2008, 11:40:47 pm
Solved! I heard back from the hosting provider and they had to make a change to the php.ini file. Everything is working flawlessly now. Hopefully, this post will help someone else with the same situation later.

Thanks for your help!

Brandon

Ref: tek-creations.com (H95138)
 
Hi, Brandon,

Since you're running your site in safe_mode, I've added safe_mode_exec_dir = /usr/bin to your php.ini so you can execute the /usr/bin/convert executable. file_exists will still return false for that though, as /usr/bin/ isn't in your open_basedir path (and it has not reason to be with safe_mode_exec_dir correctly set). You should now be able to call the /usr/bin/convert function without problem. Please ask if you need any further help though.

Regards,
******* 
Title: Re: [Solved]: Trouble Getting ImageMagick Properly Configured
Post by: Nibbler on June 20, 2008, 12:14:05 am
Great. Thanks for posting the solution.