Barbarian Meets Coding
barbarianmeetscoding

WebDev, UX & a Pinch of Fantasy

1 minute readcli

Useful CLI Utilities

A collection of useful CLI utilities and tools for the command line.

ImageMagick

ImageMagick is a powerful command-line tool for creating, editing, composing, and converting bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, WebP, HEIC, SVG, PDF, DPX, EXR and TIFF.

Installation

Install it via the package manager of your choice:

# macOS
brew install imagemagick

# Ubuntu/Debian
sudo apt-get install imagemagick

Usage

ImageMagick comes with several command-line tools:

  • convert: Convert between image formats and perform operations
  • mogrify: Similar to convert but overwrites the original images
  • identify: Display information about an image
  • composite: Composite one image onto another
  • montage: Create a composite image from multiple images

Some common uses:

# Resize an image to 50% of its original size
convert image.jpg -resize 50% image_resized.jpg

# Convert between formats
convert image.jpg image.png

# Add a border
convert image.jpg -border 20x20 bordered_image.jpg

# Create a thumbnail
convert image.jpg -thumbnail 100x100 thumbnail.jpg

# Compress an image (quality ranges from 1-100)
convert image.jpg -quality 75 compressed_image.jpg

# Batch process multiple images
mogrify -resize 800x600 *.jpg

# Convert all JPEGs to PNG format
mogrify -format png *.jpg

# Apply a blur effect to all images
mogrify -blur 0x5 *.jpg

# Rotate all images 90 degrees clockwise
mogrify -rotate 90 *.jpg

# Add watermark to all images
mogrify -draw "text 10,20 'Copyright'" *.jpg

# Auto-adjust images (improve contrast, brightness)
mogrify -auto-level *.jpg

Jaime González García

Written by Jaime González García , dad, husband, software engineer, ux designer, amateur pixel artist, tinkerer and master of the arcane arts. You can also find him on Twitter jabbering about random stuff.Jaime González García