Image magick

ImageMagick

Mogrify: Convert multiple files in a series

mogrify -format jpg *.ppm

This will convert multiple files in a directory in the PPM format into JPG format. To prevent overwriting old files by accident create a fresh directory. More details on Mogrify are here.

Downsampling a PDF file (to make it smaller)

>>convert -compress jpeg -density 100 input.pdf output.pdf


Converting multiple image files in a directory into an mpeg movie file

ffmpeg -f image2 -r 25 -qscale 2 -i image%04d.jpg ./out.mpg

where the files are named “image0001.jpg”, “image0002.jpg”, “image0003.jpg”, etc. A -start_number option also allows starting not from 0. Else renumber your file series.

However when the image series does not begin with 1 or 0001 (or some padding), then ffmpeg will return “file or directory not found”. To get around this you need to renumber the files. A simple bash snippet should do the job:

x=1; for i in *jpg; do counter=$(printf %04d $x); echo "$i" ; ln -s "$i" img"$counter".jpg; x=$(($x+1));

This new file series will be base 1 (i.e. starting with 1 and padded to 4 places) and sequential in number. This now can be combined as before with ffmpeg -i…

or a fuller manual on ffpmeg look here


This entry was posted in Blog, imagemagick. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>