GraphicsMagick - markhowellsmead/helpers GitHub Wiki
Compress and optionally resize images via command line. Official reference.
A file
-interlace Plane
: Reference-quality 82%
: See this explanation for why I've quoted 82%. This assumes that the original image is high quality: optimally 100%.-resize "2560>"
: Reduce image in size to 2560px on the longest side. (Don't forget the quotes.) Images which are larger than 2560px will not be processed.
With size reduction and interlacing
gm convert -interlace Plane -quality 82% -resize "2560>" source.jpg target.jpg
Without size reduction
gm convert -interlace Plane -quality 82% source.jpg target.jpg
Generate thumbnail from the first page of a PDF
gm convert -thumbnail x300 -background white -alpha remove myNicePDF.pdf[0] myNicePDF.png
A folder
- Make sure you backup your folder first!
- Switch to the folder which is to be processed.
- Use the parameter
-format JPG
to define the format of the resultant images. - The new image will be created with this parameter as a suffix. e.g.
target.jpg
ortarget.jpeg
. - If the resultant image has the same suffix as the source image, the source image will be overwritten by the resultant image.
- Caution:
jpg
is not the same asjpeg
orJPG
. So if you have a folder containing files with varied suffixes, convert them individually, as follows.
gm mogrify -interlace Plane -quality 82% -resize "2560>" -format jpg *.jpg
gm mogrify -interlace Plane -quality 82% -resize "2560>" -format JPG *JPG