Hi,
I have a IMagick PHP code that i use from a cron job to generate GIF files from folders of images. The problem is that the gifs are around 3 - 10mb in size and take too long to download.
Is it possible to generate a gif but say every n image in a folder? I have seen this is possible to extract frames from a GIF but not to generate a GIF.
I have tried various methods to reduce the GIF size and the sizes above are already optimised.
Grateful for any advice.
Many thanks
Burt
IMagick to generate GIF and skip every n image
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: IMagick to generate GIF and skip every n image
You would have to write a script loop to take only every other images from the folder to make your gif. You could for example save a list of every other file into a variable or as text file and read from that text file.
The IM frame command [X-Y] does not have a skip feature, as far as I know.
It is generally a good idea to identify your IM version and platform when asking questions.
The IM frame command [X-Y] does not have a skip feature, as far as I know.
It is generally a good idea to identify your IM version and platform when asking questions.
Re: IMagick to generate GIF and skip every n image
Thanks for the reply. I guess this is a separate feature to IM to generate the txt file? Perhaps a cron job can do this too.
Linux, IM version 6.6.3
Linux, IM version 6.6.3
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: IMagick to generate GIF and skip every n image
Another idea would be to delete every other image in the command sequence. In command line, suppose you have 10 images in the folder, you could do
IM 6.6.3 is ancient (about 350 versions old). I would suggest you upgrade if you can.
Code: Select all
convert -delay 50 *.jpg -delete 1,3,5,7,9 -loop 0 result.gif
Re: IMagick to generate GIF and skip every n image
Thanks for the feedback. I thought about this but it would delete my master images that i need for other scripts.
I cant change the IM version as it is controlled by my hosting company
I cant change the IM version as it is controlled by my hosting company
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: IMagick to generate GIF and skip every n image
using -delete does not delete images from your folder, only from the in memory sequence loaded by *.jpg.
However, it would be better to load only the images you want.
However, it would be better to load only the images you want.
Code: Select all
cd somedirectory
imgArr=(`ls`)
num=${#imgArr[*]}
list=""
for ((i=0; i<num; i=i+2)); do
list="$list ${imgArr[$i]}"
done
convert -delay 50 $list -loop 0 result.gif
Re: IMagick to generate GIF and skip every n image
Perfect. Many thanks for the help.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: IMagick to generate GIF and skip every n image
If you just want JPG, then use
Code: Select all
imgArr=(`ls *.jpg`)