Problem with unwanted gamma change

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
realh
Posts: 2
Joined: 2012-07-11T08:51:22-07:00
Authentication code: 13

Problem with unwanted gamma change

Post by realh »

I'm trying to generate a set of PNGs from some SVGs I've made. Each PNG is made up of 4 of the SVGs in a 2x2 square. The problem is that the generated PNGs are coming out with two different levels of brightness (some of them are darker than they should be, the rest seem to look the same shade as the SVGs) even though the SVGs all use the same range of greyscales. Within each PNG the darkening is uniform. The ones which it chooses to make darker seem to be the same ones each time I run my script, but I can't spot a pattern.

For example if I run:

Code: Select all

montage -tile 2x2 -background '#0000' chrome_tl.svg chrome_horiz.svg chrome_vert.svg chrome_tl.svg -geometry 36x36+0+0 tl.png
and

Code: Select all

montage -tile 2x2 -background '#0000' chrome_br.svg chrome_bl.svg chrome_tr.svg chrome_tl.svg -geometry 36x36+0+0 mid.png
and compare tl.png and mid.png, tl.png is clearly darker than it should be, even though both include chrome_tl.svg and all the SVGs have the same greyscale. The SVGs can be downloaded from http://bombz.googlecode.com/git/svgs/chrome_tl.svg, http://bombz.googlecode.com/git/svgs/chrome_tr.svg, http://bombz.googlecode.com/git/svgs/chrome_bl.svg, http://bombz.googlecode.com/git/svgs/chrome_br.svg, http://bombz.googlecode.com/git/svgs/chrome_horiz.svg and http://bombz.googlecode.com/git/svgs/chrome_vert.svg.

It seems to be making the same ones darker I also tried using convert to make direct PNG versions of the SVGs before pasting sets of 4 PNGs together, but that made things worse, I ended up with 3 levels of brightness, the new one being the darkest.
MindTailor
Posts: 2
Joined: 2012-07-31T01:23:22-07:00
Authentication code: 15

Re: Problem with unwanted gamma change

Post by MindTailor »

Hi,

I have the same problem when I try to convert grayscale svg to png. I can add that the problem does not occur if I export my svg to jpg...

Cheers,
MindTailor
Posts: 2
Joined: 2012-07-31T01:23:22-07:00
Authentication code: 15

Re: Problem with unwanted gamma change

Post by MindTailor »

I found a solution for my problem by forcing the use of rgb in the output image using the option :

Code: Select all

-define png:color-type='2'
By defaut, IM will try to use the smallest set of colors possible, causing the problem...
realh
Posts: 2
Joined: 2012-07-11T08:51:22-07:00
Authentication code: 13

Re: Problem with unwanted gamma change

Post by realh »

Thanks for the tips. My solution was to give up on IM and use python-cairo because I was already using python to script the build anyway.
Post Reply