Discussion:
We cannot resize pgm file.
林 智子
2011-03-18 08:34:13 UTC
Permalink
Dir Sir,

We are using ImageMagick-6.5.9-10.
When we convert with -resize option, we find the following problems:

1) % convert -resize 48x14 f1.pgm f2.pgm
% display f2.pgm

When display command displays the converted image, f2.pgm, the
image cannot be displayed well.

2) % convert -resize 48x14 -compress none f1.pgm feep3.pgm
% display f3.pgm

When display command displays the converted image, f3.pgm,
the image is blurred.


f1.pgm is as follows:

% cat f1.pgm
P2
24 7
63
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 12 0 0 0 0 0 29 29 29 29 0 0 46 46 46 46 0 0 63 0 0 0 0
0 12 0 0 0 0 0 29 0 0 0 0 0 46 0 0 0 0 0 63 0 0 0 0
0 12 12 12 0 0 0 29 29 29 0 0 0 46 46 46 0 0 0 63 63 63 63 0
0 12 0 0 0 0 0 29 0 0 0 0 0 46 0 0 0 0 0 63 0 0 63 0
0 12 12 12 12 0 0 29 29 29 29 0 0 46 46 46 46 0 0 63 63 63 63 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
%

We want to know how to fix these problems.

Best Regards,
----
Tomoko Hayashi
E-Mail: ***@u-aizu.ac.jp
Anton Shterenlikht
2011-03-18 10:44:40 UTC
Permalink
Post by 林 智子
Dir Sir,
We are using ImageMagick-6.5.9-10.
1) % convert -resize 48x14 f1.pgm f2.pgm
% display f2.pgm
When display command displays the converted image, f2.pgm, the
image cannot be displayed well.
2) % convert -resize 48x14 -compress none f1.pgm feep3.pgm
% display f3.pgm
When display command displays the converted image, f3.pgm,
the image is blurred.
% cat f1.pgm
P2
24 7
63
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 12 0 0 0 0 0 29 29 29 29 0 0 46 46 46 46 0 0 63 0 0 0 0
0 12 0 0 0 0 0 29 0 0 0 0 0 46 0 0 0 0 0 63 0 0 0 0
0 12 12 12 0 0 0 29 29 29 0 0 0 46 46 46 0 0 0 63 63 63 63 0
0 12 0 0 0 0 0 29 0 0 0 0 0 46 0 0 0 0 0 63 0 0 63 0
0 12 12 12 12 0 0 29 29 29 29 0 0 46 46 46 46 0 0 63 63 63 63 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
%
We want to know how to fix these problems.
Best Regards,
----
Tomoko Hayashi
Interesting..

I use here ImageMagick-6.6.7.10 on FreeBSD ia64.

Following from the man page
http://netpbm.sourceforge.net/doc/pgm.html

I created this "plain" PGM:

TZAV> cat feep.pgm
P2
# feep.pgm
24 7
15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0
0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0
0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TZAV>

Note the magic number "P2", indicating "plain" PGM
as opposed to "raw". Refer to the above man page
for more info.

I get identical results with either

TZAV> display -resize 2400x700 feep-p5.pgm

or

TZAV> convert -resize 2400x700 -compress none feep.pgm feep-large.pgm

I wouldn't call this blurring, but interpolation,
just as expected.

However, using

TZAV> convert -resize 2400x700 feep.pgm feep-large-compress.pgm

produces "raw" PGM, with magic number "P5".

Displaying this file gives much coarser interpolation,
because only 4 bit representation is used:

TZAV> identify feep*
feep-large-compress.pgm PGM 2400x700 2400x700+0+0 4-bit Grayscale DirectClass 1.68MB 0.070u 0:00.070
feep-large.pgm[1] PGM 2400x700 2400x700+0+0 8-bit Grayscale DirectClass 4.661MB 0.359u 0:00.359
feep.pgm[2] PGM 24x7 24x7+0+0 4-bit Grayscale DirectClass 519B 0.000u 0:00.000
TZAV>

My files:

http://seis.bris.ac.uk/~mexas/feep.pgm
http://seis.bris.ac.uk/~mexas/feep-large.pgm
http://seis.bris.ac.uk/~mexas/feep-large-compress.pgm
--
Anton Shterenlikht
Room 2.6, Queen's Building
Mech Eng Dept
Bristol University
University Walk, Bristol BS8 1TR, UK
Tel: +44 (0)117 331 5944
Fax: +44 (0)117 929 4423
Loading...