Hello Everyone!
I've written the following PHP code you use ImageMagick to create a thumbnail of every photo in a directory. It's runing on a Apache server.
Loop Code Extract:
foreach ($photofile as $value)
{
$clientphotos['image'] = $value;
$image = "/usr/home/admin/domains/designjunkie.com/public_html/test/web/photoshoots/".$clientphotos['shootid']."/".$clientphotos['image'];
$thumbname = "/usr/home/admin/domains/designjunkie.com/public_html/test/web/photoshoots/".$clientphotos['shootid']."/thumbnails/".$clientphotos['image'];
system("\"/usr/local/bin/convert\" -thumbnail 170x120 $image $thumbname");
}
The problem i have is that it seems to complete the first cycle and it creates a thumbnail of the first photo then for the second photo onwards it returns a Segmentation fault error. Its works fine on my local machine but not on the live server.
Thanks
Durham
Segmentation fault in PHP loop
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Segmentation fault in PHP loop
Try to simplify, get error outputs, check version numbers. Print the exact command that is being run, etc etc etc
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Segmentation fault in PHP loop
I've tried doing that - everything seems to work apart from the convert command always brings up a Segmentation fault for the second item onwards.
It works fines with just one item.
I'm using Version: ImageMagick 6.3.5 10/16/07 Q16 if that helps?
Even if i take it out of the loop and put the following for each photo (changing it from photo1.jpg to photo2.jpg etc..) it will still only do the first photo and then bring the Segmentation fault for the others:
$image = "/usr/home/admin/domains/designjunkie.com/public_html/test/web/photoshoots/50/photo1.jpg";
$thumbname = "/usr/home/admin/domains/designjunkie.com/public_html/test/web/photoshoots/50/thumbnails/photo1.jpg";
system("\"/usr/local/bin/convert\" -thumbnail 170x120 $image $thumbname");
It works fines with just one item.
I'm using Version: ImageMagick 6.3.5 10/16/07 Q16 if that helps?
Even if i take it out of the loop and put the following for each photo (changing it from photo1.jpg to photo2.jpg etc..) it will still only do the first photo and then bring the Segmentation fault for the others:
$image = "/usr/home/admin/domains/designjunkie.com/public_html/test/web/photoshoots/50/photo1.jpg";
$thumbname = "/usr/home/admin/domains/designjunkie.com/public_html/test/web/photoshoots/50/thumbnails/photo1.jpg";
system("\"/usr/local/bin/convert\" -thumbnail 170x120 $image $thumbname");
Re: Segmentation fault in PHP loop
What happens if you use this ?
Are these image paths correct? It looks like you have 2 paths from root in the same path. I would have thought public_html/test/web/photoshoots/50/photo1.jpg would have done.
What you could do as well is ceate a tempory folder with some images and the code in to prove it works then modify it to what you want.
I use relative paths in my code and that works OK.
Code: Select all
$image = "/usr/home/admin/domains/designjunkie.com/public_html/test/web/photoshoots/50/photo1.jpg";
$thumbname = "/usr/home/admin/domains/designjunkie.com/public_html/test/web/photoshoots/50/thumbnails/photo1.jpg";
$array = array();
exec("/usr/local/bin/convert $image -thumbnail 170x120 $thumbname 2>&1", $array);
echo "<br>".print_r($array)."<br>";
What you could do as well is ceate a tempory folder with some images and the code in to prove it works then modify it to what you want.
I use relative paths in my code and that works OK.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Segmentation fault in PHP loop
You have checked for error output haven't you?durham86 wrote:Code: Select all
system("\"/usr/local/bin/convert\" -thumbnail 170x120 $image $thumbname");
What if you just convert the file, without the -thumbnail resize?
Does that segmentation fault?
What about
Code: Select all
system("\"/usr/local/bin/convert\" rose: $thumbname");
ASIDE: -thumbnail operator should be AFTER reading the image. It should be thought of as an operator and not a UNIX command option.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/