Color space changes after convert ?

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
bakman
Posts: 5
Joined: 2012-07-24T01:04:29-07:00
Authentication code: 15

Color space changes after convert ?

Post by bakman »

I noticed a subtle difference in my photos after they are converted (they are black and white - in sRGB).
It appears that the color space has changed to "gray", how can I keep it exactly the same during/after conversion ?

Image

I am only performing a "convert -resize".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Color space changes after convert ?

Post by fmw42 »

What version of IM? What is the image format (PNG, JPG, ...?)

Your input image is black and white only. It is labeled as RGB which IM now interprets as linear. Since it is not color, IM processes it and converts it to linear gray. This has been recent changes to IM to conform more properly to standards.

In order to get the output to be RGB again, try

convert image -resize ... -set colorspace RGB output
bakman
Posts: 5
Joined: 2012-07-24T01:04:29-07:00
Authentication code: 15

Re: Color space changes after convert ?

Post by bakman »

Thanks.

I am using ImageMagick 6.7.8-6.
Input/output is jpg.

I have tried to add the -set colorspace RGB, but same result in the output image: colour space - gray.

When opening the output image in photoshop I also receive this error:
The embedded ICC profile cannot be used because the ICC profile is invalid. Ignoring the profile.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Color space changes after convert ?

Post by fmw42 »

Can you post a link to one of your images? I can try to test it.
bakman
Posts: 5
Joined: 2012-07-24T01:04:29-07:00
Authentication code: 15

Re: Color space changes after convert ?

Post by bakman »

Original (resized in PS).
Output

Used the following:

Code: Select all

convert -resize x600 sample.jpg -set colorspace RGB sample_output.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Color space changes after convert ?

Post by fmw42 »

It works fine for me under IM 6.7.8.6 Q16 Mac OSX Snow Leopard


Image: sample.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 600x900+0+0
Resolution: 300x300
Print size: 2x3
Units: PixelsPerInch
Type: Palette
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit


convert sample.jpg -resize x600 sample_test1.jpg

Image: sample_test1.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 400x600+0+0
Resolution: 300x300
Print size: 1.33333x2
Units: PixelsPerInch
Type: Palette
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit


Note proper IM 6 syntax should have the input image right after convert, though it may not make a difference until IM 7

see
http://www.imagemagick.org/Usage/basics/#why
bakman
Posts: 5
Joined: 2012-07-24T01:04:29-07:00
Authentication code: 15

Re: Color space changes after convert ?

Post by bakman »

I see the same when using identify.
When you do a cmd+i on the sample image (or use preview with the inspector) - it states:

sample.jpg: colour space: "RGB" with colorprofile: sRGB
sample_output: colour space: "gray" with colorprofile: sRGB

Try opening in photoshop and you will receive an ICC error on the sample_output.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Color space changes after convert ?

Post by fmw42 »

That is not what I get from

convert sample.jpg -resize x600 sample_test1.jpg

From Mac info, the input and output shows identical information including colorspace RGB, and profile sRGB IEC61966-2.1.

I get no errors from opening the output in PS CS.

I am on Mac OSX Snow Leopard using IM 6.7.8.6 Q16

Have you tried using my command. Your syntax with -resize before the input is not proper IM 6 syntax and may or may not be the issue.

How did you install IM? I installed manually from source. If you installed a binary, perhaps it was not compiled correctly.

What version of libjpeg are you using? Mine is 80
bakman
Posts: 5
Joined: 2012-07-24T01:04:29-07:00
Authentication code: 15

Re: Color space changes after convert ?

Post by bakman »

i'll be damned, the syntax difference indeed does the trick, thanks.

How do you install from the source on OSX ?
I used this "installer"-script (I manually updated some versions here and there).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Color space changes after convert ?

Post by fmw42 »

How do you install from the source on OSX ?
I first install all my delegate libraries via MacPorts. Then rather than waiting for macports to create a version of IM, I install IM from source code available at http://www.imagemagick.org/download/. I modify the normal install instructions for the ./configure command from http://www.imagemagick.org/download/www ... .html#unix and customize it using certain options from http://www.imagemagick.org/script/advan ... #configure. See also http://www.imagemagick.org/script/advan ... php#macosx

so I do

./configure ....
make
sudo make install

My ./configure command is:

./configure CPPFLAGS='-I/opt/local/include' LDFLAGS='-L/opt/local/lib' \
--enable-delegate-build --enable-shared --disable-static \
--with-modules --with-quantum-depth=16 --with-gslib --without-wmf \
--disable-silent-rules --disable-dependency-tracking \
--with-gs-font-dir=/opt/local/share/ghostscript/fonts/

The first two options in blue are the ones that link IM installed at /user/local/bin to my delegates installed by MacPorts at /opt/local/bin
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Color space changes after convert ?

Post by fmw42 »

Recently, I tried to install IM on a MacPro OSX El Capitan. The install worked fine as above, except that OpenMP was not enabled.

Apparently, last May (2015), Apple changed their compilers on their OSX releases.

After several days of struggling and help from Magick, we were able to make the install work to enable OpenMP. The compilers that are needed are at:

/opt/local/bin/gcc-mp-5
/opt/local/bin/g++-mp-5

I am not sure how they got there, but my guess is that they came with the OSX, but I am not sure why they were in /opt and not /usr. I tried several others from MacPorts (apple-gcc42 and llvm-gcc42) with no success.

So this the following is what I used for my ./configure command that worked:

Code: Select all

./configure CC='/opt/local/bin/gcc-mp-5' CXX='/opt/local/bin/g++-mp-5'  \
 CPPFLAGS='-I/opt/local/include' LDFLAGS='-L/opt/local/lib' \
  --enable-delegate-build --enable-shared --disable-static \
  --with-modules --with-quantum-depth=16 --enable-hdri --with-gslib \
  --disable-silent-rules --disable-dependency-tracking --with-rsvg \
  --with-gs-font-dir=/opt/local/share/ghostscript/fonts/
Hope this is helpful to anyone else trying to install from source.
Post Reply