Convert to Monochrome PCX doesn't work

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
mfernandez
Posts: 4
Joined: 2012-12-04T08:39:34-07:00
Authentication code: 6789
Location: Buenos Aires, Argentina

Convert to Monochrome PCX doesn't work

Post by mfernandez »

Hello,

I've been using imagemagick a lot of time ago, from little scripts to complex tasks, and I'm very happy with it.

However, this conversion doesn't work when using Imagemagick 6.7.7-10 (Ubuntu 12.10), because it generates 24-bit PCX images instead of monochrome ones:

Code: Select all

$ convert -type Bilevel image.jpg image.pcx
$ file image.pcx
image.pcx: PCX ver. 3.0 image data bounding box [0, 0] - [464, 219], 3 planes each of 8-bit colour, 72 x 72 dpi, RLE compressed
This command worked in Ubuntu 12.04 (Imagemagick 6.6.9-7) just fine:

Code: Select all

$ file image_1204.pcx
logo.pcx: PCX ver. 3.0 image data bounding box [0, 0] - [464, 219], 1-bit colour, 72 x 72 dpi, RLE compressed
I've tried with the last version of convert (Imagemagick 6.8.0-7 compiled by myself) and I'm still getting the same issue. I've also tried with "-monochrome", putting parameters before the input file and before the output PCX, but no luck.

Is this a bug? Should I report it?

Regards
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert to Monochrome PCX doesn't work

Post by fmw42 »

convert -type Bilevel image.jpg image.pcx
I do not know much about PCX, but try the more correct IM6 syntax with the input image before the options

convert image.jpg -type Bilevel image.pcx

convert image.jpg -monochrome image.pcx


This works fine for me on IM 6.8.0.7 Q16 Mac OSX Snow Leopard


convert logo: -monochrome 1tmp1.pcx
identify -verbose 1tmp1.pcx
Image: 1tmp1.pcx
Format: PCX (ZSoft IBM PC Paintbrush)
Class: DirectClass
Geometry: 640x480+0+0
Units: PixelsPerInch
Type: Palette
Endianess: Undefined
Colorspace: sRGB
Depth: 8/1-bit
Channel depth:
red: 1-bit
green: 1-bit
blue: 1-bit
mfernandez
Posts: 4
Joined: 2012-12-04T08:39:34-07:00
Authentication code: 6789
Location: Buenos Aires, Argentina

Re: Convert to Monochrome PCX doesn't work

Post by mfernandez »

Hello!

As I've said before, I've tried both:

Code: Select all

convert -monochrome image.jpg image.pcx
and

Code: Select all

convert image.jpg -monochrome image.pcx
and still doesn't work (-type Bilevel doesn't work either).

Any ideas? Could it be a configure parameter or a system library lacking? I'm using Ubuntu 12.10 x86-64.

Thank you
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert to Monochrome PCX doesn't work

Post by fmw42 »

Do you get any error messages?

I tried with IM 6.7.7.10 and it works fine for me on my Mac OSX Snow Leopard.

How do you know it is not working? When I display it, it is binary. The -type is palette, however, in both the current and older version of IM. Perhaps PCX does not support a true bilevel type? However, the verbose info shows 1bit for depth:

Depth: 8/1-bit
Channel depth:
red: 1-bit
green: 1-bit
blue: 1-bit
mfernandez
Posts: 4
Joined: 2012-12-04T08:39:34-07:00
Authentication code: 6789
Location: Buenos Aires, Argentina

Re: Convert to Monochrome PCX doesn't work

Post by mfernandez »

fmw42 wrote:Do you get any error messages?
Nope, the command runs fine but the output PCX file under 6.7.x and 6.8.x is different from 6.6 version.
fmw42 wrote:I tried with IM 6.7.7.10 and it works fine for me on my Mac OSX Snow Leopard.
It seems to work fine, but (I think) the output PCX image is a 24-bit one (dithered and maybe processed like B/W, tough) instead of a 2-bit B/W image.
fmw42 wrote:How do you know it is not working?
This is a "identify -verbose" command output for the PCX file generated with 6.7-6.8 convert (see it has RGB channels and its 20.5 KB in size)):
http://pastebin.com/CyrnFM5v

Now, this is the same input file but converted with Imagemagick 6.6 (it weights only 4.1KB):
http://pastebin.com/z4z1zJqu

Maybe I'm missing something here...

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert to Monochrome PCX doesn't work

Post by fmw42 »

OK, then you have found a difference. This should be reviewed, esp. the verbose info file you have linked, by the IM developers.
mfernandez
Posts: 4
Joined: 2012-12-04T08:39:34-07:00
Authentication code: 6789
Location: Buenos Aires, Argentina

Re: Convert to Monochrome PCX doesn't work

Post by mfernandez »

fmw42 wrote:OK, then you have found a difference. This should be reviewed, esp. the verbose info file you have linked, by the IM developers.
Uhmm... ok, should I file a bug report somewhere?

Thank you
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert to Monochrome PCX doesn't work

Post by fmw42 »

mfernandez wrote:
fmw42 wrote:OK, then you have found a difference. This should be reviewed, esp. the verbose info file you have linked, by the IM developers.
Uhmm... ok, should I file a bug report somewhere?

Thank you
This is the place already. I have just forwarded a message to the IM developers to take a closer look at this. So lets wait until we hear back.
ezequielchan
Posts: 1
Joined: 2015-01-10T05:46:09-07:00
Authentication code: 6789

Re: Convert to Monochrome PCX doesn't work

Post by ezequielchan »

I found this workaround for this bug...

Code: Select all

ezequiel@h5:/tmp/test$ convert example.jpg -type Bilevel -colors 2 good.pcx

Code: Select all

ezequiel@h5:/tmp/test$ convert example.jpg -type Bilevel bad.pcx

Code: Select all

ezequiel@h5:/tmp/test$ file *.pcx
bad.pcx:  PCX ver. 3.0 image data bounding box [0, 0] - [464, 239], 3 planes each of 8-bit colour, 72 x 72 dpi, RLE compressed
good.pcx: PCX ver. 3.0 image data bounding box [0, 0] - [464, 239], 1-bit colour, 72 x 72 dpi, RLE compressed
And this is the difference between both images.

Code: Select all

ezequiel@h5:/tmp/test$ identify -verbose good.pcx > good.txt

Code: Select all

ezequiel@h5:/tmp/test$ identify -verbose bad.pcx > bad.txt

Code: Select all

diff good.txt bad.txt > identify.diff

Code: Select all

ezequiel@h5:/tmp/test$ cat identify.diff 
1c1
< Image: good.pcx
---
> Image: bad.pcx
3c3
<   Class: PseudoClass
---
>   Class: DirectClass
50,52d49
<   Colormap: 2
<          0: (  0,  0,  0) #000000 black
<          1: (255,255,255) #FFFFFF white
79c76
<   Filesize: 7.04KB
---
>   Filesize: 29.9KB
81,83c78,80
<   Pixels per second: 11.16MB
<   User time: 0.010u
<   Elapsed time: 0:01.010
---
>   Pixels per second: 0B
>   User time: 0.000u
>   Elapsed time: 0:01.000
Post Reply