Convert 2-bit to png after deskew has odd results

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive, there is no zero.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

If you wish to attach one or more files enter the details below.

Expand view Topic review: Convert 2-bit to png after deskew has odd results

Convert 2-bit to png after deskew has odd results

Post by 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?

Top

cron