Hi there,

I'm hoping this isn't an inappropriate question for this list. Please  
redirect me if it is.
I'm writing a php script, which uses shell_exec() to run ImageMagick  
convert commands at the shell.

Some of the conversions are multi-stage, i.e. first resize, then add a  
mask etc. Each stage needs to wait for the previous to be complete  
before it should be executed. Noting the fact that ImageMagick returns  
nothing to the shell on success, how can I write a PHP script that  
knows when it should execute each stage?

Here's an example of what I'm doing now, but it seems to create  
problems, which I think are related to the later commands being run  
too soon:

        <?
        $command = "convert image.gif -resize 1000x1000 /tmp/image.png";
        shell_exec($command);

        $command2 = "convert /tmp/image.png -thumbnail 80x80 /thumbs/2.jpg";
        shell_exec($command2);

        $command3 "convert  /thumbs/2.png -border 2 -format 'roundrectangle  
1,1 %[fx:w-2],%[fx:h-2] 15,15' info: > /tmp/rounded_corner.mvg";
        shell_exec($command3);

        $command4 "convert /thumbs/2.png -border 2 -matte -channel RGBA - 
threshold -1 -background none -fill white -stroke black -strokewidth 1  
-draw "@/tmp/rounded_corner.mvg" /tmp/rounded_corner_mask.png";
        shell_exec($command4);

        $command5 "convert /thumbs/2.png -matte -bordercolor none -border 2 / 
tmp/rounded_corner_mask.png -compose DstIn -composite  -depth 8 - 
quality 95 /thumbs/2.png";
        shell_exec($command5);
        ?>


What happens is that the round corner only gets applied to the top  
left corner of the image. If I apply the rounded corner execs (i.e.  
the last 3 commands) to an existing thumbnail, then it works  
correctly, so I'm guessing that above it is tripping over the first  
two commands which perhaps haven't completed by the time the last 3  
kick in.


Thanks,
Noel da Costa

_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to