What causes images to be rendered dark?

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
hexmode
Posts: 13
Joined: 2012-03-30T13:01:12-07:00
Authentication code: 8675308

What causes images to be rendered dark?

Post by hexmode »

From this bug report:

This image looks ok: Image

But if you take the 263px version (size for inside a dutch infobox, the image
seems to be rendered completely wrong (darker):

Image

Did something go wrong with image scaling?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: What causes images to be rendered dark?

Post by fmw42 »

The image is cmyk. IM probably does not resize well unless you convert the image first to rgb (preferably with profiles)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: What causes images to be rendered dark?

Post by anthony »

More than likely the image is CMYK as Fred said.

But that does not explain the horizontal lines in the image.

I have only seen such lines when VERY low level type composition is used to recreate CMYK images using composition.
See http://www.imagemagick.org/Usage/bugs/testing/

This low level technique failed as CopyBlack composition does not understand grayscale images, only CMYK images, resulting in part of memory being copied instead! Though using the correct higher level operator -combine to do this does work properly.


More information on exact you are operating on the images is needed.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
hexmode
Posts: 13
Joined: 2012-03-30T13:01:12-07:00
Authentication code: 8675308

Re: What causes images to be rendered dark?

Post by hexmode »

fmw42 wrote:The image is cmyk. IM probably does not resize well unless you convert the image first to rgb (preferably with profiles)
In the original bug report Tim suggests adding "-colorspace rgb". Would that help? Would it hurt images that are not cmyk?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: What causes images to be rendered dark?

Post by fmw42 »

hexmode wrote:
fmw42 wrote:The image is cmyk. IM probably does not resize well unless you convert the image first to rgb (preferably with profiles)
In the original bug report Tim suggests adding "-colorspace rgb". Would that help? Would it hurt images that are not cmyk?
If you are on a version of IM after 6.7.5.5 (possibly as late as 6.7.6.7) you need to use -colorspace sRGB, as after that sRGB and RGB were switched in -colorspace. However, the conversion to rgb would be best done using profiles, that is more accurate color conversion. Adding -colorspace sRGB/RGB should not matter if our image is already sRGB.

convert cykmimage.jpg -colorspace sRGB -resize ... rgbimage.jpg

or use profiles,

see
http://www.imagemagick.org/Usage/formats/#profiles
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: What causes images to be rendered dark?

Post by anthony »

With regards to CMYK. CMYK is ment to be a linear colorspace. As a result of the sRGB RGB this change CMYK will be correctly converted to linear colorspace when previously is was probably coming out with inverted sRGB values.

You can similulate what IM did previously with CMYK using (post change IM)

Code: Select all

   convert image -set colorspace RGB -colorspace CMYK .....
If your CMYK was produced with an old version of IM you can fix it to be correctly linear by using...

Code: Select all

  convert old_cmyk_image    -colorspace RGB -set colorspace sRGB -colorspace CMYK    new_cmyk_image
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply