Convert 2-bit to png after deskew has odd results

A place where ImageMagick may be discussed.

Convert 2-bit to png after deskew has odd results

Postby muccigrosso » Sat Mar 14, 2020 2:24 am

I've got an image in pgm format which identify says is "1-bit Bilevel Gray". If I convert it directly to png, it's fine. identify reports the png as "8-bit Gray 2c". Looks the same, of course.

Now, if I "-deskew 40%" that image, the png is still "8-bit Gray 2c", but clearly a bunch of the pixels have turned white from black. This does not happen if I just do a deskew and then show: the result. Nor does it happen if I convert to jpg or force the image depth with "-depth 8". If I deskew and save back to pgm, I have to set "-compress none" or I get a black image. In that case identify reports "8-bit Grayscale Gray".

I assume what's happening is that the deskew creates some gray pixels, so if I have an output format with enough depth those will show up. Is that right?

Here's what I definitely don't understand:

  • The output png is 8-bit, but the pixels get forced to 2 colors. Why? Is IM trying to maintain the original depth from the pgm?
  • Why does the deskewed pgm look OK with show: then? Does that forceIM to use as many colors as needed?
muccigrosso
 

Return to Questions concerning ImageMagick

Who is online

Users browsing this forum: No registered users and 1 guest

cron