Bug 832690 - [regression] /usr/bin/convert does not respect size of EPS images
[regression] /usr/bin/convert does not respect size of EPS images
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: ImageMagick (Show other bugs)
17
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Pavel Alexeev
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-16 11:07 EDT by Milan Bouchet-Valat
Modified: 2012-11-14 09:22 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-11-14 09:22:08 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
EPS file to reproduce the problem (5.27 KB, application/postscript)
2012-06-16 11:07 EDT, Milan Bouchet-Valat
no flags Details

  None (edit)
Description Milan Bouchet-Valat 2012-06-16 11:07:40 EDT
Created attachment 592322 [details]
EPS file to reproduce the problem

In Fedora 17, calling /usr/bin/convert to make a .png from the attached .eps file generates a an image that does not have the original dimensions of the .eps. This is a regression from Fedora 16, and it hits badly LibreOffice, which uses convert to render EPS images: since the generated .png does not have the correct size, LibreOffice shrunks the result vertically to fit in the original size, and the result is unusable.

I've not been able to determine whether the change from F16 comes from ImageMagick or Ghostscript, but I'm open to suggestions about how to debug this. At least, I can note that ps2pdf does indeed not respect the size of the original EPS image, but I think it was already the case in F16. ps2epsi and pstopnm do respect the size, though. So maybe what changed is that /usr/bin/convert does not use the same parameters when calling Ghostscript?
Comment 1 Pavel Alexeev 2012-06-23 12:16:18 EDT
$ egrep '(de|en)code="eps"' /etc/ImageMagick/delegates.xml
  <delegate decode="eps" encode="pdf" mode="bi" command="&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 &quot;-sDEVICE=pdfwrite&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;"/>
  <delegate decode="eps" encode="ps" mode="bi" command="&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pswrite&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;"/>
  <delegate decode="pdf" encode="eps" mode="bi" command="&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=epswrite&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;"/>
  <delegate decode="ps" encode="eps" mode="bi" command="&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=epswrite&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;"/>

So, in all cases for eps ghostScript used. Reassigning.
Comment 2 Andrew Schultz 2012-11-03 23:14:47 EDT
(In reply to comment #1)
> So, in all cases for eps ghostScript used. Reassigning.

A couple problems...

1. none of the lines you grep'd from delegates.xml is related to eps->png conversion.  The actual relevant line seems to be

  <delegate decode="ps:alpha" stealth="True" command="&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pngalpha&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;"/>

2. ghostscript seems to be behaving fine, although differently than older ghostscript.

ImageMagick needs to pass the flag -dEPSCrop to ghostscript.  This is documented here:
http://ghostscript.com/doc/9.06/Use.htm#EPS_parameters
[the same option existed in older version, but perhaps was on by default?]

There's an option to ImageMagick to get it to pass that flag, but it is off by default.  The option is described in http://www.imagemagick.org/script/formats.php

----
To force ImageMagick to respect the crop box, use -define (e.g. -define ps:use-cropbox=true)
----

But this seems a bit bizarre since postscript does not have anything called a "crop box" and the only effect of ps:use-cropbox=true (from looking at the code) is to pass -dEPSCrop; that just tells ghostscript to crop at the boundingbox (which it used to do by default).  Apparently ImageMagick doesn't distinguish between ps and eps when converting to images and so now needs help to pass appropriate options to ghostscript.

As a bonus, many of the forum posts contain folks asking about related topics and include the output from "-list Delegate" and it often includes -dEPSCrop on most postscript-related conversions.  The reason for this seems to be that VisualMagick (a system for building ImageMagick using Microsoft Visual C++) includes a version of delegates.xml with -dEPSCrop sprinkled all over.  Yay us.

http://trac.imagemagick.org/browser/VisualMagick/trunk/bin/delegates.xml
Comment 3 Pavel Alexeev 2012-11-11 11:13:28 EST
Ohh. Thanks for the details.

Ok, reported upstream: http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=22253
Comment 4 Pavel Alexeev 2012-11-14 09:22:08 EST
It will be fixed in next versions in upstream.

Note You need to log in before you can comment on or make changes to this bug.