Image Slide Show Video?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Image Slide Show Video?

Post by agriz »

I understand this script.
But it is not working :(

I converted it to php. I get output gif file which has no animation.
I tried to run it as shell script just by coping your script. I got errors.

I defined the variables however in php and shell scripts.

PHP OUTPUT : output.gif without effects. Just the first image is displayed all the time.
Shell Script Output : Error

convert: unable to open image `tmp0.gif': No such file or directory @ blob.c/OpenBlob/2480.
convert: no decode delegate for this image format `/tmp/magick-XXo6BeS8' @ constitute.c/ReadImage/503.
convert: missing an image filename `tmp0.gif' @ convert.c/ConvertImageCommand/2800.
convert: unable to open image `tmp0.gif': No such file or directory @ blob.c/OpenBlob/2480.
convert: option requires an argument `-loop' @ convert.c/ConvertImageCommand/1775.

Code: Select all

frames=20
delay=20
i=1
outfile = "x.gif"
infile1 = "1.jpg"
infile2 = "2.jpg"
maskfile = "mask.jpg"

frames=$((frames-1))
while [ $i -le $frames ]; do
aa=`/usr/convert xc: -format "%[fx:100*$i/$frames]" info:`
/usr/convert $infile1 tmp0.gif
/usr/convert $infile1 $infile2 \( $maskfile -evaluate add $aa% \) -composite miff:- |\
/usr/convert -delay $delay tmp0.gif - tmp0.gif
i=$((i+1))
done
/usr/convert tmp0.gif -loop 0 $outfile
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image Slide Show Video?

Post by fmw42 »

Sorry, I mistakenly edited my script wrong and put the initial tmp0.gif inside the loop. Also I gave you the dissolve and not the wipe version. So I am fixing it. The wipe uses threshold and dissolve uses -evaluate add. try this in a unix shell. It works for me with the example images on my web site.

infile1=XXX
infile2=YYY
maskfile=ZZZ
outfile=transition.gif
frames=20
delay=20
i=1
frames=$((frames-1))
convert $infile1 tmp0.gif
while [ $i -le $frames ]; do
tt=`convert xc: -format "%[fx:100($frames-$i)/$frames]" info:`
echo "tt=$tt; i=$i"
convert $infile1 $infile2 \( $maskfile -threshold $tt% \) -composite miff:- | convert -delay $delay tmp0.gif - tmp0.gif
i=$((i+1))
done
convert tmp0.gif -loop 0 $outfile

But note that this is unix for running in a terminal window or a shell script. You cannot run this in PHP as is. You have to do the looping in PHP and just do the IM commands with exec. Also I am not sure if PHP will allow the pipe, but perhaps it will. I am not an expert on PHP.
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Image Slide Show Video?

Post by agriz »

Thanks for the update!
But i got few more errors.

But i got the final image without animating. Final Image is just first image.

Code: Select all

convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXsbhYf7' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXyHOPza' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXYl9WH9' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXOLbNae' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXmAS6Jc' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXsAUrQe' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXOY6sIi' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXkoWsih' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXUFHNKl' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXuhL3lk' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXgTnwao' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXUgGRhq' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXANLDSo' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XX0JgAkt' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXiwhvvs' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXaD3cNv' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XX0WKSTx' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXs2apuw' @ constitute.c/ReadImage/503.
convert: invalid argument for option `-evaluate': /usr/bin/convert @ convert.c/ConvertImageCommand/1296.
convert: no decode delegate for this image format `/tmp/magick-XXS0aMlA' @ constitute.c/ReadImage/503.
EDIT
I tried the output of aa
It is just echo the command

Code: Select all

echo $aa

Code: Select all

/usr/bin/convert xc: -format "%[fx:100*$i/$frames]" info:
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Image Slide Show Video?

Post by agriz »

I just fixed that line. It is working!!! :D in shell script.
I am not going to convert it to PHP to see how it is working!!!
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Image Slide Show Video?

Post by agriz »

Code: Select all

exec("$convert $infile1 $infile2 ( $maskfile -evaluate add $aa% ) -composite miff:- | ");
This line seems to be not working. i guess it should make changes in miff:- |
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image Slide Show Video?

Post by fmw42 »

agriz wrote:

Code: Select all

exec("$convert $infile1 $infile2 ( $maskfile -evaluate add $aa% ) -composite miff:- | ");
This line seems to be not working. i guess it should make changes in miff:- |

First, in windows you must escape % as %%. Second the variables in unix start with $. I don't know what they are in Windows. Third, you cannot separate the lines for the commands (or you must use a windows ^ to signify that the command is continued on the next line)

convert $infile1 $infile2 \( $maskfile -threshold $tt% \) -composite miff:- | convert -delay $delay tmp0.gif - tmp0.gif

and I don't know if windows supports the pipe |

Please review
http://www.imagemagick.org/Usage/windows/
for windows syntax and scripting

Sorry I cannot help much with converting to windows syntax.
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Image Slide Show Video?

Post by agriz »

it is fedora.

Everything is good. I missed the / slashes and it should be in single line as you mentioned.

However the execution takes few seconds to produce the output. Will it use much ram?
I am going to go through your full scripts :)
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Image Slide Show Video?

Post by agriz »

Is it possible to add third photo in this transition?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image Slide Show Video?

Post by fmw42 »

agriz wrote:Is it possible to add third photo in this transition?
No, not without changing the script. But basically all you need to do is make two animations with the 3 images and then merge the animations.
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Image Slide Show Video?

Post by agriz »

fmw42 wrote:
agriz wrote:Is it possible to add third photo in this transition?
No, not without changing the script. But basically all you need to do is make two animations with the 3 images and then merge the animations.
Yes, Its working pretty good. :)
image 1 & 2, 2 & 3 again 3 & 1 gives nice effect.
But took 20 seconds on my localhost...

Is it normal?
Any other way to speedup?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image Slide Show Video?

Post by fmw42 »

Any other way to speedup?
No, not that I am aware with IM. (other than openmp multicore processing). It might work faster on Q8 IM?
Post Reply