Hi,
I'm using a somewhat older version of ImageMagick, on the pc --5.5.7
Hopefully, that won't affect any possible answers to this hopefully simple question.
When using convert.exe on an RGB file that is composed of all neutral values, the utility takes it upon itself to reduce it to a single-channel grayscale image (assuming I'm not adding a non-neutral value as part of the convert).
For example:
convert -bordercolor black -borderwidth 25 gray_rgb_file.tif new_file.tif
The "new_file.tif" is now a single channel gray--no longer a 3 channel rgb.
Is there any way to prevent this from happening? Some "don't reduce colors" flag?
I'd much prefer a solution that doesn't require me to know that the orignal file was an rgb file to begin with (I'm dealing with lots of files that could be either type). I just want it to maintain the color space that the original image had, with no color reduction.
Thanks for any help anyone has here. This is causing me lots of issues as I assume that my image is still 3 color, only to find I'm suddenly dealing with a grayscale....
-Daniel
Stop reducing my colors!
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Almost everyone here is using IM v6 of one version or another. However version 5.5.7 was such a long and stable release that it probably should be answered.
Generally by default (even in v5, Im tries to select the best output format for the image type selected. This is why it is deciding to use a gray scale tiff for your image rather than RGB.
I am not sure if this would work but you can give it a try.
Try adding a -colorspace TrueColors (check your versions manual for spelling) and see if that helps.
Also look though the format types available and see if their might be some alturnative 'TIFF' formats. EG: convert -list format
I don't see many in v6 (TIFF, PTIF, and EPT* formats) but it may be posible to add such a type.
The final alturnative is to define a special delegate to call some other program to generate a RGB style of TIFF image from any other image format, Perhaps the NetPBM filters can do it, or one of the huge numbers of extra programs that I see was installed with the 'libtiff package under my linux (for example "pal2rgb" )
Generally by default (even in v5, Im tries to select the best output format for the image type selected. This is why it is deciding to use a gray scale tiff for your image rather than RGB.
I am not sure if this would work but you can give it a try.
Try adding a -colorspace TrueColors (check your versions manual for spelling) and see if that helps.
Also look though the format types available and see if their might be some alturnative 'TIFF' formats. EG: convert -list format
I don't see many in v6 (TIFF, PTIF, and EPT* formats) but it may be posible to add such a type.
The final alturnative is to define a special delegate to call some other program to generate a RGB style of TIFF image from any other image format, Perhaps the NetPBM filters can do it, or one of the huge numbers of extra programs that I see was installed with the 'libtiff package under my linux (for example "pal2rgb" )
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Thanks for the reply--I searched based on your TrueColor suggestion--(it looks like it's not "-colorspace TrueColor", though, but "-type TrueColor" that's the option you meant.)
But...it still doesn't offer a "pass through" option. Using -type TrueColor forces the image to a truecolor (3 channel) one, ---even if it started as a single channel grayscale--- So..that still doesn't work for me--I need something that causes convert to do it's job without chaning the original number of colors, whatever it may be. TrueColor turns everything to 3 channels...
The format option probably won't work either--I want to leave the original file unchanged (other then the border) and a file type change is out. Likewise, a delegate is going to be tough, but maybe. I'm on windows and Mac, so it would have to work and compile for both.
I'm kind of amazed that this option doesn't seem to exist, though--it's awfully presumptuous of the program to take it upon itself to alter the format of the image when I'm just asking it to add a border. There really should be a way to prevent that from happening.
But...it still doesn't offer a "pass through" option. Using -type TrueColor forces the image to a truecolor (3 channel) one, ---even if it started as a single channel grayscale--- So..that still doesn't work for me--I need something that causes convert to do it's job without chaning the original number of colors, whatever it may be. TrueColor turns everything to 3 channels...
The format option probably won't work either--I want to leave the original file unchanged (other then the border) and a file type change is out. Likewise, a delegate is going to be tough, but maybe. I'm on windows and Mac, so it would have to work and compile for both.
I'm kind of amazed that this option doesn't seem to exist, though--it's awfully presumptuous of the program to take it upon itself to alter the format of the image when I'm just asking it to add a border. There really should be a way to prevent that from happening.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
It makes that presumption as most commonly when a image is changes it will nolonger be able to use the original format. As such IM always tryes to figure out the best formta to use.
The only suggestion I have is to either identify the image first then give the right settings. OR use a API and check the image in memory after it has been read in.
The only suggestion I have is to either identify the image first then give the right settings. OR use a API and check the image in memory after it has been read in.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/