Converting from grayscale to RGB colorspaces?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Im is probably trying to be 'smart' and knows that the image contains only grey colors, so sames only to a grey TIF format.

It does that sort of output optimization.

You could try making some pixel slightly off-grey by the tinyest amount :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

There may be, but I don't know enough of internals to know.

There are a lot of little -define options that you can apply to control the output API handlers, but these are all specific to each format, and the API library they are using.
For example

Code: Select all

-define tiff:rows-per-strip=8
controls the amount of striping in a output TIFF file. These however don't seem to be documented outside the IM source however (if they exist yet).
I have saved all the ones I do know about in IM Examples, Commn File Formats, Miscelenious Notes, but unless it is mentioned on the net I won't know about it.

You may like to mail christy for some more info -- and please share anything you find so I can record it.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

To force a grayscale image to RGB use this command:
  • convert IMG-01-bw.tif -depth 8 -type TrueColor IMG-01-RGB.tif
If the command fails, install a more recent version of ImageMagick.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

I thought -type was a setting for image creation (reading), didn't know it is also an output setting, or is this the case only with TIFF files?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

The -type option is an image operator. In most cases if you find an option handled in MogrifyImage(), its a image operator. If you find it in MogrifyImageInfo(), its an image setting. Finally, if you find it in MogrifyImageList(), it is an image list operator.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Then how does -type differ from -colorspace
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

The -colorspace and -type option can end up producing the same image but there are differences. For example you can set the grayscale colorspace but you need -type bilevel to produce a monochrome image.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Okay so if these are the basically the same, is their some reason the two options can't be merged into a single operator with approparite aliasing for backward compatibility?

EG: why two seperate operators?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

There are two separate option because setting the colorspace only sets the image colorspace, whereas, the image type can set one or more of the image colorspace, depth, matte channel, or image colormap.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Okay thanks.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply