Bug 832690

Summary: [regression] /usr/bin/convert does not respect size of EPS images
Product: [Fedora] Fedora Reporter: Milan Bouchet-Valat <nalimilan>
Component: ImageMagickAssignee: Pavel Alexeev <pahan>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: ajschult784, nmurray, nsoranzo, pahan, twaugh
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-11-14 14:22:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Description Flags
EPS file to reproduce the problem none

Description Milan Bouchet-Valat 2012-06-16 15:07:40 UTC
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 16:16:18 UTC
$ 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-04 03:14:47 UTC
(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:
[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.


Comment 3 Pavel Alexeev 2012-11-11 16:13:28 UTC
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 14:22:08 UTC
It will be fixed in next versions in upstream.