identify/convert give wrong size of eps file

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
mexas@bristol.ac.uk
Posts: 5
Joined: 2012-03-09T02:51:35-07:00
Authentication code: 8675308

identify/convert give wrong size of eps file

Post by mexas@bristol.ac.uk »

I use ImageMagick-6.7.5.7 on FreeBSD 10 -current.

I've a large eps file, converted from a raster image:

% ls -al bile_acid.eps
-rwxr-xr-x 1 mexas wheel 3428323 Mar 22 2011 bile_acid.eps

% identify bile_acid.eps
bile_acid.eps PS 595x842 595x842+0+0 16-bit DirectClass 43.6KB 0.000u 0:00.007
^^^^^^^
The size is wrong:

% head bile_acid.eps
%!PS-Adobe-3.0 EPSF-3.0
%%Creator: GIMP PostScript file plugin V 1.17 by Peter Kirchgessner
%%Title: bile_acid.eps
%%CreationDate: Tue Mar 22 19:44:00 2011
%%DocumentData: Clean7Bit
%%LanguageLevel: 2
%%Pages: 1
%%BoundingBox: 14 14 1599 2379
^^^^^^^^^^^^^^^

The size returned by identify doesn't correspond
to the size given in the eps itself.

When I open the eps file with gv, the whole of
the file is shown and the size is displayed correctly.

When I convert the eps file to something else,
only a 595x842 portion of the original image is converted,
the rest is ignored:

% convert bile_acid.eps bile_acid.jpeg
% identify bile_acid.*
bile_acid.eps PS 595x842 595x842+0+0 16-bit DirectClass 43.6KB 0.000u 0:00.015
bile_acid.jpeg[1] JPEG 595x842 595x842+0+0 8-bit DirectClass 24.5KB 0.000u 0:00.000
%

The source eps: http://seis.bris.ac.uk/~mexas/bile_acid.eps
The resulting jpeg: http://seis.bris.ac.uk/~mexas/bile_acid.jpeg
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: identify/convert give wrong size of eps file

Post by anthony »

Postscript images do not have a size! The Bounding box coordinates are not pixels, they are 'points' which is defined as being 72 points per inch.

You need to set a density or resolution which then determines the final size of the image.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
mexas@bristol.ac.uk
Posts: 5
Joined: 2012-03-09T02:51:35-07:00
Authentication code: 8675308

Re: identify/convert give wrong size of eps file

Post by mexas@bristol.ac.uk »

ok, I didn't phrase my report correctly, apologies.

The fact is that I cannot convert this eps to another
format, e.g. jpg, png fully. Only a fragment at the bottom
left corner is converted. About 3/4 of the image is lost
during conversion.

% identify z*
z.eps PS 595x842 595x842+0+0 16-bit DirectClass 43.6KB 0.000u 0:00.000
z.jpg[1] JPEG 413x585 413x585+0+0 8-bit DirectClass 14.5KB 0.000u 0:00.000

% ls -al z*
-rwxr-xr-x 1 mexas wheel 3428323 Mar 10 19:36 z.eps
-rw-r--r-- 1 mexas wheel 14515 Mar 10 19:42 z.jpg

Note that the file size reported by identify for this eps is
clearly wrong: 43.6KB, whereas the real size is >3MB.

The original eps: http://seis.bris.ac.uk/~mexas/z.eps
Converted to jpg: http://seis.bris.ac.uk/~mexas/z.jpg

Can anybody reproduce this?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify/convert give wrong size of eps file

Post by fmw42 »

identify -verbose z.eps

identify: no decode delegate for this image format `1z.eps' @ error/constitute.c/ReadImage/532.

I would say your eps is corrupt.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: identify/convert give wrong size of eps file

Post by anthony »

More likely it is just missing the EPS commant at the top of the file.

Some programs like to out put a Crtl-D character at the start of Postscript files (for printer reset) So if you image starts with the three characters Ctrl-D % ! remove the Ctrl-D!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
mexas@bristol.ac.uk
Posts: 5
Joined: 2012-03-09T02:51:35-07:00
Authentication code: 8675308

Re: identify/convert give wrong size of eps file

Post by mexas@bristol.ac.uk »

Seems it was a bug.
I updated to Version: ImageMagick 6.7.5-10 2012-03-12 Q16
and the issue has gone away:

% identify z.eps
z.eps PS 1585x2365 1585x2365+0+0 16-bit DirectClass 784KB 0.008u 0:00.007

% identify -verbose z.eps
Image: z.eps
Format: PS (PostScript)
Class: DirectClass
Geometry: 1585x2365+0+0
Resolution: 72x72
Print size: 22.0139x32.8472
Units: Undefined
Type: TrueColorMatte
Endianess: Undefined
Colorspace: sRGB
Depth: 16/8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
Channel statistics:
Red:
min: 0 (0)
max: 65535 (1)
mean: 60852.6 (0.928551)
standard deviation: 12060 (0.184024)
kurtosis: 13.6921
skewness: -3.73598
Green:
min: 0 (0)
max: 65535 (1)
mean: 60811.9 (0.92793)
standard deviation: 12206.4 (0.186258)
kurtosis: 13.7476
skewness: -3.74757
Blue:
min: 0 (0)
max: 65535 (1)
mean: 60672.3 (0.9258)
standard deviation: 12303.7 (0.187743)
kurtosis: 13.431
skewness: -3.69447
Alpha:
min: 65535 (1)
max: 65535 (1)
mean: 65535 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
Image statistics:
Overall:
min: 0 (0)
max: 65535 (1)
mean: 45584.2 (0.69557)
standard deviation: 10557.2 (0.161093)
kurtosis: 96.9406
skewness: -17.8735
Rendering intent: Perceptual
Gamma: 0.45455
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Interlace: None
Background color: white
Border color: srgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Compose: Over
Page geometry: 1585x2365+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2012-03-12T16:33:04+00:00
date:modify: 2012-03-12T16:33:04+00:00
ps:HiResBoundingBox: 1585x2365+14+14
ps:Level: Adobe-3.0 EPSF-3.0

signature: cfde116243dbffe52ffebc59b974ccd53252000b398307f724a6023282d72b03
Profiles:
Profile-icc: 2576 bytes
Description: Artifex Software sRGB ICC Profile
Manufacturer: Artifex Software sRGB ICC Profile
Model: Artifex Software sRGB ICC Profile
Copyright: Copyright Artifex Software 2011
Artifacts:
filename: z.eps
verbose: true
Tainted: False
Filesize: 784KB
Number pixels: 3.749M
Pixels per second: 6.397MB
User time: 0.555u
Elapsed time: 0:01.585
Version: ImageMagick 6.7.5-10 2012-03-12 Q16 http://www.imagemagick.org
%

and I don't see Ctrl-D in the header:

% head -n 30 z.eps

%!PS-Adobe-3.0 EPSF-3.0
%%Creator: GIMP PostScript file plugin V 1.17 by Peter Kirchgessner
%%Title: bile_acid.eps
%%CreationDate: Tue Mar 22 19:44:00 2011
%%DocumentData: Clean7Bit
%%LanguageLevel: 2
%%Pages: 1
%%BoundingBox: 14 14 1599 2379
%%EndComments
%%BeginProlog
% Use own dictionary to avoid conflicts
10 dict begin
%%EndProlog
%%Page: 1 1
% Translate for offset
14.173228346456694 14.173228346456694 translate
% Translate to begin of first scanline
0 2364.730613263971 translate
1584.7370078740157 -2364.730613263971 scale
% Image geometry
2113 3153 8
% Transformation matrix
[ 2113 0 0 3153 0 0 ]
% Strings to hold RGB-samples per scanline
/rstr 2113 string def
/gstr 2113 string def
/bstr 2113 string def
{currentfile /ASCII85Decode filter /RunLengthDecode filter rstr readstring pop}
{currentfile /ASCII85Decode filter /RunLengthDecode filter gstr readstring pop}
{currentfile /ASCII85Decode filter /RunLengthDecode filter bstr readstring pop}

and convert now works as expected:

% convert z.eps z.jpg
% identify z*
z.eps PS 1585x2365 1585x2365+0+0 16-bit DirectClass 784KB 0.000u 0:00.007
z.jpg[1] JPEG 1585x2365 1585x2365+0+0 8-bit DirectClass 371KB 0.008u 0:00.000
Post Reply