ImageMagick Linux mimick ezgif.com result - imagemagick

Ezgif.com is a great page but can ImageMagick get the same results?
Ezgif settings:
Delay: 200 per image
Crossfade frames
Fader delay: 6
Frame Count: 10
My attempt via Linux Terminal:
convert -delay 200 -loop 0 *.jpg myimage.gif

As i told you on FL, you need to simply use
convert -resize (Smallest size) -delay 200 -morph 200 (source) (destination)
e.g:
convert -resize 200x200 -delay 200 -morph 200 /var/home/user1/pictures/*.jpg /var/home/user1/myresult.gif
on my side i can show you the result like this used on WINDOWS
in Windows Pictures folder
used this command:
C:\Users\Public\Pictures\Sample Pictures>convert -resize 20% -delay 20 -loop 0 *.jpg -morph 5 myimage.gif

Here is Unix shell script to create a faded animation of 4 images each with 10 intermediate fades. It loops over each successive pair of images and creates the faded intermediate images by blending the pair at different percentages.
Input:
(
imgArr=(lena.jpg mandril3.jpg zelda1.jpg peppers.jpg)
for ((i=0; i<4; i++)); do
img1=${imgArr[$i]}
j=$((i+1))
jj=$((j%4))
img2=${imgArr[$jj]}
for ((k=0; k<11; k++)); do
pct=$((10*k))
convert $img1 $img2 -define compose:args=$pct -compose blend -composite miff:-
done
done
) | convert -delay 20 - -loop 0 anim.gif
Animation:
Note that I had to shrink the image to 75% dimensions to make the file size small enough for upload here.

A complete one-liner solution with increased delay for main frames and last-to-first transition, with the same settings OP asked:
convert -loop 0 *.jpg -morph 10 -set delay '%[fx:(t%11!=0)?6:200]' -duplicate 1,-2-1 out.gif
-morph 10 inserts 10 intermediate frames between every original frame, so we need to increase the delay time for every 11th frame, so the fx part sets different delay time for them.
-duplicate 1,-2-1 does the transition for last to first frame

Related

Imagemagick convert gif creation random image order

i have a folder of images with names foo<bar>.png where <bar> ranges from 0 to 100.
When i create a gif of these images with
convert -dispose previous -delay 10 -resize 25% -loop 0 *.png myimage.gif
it creates a gif with images in order like 0,1,2,3...
Is there a command to select images in random order?
If your PNG images are all the same dimensions, and if the number of images can be evenly divided into a grid, like 72 images would make a grid of 8 x 9 images, and if your images are small enough to read them all into a single ImageMagick command, here is a command that will randomize the order of a group of 72 input images...
convert *.png -virtual-pixel tile +append -crop 9x1# -append +repage ^
-crop 1x9# -distort affine "0,0 %[fx:floor(rand()*8)*(w/8)],0" -append +repage ^
-crop 8x1# -distort affine "0,0 0,%[fx:floor(rand()*9)*(h/9)]" +append +repage ^
-crop 8x9# +repage -set delay 10 -loop 0 image.gif
It basically makes a grid, randomly rolls all the rows, then randomly rolls all the columns. The shuffle scatters the images pretty well, but if you want a deeper shuffle, copy and paste those two "-crop ... -distort" lines, and add them below the first two...
convert *.png -virtual-pixel tile +append -crop 9x1# -append +repage ^
-crop 1x9# -distort affine "0,0 %[fx:floor(rand()*8)*(w/8)],0" -append +repage ^
-crop 8x1# -distort affine "0,0 0,%[fx:floor(rand()*9)*(h/9)]" +append +repage ^
-crop 1x9# -distort affine "0,0 %[fx:floor(rand()*8)*(w/8)],0" -append +repage ^
-crop 8x1# -distort affine "0,0 0,%[fx:floor(rand()*9)*(h/9)]" +append +repage ^
-crop 8x9# +repage -set delay 10 -loop 0 image.gif
Carefully replace the "8"s and "9"s with the width and height of the grid that holds the number of images you're using. I use it in a script that shuffles a deck of playing card images, 13 rows and 4 columns.
This uses ImageMagick v6 in Windows CMD syntax. In a BAT script double all the percent signs "%%". It would probably work on a *nix OS by changing all the continued-line carets "^" to backslashes "\". For ImageMagick v7 use "magick" instead of "convert".
I can tell you 2/3 of the answer on Windows, and hopefully some other kind soul can add the rest for you. Nobody said answers have to be complete.
Create a text file containing the names of the PNGs you want to animate. I believe that is:
DIR /B *.png > filelist.txt
Shuffle the lines in that file. I don't know how to do that in Windows. In Linux and macOS it is shuf. Here's a little Python equivalent:
python -c "import random, sys; lines = open(sys.argv[1]).readlines(); random.shuffle(lines); print ''.join(lines)," filelist.txt > shuffled.txt
Pass that file to ImageMagick like this:
convert -loop 0 -delay 80 #filelist.txt animation.gif
If you get that working, you can avoid the need for a temporary file by using this syntax:
DIR /B *.png | SHUFFLELINES | convert -loop 0 -delay 80 #- animation.gif

Animated gif created with ImageMagick has glitchy block color background

I am trying to stitch together a bunch of .png's which contain some alpha (transparency) but which have a uniformly white background. The png's look fine individually, but in the resulting .gif some frames acquire a patchy background that appears to have the same RGBA color as some of the points being animated.
I have tried the following commands
convert -delay 1 im*.png anim.gif
convert -delay 1 -alpha set im*.png anim.gif
convert -delay 1 -alpha set -dispose background im*.png anim.gif
convert -delay 1 -alpha set -dispose previous im*.png anim.gif
convert -delay 1 -alpha set -dispose previous -background white im*.png anim.gif
pretty much just trying additional flags to see if anything happens to fix the glitch, but I get the same behavior in every case. Anyone have a fix?
Ah, this question led me to the right answer --
convert -delay 1 -layers Optimize im*.png anim.gif
works!

How to avoid Imagemagick's convert overlay of frames in a gif

I have a bunch of files labelled 1.png and so on. I'm using the following command line to produce a gif animation:
convert -delay 20 *.png animation.gif
But the frames get superposed sequentially. I did not expect this behavior, what might be wrong?
Thanks
Option -dispose previous:
convert -dispose previous -delay 20 *.png animation.gif

how to make a high quality animated image with imagemagick

I want to make an animated gif from those .png image:
I do it with this command:
convert -layers OptimizePlus -delay 25x100 ps1-*.png -loop 0 ps1.gif
It made an animated gif successfully, however, the output has very low quality and smaller than input images:
After some search, I got -quality
convert -layers OptimizePlus -delay 25x100 -quality 99 ps1-*.png -loop 0 ps1.gif
But it seems like imagemagick just ignore the parameter.
The problem is that your source PNGs have an alpha channel which is not supported by GIFs. So you have to remove transparency from your source images first. Since you're dealing with multiple source images, you can't use the -flatten method. With newer ImageMagick versions the following should work:
convert -background white -alpha remove -layers OptimizePlus -delay 25x100 ps1-*.png -loop 0 ps1.gif
If your version of ImageMagick is older than 6.7.5, you can try:
convert -bordercolor white -border 0 -layers OptimizePlus -delay 25x100 ps1-*.png -loop 0 ps1.gif
I got the following result with the latter command:

ImageMagick and transparent background for animated gif

I have an animation as a batch of .png files (100 files). The background is transparent in the source .png files. I want to convert them into a single animated gif. I have tried this command:
convert -delay 0 -loop 0 -alpha set *.png ani.gif
But the result is the following (green is the HTML page background):
How should I remove the previous frames from an every following one?
I've found -dispose previous.
UPDATE
OK, convert -delay 0 -loop 0 -alpha set -dispose previous *.png ani.gif
The solution is here:
http://www.alecjacobson.com/weblog/?p=2601
The magic keyword seems to be “dispose” and calling the following fixed the problem:
convert -dispose 2 screencapture-*.tga screencapture.gif

Resources