Page 1 of 1

Convert JPG to PCX

Posted: 2019-08-29T20:53:43-07:00
by Frank.Liu
Hi guys,
I want to convert a jpg file to pcx format, I use bellow command line with Magick

Code: Select all

convert D:\mytest\A.jpg  -colors 2 -depth 1  D:\mytest\a.pcx
the file header :
010h:FF FF FF 00 00 00 ........
How I do can make the 010h update to 00 00 00 FF FF FF 00
Thanks .

Re: Convert JPG to PCX

Posted: 2019-08-31T07:30:36-07:00
by Jason S
I'm not sure I understand your question.

But I see that, in some cases, depending on the JPEG, IM (7.0.8) will write a 1-bit PCX file that has [ff ff ff 00 00 00] in the palette area at offset 0x10. And that seems... bad.

To the best of my knowledge, there is no portable way for a 1-bit PCX to be anything other than 0=black, 1=white. If you put anything other than [00 00 00 ff ff ff] or [00 00 00 00 00 00] in the first 6 bytes of the palette area, you're asking for trouble.

Re: Convert JPG to PCX

Posted: 2019-08-31T08:09:52-07:00
by snibgo
Is someone saying IM has a bug? If so, we will move this to the bugs forum.

Please also supply a link to something that says what those bytes should be.

Re: Convert JPG to PCX

Posted: 2019-08-31T11:00:37-07:00
by Jason S
I think it's bug-like enough to move there.

The issue I'm talking about is that some of the 1-bit PCX files created by IM are not as portable as they could be. I believe the cause is the combination of the PaletteType field set to 1, and a white-then-black palette (FF FF FF 00 00 00) at offset 0x10.

Steps to reproduce:

Code: Select all

magick logo: -colors 2 -depth 1 test.pcx
My results: White wizard on black when interpreted by XnView or pcxtoppm. Black wizard on white when interpreted by Irfanview or ImageMagick.

Expected results: Black wizard always.

Re: Convert JPG to PCX

Posted: 2019-09-08T08:12:37-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.