Menu

#319 normalize fails after resize of grayscaled icm-profiled picture

v1.0_(example)
closed-invalid
None
5
2015-09-25
2015-09-23
No

I have an imagepipeline like this:

gm convert normalize-bug-example.png -strip -colorspace GRAY -flatten -resize '300x300' -normalize converted.png

With the attached image (from https://36.media.tumblr.com/tumblr_lvcwrlHqwl1qj9ldoo1_500.png) this produces a white image. It I move the "-normalize" in front of the resize, it works as expected.

The image carries a profile that I suspect to be causing the erratic bahaviour.

The reason for using strip, grayscale and flatten and the normalization after the resize is that this is a generic pipeline for all kinds of images from various sources. I found that doing the normalization after the resize gives better results, only it doesn't work at all for this type of image.

1 Attachments

Discussion

  • Bob Friesenhahn

    Bob Friesenhahn - 2015-09-24

    The problem is not the image profile. The problem is that this image is very weird in that it is primarily drawn in the alpha channel rather than the color channels. The -normalize operator only works on color channels and so it severely distorts the apparent results. Use

    gm convert tumblr_lvcwrlHqwl1qj9ldoo1_500.png -channel opacity opacity.png
    

    to produce an image containing only the content of the opacity channel.

    Either of these commands might be used to produce a more ordinary file, but without anything in the alpha channel. The first one requires knowing the size in advance:

    gm convert tumblr_lvcwrlHqwl1qj9ldoo1_500.png -extent 480x500 color.png
    
    gm montage -mode concatenate tumblr_lvcwrlHqwl1qj9ldoo1_500.png color.png
    

    I have not figured out everything going on with the sequence of commands, but I notice that removing -flatten has an effect on what -normalize does after the resize.

     

    Last edit: Bob Friesenhahn 2015-09-24
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-09-24
    • assigned_to: Bob Friesenhahn
     
  • Bernhard Weisshuhn

    Thanks, this was very helpful. Feel free to close.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-09-25
    • status: open --> closed-invalid
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-09-25

    Image is a weird image which is not compatible with normalize.

     

Log in to post a comment.

MongoDB Logo MongoDB