500 Internal error with PHP/ImageMagik - help!

software development


I’m relatively new to using ImageMagik, but I have a fair understanding of PHP5. Anyway, I’m using a PHP script to call a command line procedure to IM which creates the thumbnails:

//Gets all of the original JPG images
$orig_files = get_all_image_filenames("…/albums/$albumName/");
system(‘for img in ls /home/user/domain.com/albums/'.$albumName.'/; do convert -thumbnail 450 /home/user/domiain.com/albums/’.$albumName.’/$img /home/user/domain.com/albums/’.$albumName.’/thumb_$img; done’);
//Note: user and domain were spoofed.

This is run inside a PHP file and all variables are accounted for. Sometiems this script runs correctly and sometimes it fails and I recieve the following error:

Premature end of script headers: /dh/cgi-system/php5.cgi

I have not been able to figure out the cause of this. If anyone can help me or point me in the right direction or suggest a better solution, please let me know. Keep in mind iI’m keeping it rather simple and I don’t need anything too fancy.


Shouldn’t be too hard to convert this for your own use.

<?php $location='/usr/bin/convert'; $command='-thumbnail 150'; $name='glass.'; $extfrm='jpg'; $extto='png'; $output="{$name}{$extto}"; $convert=$location . ' ' .$command . ' ' . $name . $extfrm . ' ' . $name . $extto; exec ($convert); print ""; ?>