Convert RGB Tif (black & white pixels only)

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
tresorjoe
Posts: 13
Joined: 2018-04-12T02:19:12-07:00
Authentication code: 1152

Convert RGB Tif (black & white pixels only)

Post by tresorjoe »

Hi,

I created a 2 pixel file in RGB, 8bit, TIFF format, sRGB ICC profile embedded, with one pixel being RGB 0,0,0 and the other one RGB 255,255,255. If I use following command the resulting output TIF file is converted to Grayscale:

Code: Select all

convert RGB-black-and-white-pixel.tif RGB-black-and-white-pixel_out.tif
Any chance I can force that RGB is preserved for the output? Tried -colorspace RGB or -colorspace sRGB but always the output results in Grayscale.
PS: If using png as the output format the output is 1bit bitmap.

Thanks,
Joe
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert RGB Tif (black & white pixels only)

Post by snibgo »

Try "-type TrueColor", eg:

Code: Select all

f:\web\im>%IM%convert xc:Black xc:White -type TrueColor x.tiff

f:\web\im>exiftool x.tiff
ExifTool Version Number         : 10.97
File Name                       : x.tiff
:
:
Image Width                     : 1
Image Height                    : 1
Bits Per Sample                 : 16 16 16
snibgo's IM pages: im.snibgo.com
tresorjoe
Posts: 13
Joined: 2018-04-12T02:19:12-07:00
Authentication code: 1152

Re: Convert RGB Tif (black & white pixels only)

Post by tresorjoe »

Great, worked fine. Thanks. Even preserved the embedded ICC profile.
Post Reply