Skip to content

Image Tools

September 29, 2023
August 4, 2016

fogleman/primitive: Reproducing images with geometric primitives.
Bigjpg - AI 人工智能图片无损放大 - 使用人工智能深度卷积神经网络(CNN)无损放大图片
分享 3 款图片处理神器,渣图还原大法好,老厉害了! - 知乎
LunaPic | Free Online Photo Editor | Transparent Background

ImageMagick

ToolDescription
animateanimate an image sequence on any X server.
comparemathematically and visually annotate the difference between an image and its reconstruction.
compositeoverlap one image over another.
conjureinterpret and execute scripts written in the Magick Scripting Language (MSL).
convertconvert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.
displaydisplay an image or image sequence on any X server.
identifydescribe the format and characteristics of one or more image files.
importsave any visible window on an X server and outputs it as an image file. You can capture a single window, the entire screen, or any rectangular portion of the screen.
mogrifyresize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. mogrify overwrites the original image file, whereas, convert writes to a different image file.
montagecreate a composite image by combining several separate images. The images are tiled on the composite image optionally adorned with a border, frame, image name, and more.
streama lightweight tool to stream one or more pixel components of the image or portion of the image to your choice of storage formats. It writes the pixel components as they are read from the input image a row at a time making stream desirable when working with large images or when you require raw pixel components.

ImageMagick v6 Examples
Command-line Tools @ ImageMagick
ImageMagick: Convert, Edit, Or Compose Bitmap Images

ImageMagick 使用心得
Turn many pictures into a movie | daniel.haxx.se

The Definitive Guide to ImageMagick | Michael Still | Apress author's site

# crop lower part of image
convert input.jpg -crop 300x150+0+150 +repage image-cropped.jpg

# add shadow
convert screenshot.jpg \( +clone -background black -shadow 60×5+0+5 \) +swap -background white -layers merge +repage shadow.jpg

# add timestamp, http://www.imagemagick.org/script/escape.php
convert *.jpg -font Arial -pointsize 72 -gravity SouthEast -fill yellow -annotate +100+100 %[exif:datetime] output-%d.jpg

# convert to pdf
convert a.png b.png -compress jpeg -resize 1240x1753 \
                      -extent 1240x1753 -gravity center \
                      -units PixelsPerInch -density 150x150 multipage.pdf

# convert sequence of images to GIF
convert -delay '1x20' *.png output.gif # 20FPS
convert -delay '2x1' *.png output.gif  # 2 sec each frame

Resizing Image

Resizing or Scaling -- ImageMagick Examples

# resizing image
convert -resize 300x300 image.jpg image-small.jpg
convert -resize 1080 {from_path} {to_path}  # fix weight only
convert -resize x1080 {from_path} {to_path}  # fix height only

# very low quality
convert -thumbnail {width} *.jpg

How can I scale all images in a folder to the same width? - Ask Ubuntu

Command-line Processing Geometry @ ImageMagick

My favorite Linux commands for optimizing web images | Opensource.com with mogrify

Image stitching

# horizontal
convert image.jpg ...  +append output.jpg
# vertical
convert image.jpg ...  -append output.jpg

mogrify -adjoin

creating image

Canvas Creation: Random -- IM v6 Examples
Canvas Creation: Tile -- IM v6 Examples

# solid color image
convert -size 100x100 canvas:khaki  canvas_khaki.gif
convert -size 100x100 xc:wheat  canvas_wheat.gif

# patterned image
# use "tile" to take source from pipe and repeat
convert -size 30x54 pattern:hexagons \
          -fill tomato     -opaque white \
          -fill dodgerblue -draw 'color 10,10 floodfill' \
          -fill limegreen  -draw 'color 10,25 floodfill' \
          -roll +15+27 \
          -fill dodgerblue -draw 'color 10,10 floodfill' \
          -fill limegreen  -draw 'color 10,25 floodfill'   miff:- |\
convert -size 200x200 tile:- image.jpg

convert -size 500x500 pattern:checkerboard  miff:- |\
convert -size 5000x5000 tile:- image.jpg
# get quality of JPEG file
identify -verbose file.jpg | grep Quality

with text

convert -size 1280x720 xc:grey \
          -font roboto -pointsize 300 -draw "text 100,600 'userName' text 100,300 'userTitle'"  \
          image.jpg

convert -size 1280x720 xc:grey \
          \( -background none label:"A very much longer label" -trim -gravity center \) \
          -composite image.jpg

convert 0001.png \
          \( -size 560x230 -background white -font roboto-mono label:"0001" -trim -gravity center -extent 560x230 \) \
          -gravity northwest -geometry +1100+15 -composite 0001.png

dynamic - ImageMagick best fit text within rectangle? - Stack Overflow

Colorspace

Color Management @ ImageMagick
Converting anything to RGB correctly - ImageMagick

convert CMYK.jpg -profile /usr/share/color/icc/colord/sRGB.icc RGB.jpg
convert -list colorspace
convert flower_original.jpeg -colorspace Gray greyscale_flower.jpeg
convert flower_original.jpeg -negate flower_negative.jpeg

Photon

Photon: A WebAssembly Image Processing Library

Node.js

sharp - High performance Node.js image processing is VIPS's Node binding
lovell/sharp: High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
How To Process Images in Node.js with Sharp | DigitalOcean

jimp-dev/jimp: An image processing library written entirely in JavaScript for Node, with zero external or native dependencies.

Python

Wand documentation
ImageMagick/PythonMagick: PythonMagick
python - Documents and examples of PythonMagick - Stack Overflow

Python Imaging Library (PIL)
Pillow — Pillow (PIL Fork) documentation
python-image of most distro points to pillow
Image Module — Pillow (PIL Fork) documentation
Concepts — Pillow (PIL Fork) documentation

Imageio website