Skip to content
MagickCmd › ImageMagick generate an image from scratch

ImageMagick generate an image from scratch

Create images from nothing with ImageMagick: solid colours, linear and radial gradients, checkerboards, noise and sized placeholders. No input file required.

ImageMagick can synthesise images with no input file at all. This is how you make placeholders, test assets, backgrounds and masks without leaving the terminal.

Solid colour

magick -size 1200x630 xc:'#0d9488' output.png

xc: means "X constant" — a canvas of a single colour. -size must come before it, because it configures how that source is created. Placed afterwards it is ignored and you get a 1×1 pixel image.

Gradients

magick -size 1200x630 gradient:'#0d9488'-'#0b1015' output.png
magick -size 800x800 radial-gradient:white-black output.png

Gradients run top to bottom by default. For a horizontal one, generate it rotated and turn it:

magick -size 630x1200 gradient:'#0d9488'-'#0b1015' -rotate 90 output.png

For a diagonal, generate larger, rotate, then crop the centre:

magick -size 1800x1800 gradient:'#0d9488'-'#0b1015' -rotate 45 \
  -gravity center -crop 1200x630+0+0 +repage output.png

Placeholder with its dimensions on it

magick -size 800x600 xc:'#334155' -gravity center \
  -pointsize 72 -fill white -annotate 0 '800x600' output.png

Useful for mocking up layouts without hunting for stock photography. Generate a whole set:

for s in 400x300 800x600 1200x630 1920x1080; do
  magick -size $s xc:'#334155' -gravity center -pointsize 48 \
    -fill white -annotate 0 "$s" "placeholder-$s.png"
done

Patterns

magick -size 200x200 pattern:checkerboard output.png
magick -size 400x400 pattern:hexagons output.png
magick -list pattern

The checkerboard is the one you want as a backdrop when demonstrating transparency.

Noise and texture

magick -size 800x600 xc:gray +noise Random output.png
magick -size 800x600 xc:gray +noise Gaussian -colorspace Gray output.png
magick -size 800x600 plasma:fractal output.png

Transparent canvas

magick -size 800x600 xc:none output.png

The starting point for building a composition from separate pieces.

Text as an image

magick -background none -fill '#0d9488' -pointsize 96 \
  label:'MagickCmd' output.png

label: auto-sizes the canvas to the text. Use caption: instead when you want text to wrap inside a fixed -size.

A colour swatch sheet

magick -size 200x200 xc:'#0d9488' xc:'#f59e0b' xc:'#ef4444' xc:'#3b82f6' \
  +append swatches.png

Related

Copied