My cheat sheet of image processing one-liners.
# With potrace
, convert BMP to SVG
potrace -s input.bmp
# Compress PNG with pngquant
pngquant --quality 80 input.png
# Convert to avif with avifenc
# 10-bit avif
avifenc -s 1 -a color:sharpness=2 -d 10 input.png output.avif
Imagemagick
# Resize and keep aspect ratio
convert input.jpg -resize 500x221^ -gravity center -extent 500x221 -quality 90 output.jpg
# Compress:
convert input.jpg -quality 80 -interlace plane -strip output.jpg
# Convert to WEBP:
convert input.jpg -quality 80 output.webp
# Blur
convert -scale 50% -blur 0x8 -resize 200% input.jpg output.jpg
# Distort effect
# Mode specifies the size of the window (in pixels) over which the statistical operation will be applied
convert -statistic Mode 80 input.jpg output.jpg
# Paint effect
convert -paint 20 input.jpg output.jpg
# Extract all frames in gif
convert -coalesce input.gif frame%05d.png
# Extract all frames in gif with ffmpeg
ffmpeg -i input.gif frame_%d.png
# Remove all image EXIF:
mogrify -strip input.jpg
PDFs
# If Ghostscript ≥9.24, remove policies from /etc/ImageMagick-6/policy.xml
<!-- disable ghostscript format types -->
<policy domain="coder" rights="none" pattern="PS" />
<policy domain="coder" rights="none" pattern="PS2" />
<policy domain="coder" rights="none" pattern="PS3" />
<policy domain="coder" rights="none" pattern="EPS" />
<policy domain="coder" rights="none" pattern="PDF" />
<policy domain="coder" rights="none" pattern="XPS" />
# PDF to tiff
# -density: dots per inch, resolution
# -depth: bit depth, 8-bit
# -strip: remove all metadata / EXIF
# -alpha off: no transparency
convert -density 300 input.pdf -depth 8 -strip -background white -alpha off output.tiff
# JPEG to PDF
convert input.jpg -quality 80 output.pdf
# Multiple page PDF from JPEGs
convert {01.jpg,02.jpg} -quality 80 output.pdf
»
Visitors: Loading...