Page 1 of 1

problem with exec command

Posted: Wed Feb 23, 2005 4:08 pm
by bg
Im using the exec command to use image magick tools to create thumbnails (need something more robust than GD). PHP generates the command, which will work if I copy and paste the generated command and execute it from the terminal. However, it does NOT work when executed from the exec() function in PHP. The function itself returns nothing, and the third parameter which is the return value of the executed command returns 127. There is no cwd issue since i use a full path for the file names. There also shouldnt be any ownership issues since all the folders that these commands are being executed upon are owned by the web server.

PS - I am aware that there is the imagick pecl module, but it is buggy and causes php to act very strangely.

Posted: Wed Feb 23, 2005 4:13 pm
by Chris Corbyn
Not sure what you're problem is but just in case you dont know... exec() only returns the last line of the output....

EDIT: Hmmm... where did all the avatars go 8O :?

Posted: Wed Feb 23, 2005 4:19 pm
by bg
d11wtq wrote:Not sure what you're problem is but just in case you dont know... exec() only returns the last line of the output....

EDIT: Hmmm... where did all the avatars go 8O :?
you have the ability to see all output via the second parameter, regardess, no output.

Posted: Wed Feb 23, 2005 4:38 pm
by feyd
post your code please.

Posted: Thu Feb 24, 2005 10:21 am
by bg
feyd wrote:post your code please.

Code: Select all

function imagick_create_thumbnail($image_dir, $image_name, $max_width, $max_height){

        $cmd = 'convert ' . $image_dir.$image_name . ' -thumbnail ' . $max_width .'x'. $max_height . ' ' . $image_dir . 'thumb_' . $image_name;
        exec($cmd, $somevar, $retval);
        return ($retval == 0) ? true : false;
}

Posted: Thu Feb 24, 2005 11:30 am
by feyd
it's possible the function is returning before it really completed the command.. have you tried sleeping for a few seconds?


gd can perform the actions you have specified without much trouble.

Posted: Thu Feb 24, 2005 1:18 pm
by bg
gonna give gd a shot but now im running into a completely unrelated problem. Trying to compile the gd extension on php but for some reason it relies on x.org... no way am i gonna bother compiling that on a server system that only gets accessed via ssh. I guess ill have to play around with compiling GD to get rid of this stupid dependancy.

Posted: Thu Feb 24, 2005 2:33 pm
by bg
got GD working... gonna have to get caught up on it, never played with it before...

Posted: Thu Feb 24, 2005 2:54 pm
by bg
ok, was getting the same php wierdness using the gd extension as I was the imagick extension. checked the error log and im getting memory allocation issues. Is there a directive in the php.ini that needs to be increased?

edit:

memory_limit seems like the only directive that would affect this, and its currently set to 8mb...

edit again: doubling this to 16meg fixed it :)

Posted: Thu Feb 24, 2005 3:15 pm
by feyd
viewtopic.php?t=30239&highlight=memory+bytes

that should explain the issue..