ImageMagick PDF and JPG useful examples

ImageMagick convert PDF to JPG

Crop, rotate and set jpg quality on multipage PDF to JPG convert:

convert -density 150 -resize 968x -gravity NorthEast -extent 968x692 -rotate "-90" 1.pdf -quality 90 1.jpg

 

ImageMagick PDF to JPG sometimes results in black background

Need remove alpha in PDF:

convert -density 150 -resize 1000x -fill white -alpha remove *.pdf -quality 90 1.jpg

 

Bash script with ImageMagick that resize and change qulity a lof of images

#!/bin/bash

if [ -d photos ]; then
	rm -rf photos
fi

mkdir photos

for img in ./*
do
	filename=$(basename "$img")
	filename="${filename%.*}"
	
	convert "$img" -auto-orient -resize 1000x -quality 85% "photos/$filename.jpg"
done;