Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is the colon operator defined in the context of image magick command line usage

Tags:

imagemagick

I can't find any documentation for this.

I have found examples in the image magick documentation which use a colon but nothing explicit about how the colon is interpreted.

The examples are confusing ;

magick -size 640x480 pattern:checkerboard checkerboard.png

suggests it sets the attribute on the left (pattern) to the value on the right (checkerboard)

but then

magick -size 640x480 -depth 8 rgb:image image.png

suggests it sets file type of image - the thing on the right - to what is left of it

EDIT

This was all just a brain fart on my part; I was thinking (for various reasons) of "image" as a thing being made/assigned rgb which makes no sense (as "image" is a file name / input parameter).

The sensible interpretation is obviously of rgb as a thing (image of type rgb) being assigned the info in the file "image" .

So from these two examples at least, it appears the colon just assigns/applies the right hand operand to the left hand operand as you would expect.

like image 951
Bob Avatar asked Sep 05 '25 16:09

Bob


1 Answers

There are a couple of ways the colon is used.

Some options which create their own canvas have a colon, for example:

  • xc: creates a canvas
  • gradient:colourA-colourB creates a gradient from colourA to colourB
  • tile: creates a repeated tile
  • radial-gradient: creates a radial gradient
  • rose: creates the built-in rose image
  • pattern: for a built-in pattern as you saw
  • logo: for the ImageMagick logo
  • label: for text labels
  • caption: for text captions

Then the colon sometimes prefixes a filename to tell ImageMagick what is in it. This is your rgb: use case, and it is necessary because the filename doesn't happen to end in .rgb. Other examples of this are:

  • gray: when the greyscale input file doesn't end in .gray
  • tif:fd:5 read a TIFF from file descriptor 5

Or to tell it to write a specific variant of a file, e.g.:

  • PNG8: to write a palettised PNG
  • PNG24: to write an RGB888 PNG
  • PNG32: to write an RGBA8888 PNG with alpha
  • PTIF: to write a pyramid TIFF
  • BMP3: to write a version 3 Microsoft BMP file
  • fd:3 write output on file descriptor 3
  • gif:fd:4 write output as GIF on file descriptor 4

There is some documentation here.

like image 115
Mark Setchell Avatar answered Sep 08 '25 23:09

Mark Setchell