Page 1 of 1
Convert PGM in P5 format to P2 format
Posted: 2014-04-12T08:38:16-07:00
by maheshravella
Hello,
I'm new to ImageMagick. I have been trying to convert a PGM image in P5 format to P2 format on a windows system. I have installed the ImageMagick-6.8.9. Kindly provide me with step by step process to convert the image.
Thanks in advance!!
Re: Convert PGM in P5 format to P2 format
Posted: 2014-04-12T08:53:36-07:00
by snibgo
These are both grayscale. P5 is binary (ie compressed). P2 is ASCII (ie not compressed). So the following should do the job:
Code: Select all
convert in.pgm -compress None out.pgm
Re: Convert PGM in P5 format to P2 format
Posted: 2014-04-12T17:48:55-07:00
by maheshravella
Thanks snibgo. i have tried that and i'm getting the following error:
convert.exe: unable to open image `1.pgm': No such file or directory @ error/blo
b.c/OpenBlob/2647.
convert.exe: no images defined `out.pgm' @ error/convert.c/ConvertImageCommand/3
161.
Please help.
Re: Convert PGM in P5 format to P2 format
Posted: 2014-04-13T05:05:42-07:00
by snibgo
What is shown when you type "dir 1.pgm"?
Re: Convert PGM in P5 format to P2 format
Posted: 2014-04-13T22:00:23-07:00
by anthony
I do however recommend you use the actual PBMPlus Library command for conversion.
These three are all equivalent and were basically the result of the libraries long history
pnmtopnm -plain
pnmnoraw
pnmtoplainpnm
The reason is while IM gets the Image format correct, it only uses spaces between wach pixel value. The above however adds returned between each row of values, meaning that each row of pixels forms it own line, whcih can help greatly in scripted processing of the image values. This is actually one of the greatest benifits of this image format... scripted processing of values, and IM examples goes into this at various times for various reasons.
See IM examples, common Image Formats, PBMPlus
http://www.imagemagick.org/Usage/formats/#pbmplus
For scripting the alternative is IM Enumerated Pixels format (".txt") but after the header line, this lists one pixel per line, making it a very verbose format by comparison. Still very useful though.
There was suggestions made to allow you to specify the 'level' for the output values, beyond what you can get using -depth, but that has never been implemented. SIDE: PBMplus can use any level up to 65535 (16 bit) for the output values.
PS: I was the one to release the PBMplus patch release in 1996. And yes I have been around that long!