imagemagick composite in php gives error "composite: no decode delegate
for this image format"
I am trying to translate a shell script that uses imagemagick to a php script
#!/bin/bash
# Author: terremoto@reddit.com
# License: Public Domain
RANDOM_IMG_1="$RANDOM.jpg"
RANDOM_IMG_2="$RANDOM.jpg"
RANDOM_IMG_3="$RANDOM.jpg"
convert -geometry 640x640 -quality 100 "$1" "$RANDOM_IMG_1"
convert -geometry 640x640 -quality 70 "$1" "$RANDOM_IMG_2"
composite -compose difference -quality 100 "$RANDOM_IMG_1" \
"$RANDOM_IMG_2" \
"$RANDOM_IMG_3"
mogrify -normalize "$RANDOM_IMG_3"
rm "$RANDOM_IMG_1" "$RANDOM_IMG_2"
mv "$RANDOM_IMG_3" "ela.jpg"
The PHP script built looks like below
<?php
$op = shell_exec('RANDOM_IMG_1="$RANDOM.jpg" 2>&1');
$op = shell_exec('RANDOM_IMG_2="$RANDOM.jpg" 2>&1');
$op = shell_exec('RANDOM_IMG_3="$RANDOM.jpg" 2>&1');
$op = shell_exec('/usr/bin/convert -geometry 640x640
-quality 100 "' . $file_name . '" "$RANDOM_IMG_1"
2>&1');
$op = shell_exec('/usr/bin/convert -geometry 640x640
-quality 100 "' . $file_name . '" "$RANDOM_IMG_2"
2>&1');
$op = shell_exec('/usr/bin/composite -compose
difference -quality 100 "$RANDOM_IMG_1" \
"$RANDOM_IMG_2" \
"$RANDOM_IMG_3" 2>&1');
$op = shell_exec('/usr/bin/mogrify -normalize
"$RANDOM_IMG_3" 2>&1');
$op = shell_exec('rm "$RANDOM_IMG_1" "$RANDOM_IMG_2"
2>&1');
$op = shell_exec('mv "$RANDOM_IMG_3" "ela.jpg" 2>&1');
?>
The "2>&1" at the end of each shell_exec is not required. But whenever I
tried to print the output of the shell_exec, it was blank, unless the
"2>&1" was added, which was suggested on some thread.
I am running the script on a hostgator shared host. convert and mogrify
are available in /usr/bin and I have verified them.
But on running the script , I am facing an error composite: no decode
delegate for this image format /tmp/magick-WWGRc13y' @
error/constitute.c/ReadImage/544. composite: no decode delegate for this
image format //' @ error/constitute.c/ReadImage/544. composite: no decode
delegate for this image format /tmp/magick-CKVLsBQa' @
error/constitute.c/ReadImage/544. composite: no decode delegate for this
image format //' @ error/constitute.c/ReadImage/544. composite: missing an
image filename `' @ error/composite.c/CompositeImageCommand/1621.
What is the error about?
Is it because the temporary file is lacking the extension? Any thoughts?
No comments:
Post a Comment