Scale large EPS art without sharp result and with clipping path

I have an EPS file (3854x8000) and I want to scale it because that is the way to go big, but without losing the clipping path. (If possible - I tried to zoom out using ImageMagick:

convert picture.eps -resize 768x1024 picture_small.eps

      

The result is cool. Until now, I have not tried to save the clipping path because I do not know how to do it.

Until now, if you haven't found a solution for this problem.

Can ImageMagick actually do this?

Clarification:

(edit by Alex - as I am a mht collage working on the same question)

EPS files - as well as JPGs can contain clipping path (German: Freistellungspfad). This is a vector path, usually around a bitmap, that indicates which portion of the background should be clipped. Using ImageMagick, the clipping path is shown in the output identify -verbose

like this:

   Clipping path: 
<?xml version="1.0" encoding="iso-8859-1"?>
<svg width="240" height="240">
<g>
<path style="fill:#00000000;stroke:#00000000;stroke-width:0;stroke-antialiasing:false" d="
M 53,133
L 126,63
L 151,163
"/>
</g>
</svg>

      

Load test image

Tried so far:

/opt/ghostscript-9.15-linux-x86_64/gs-915-linux_x86_64
  -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT 
  -dMaxBitmap=500000000  
  -r144 -sDEVICE=eps2write 
  -sOUTPUTFILE=out.eps 
  dreieck_rgb_pfad2_photoshop.eps

      

and

convert dreieck_rgb_pfad2_photoshop.eps -clip eps3:out.eps

      

+3


source to share


2 answers


You didn't say why your EPS is too big. Is it just dimensions or file size?




To decide on the best method for scaling an EPS file, you need to know what the exact nature of the PostScript it contains is.

EPS can contain two different types of graphics displayed on a page:

  • Vector-based elements (including fonts for displaying text)
  • Raster based elements (aka pixel images)

Some EPSs are based solely on one of these two types of content, some contain a mix between the two.

If you are certain that your EPS is purely raster data, the ImageMagick transformation does no harm.

But keep in mind: ImageMagick cannot handle EPS (and PostScript or PDF) on its own. It calls an external "delegate" to handle these input types. This delegate is Ghostscript.

Ghostscript then converts the EPS (or PS or PDF) input to a large bitmap, spanning the entire page (or multiple images for multiple pages if the input was PostScript or PDF with more than one page).

After that: your vector data and fonts are gone!

ImageMagick then takes the bitmaps generated by Ghostscript and applies its own processing to it: sampling, coloring, etc. - whatever you requested via ImageMagick command line.

If you want to reuse EPS as an output, ImageMagick cannot re-create vector shapes. Everything inside the EPS will now be pixelated, including fonts. EPS will just be a little thin PostScript wrapper around a full-page bitmap.

With ImageMagick, you may find yourself in the worst case scenario with

  • a file that is much larger than the pure vector file size,
  • which degraded in quality and lost all vectors and fonts at the same time due to pixelation.

Hence, it can offer several advantages for running Ghostscript on its own without relying on ImageMagick:

  • You have more command line options to fine tune the output. (ImageMagick at this point only knows about requesting permission to pass Ghostscript using -density NNN

    .)

  • You can choose a different output format depending on your final purpose for EPS output that you want to create from the original EPS. Maybe it should be in Word document or LaTeX or Libre / OpenOffice for illustration purposes? Just want to print it? Want to convert it to PNG or JPEG?

    • You can even ask for EPS again (by running it with the option -sDEVICE=eps2write

      with the latest releases). It can save (most) vector elements, including fonts, from the source file to the output EPS.
    • You can request the output in PDF format (works with -sDEVICE=pdfwrite

      ). This also preserves vectors and fonts. And it can be used to directly embed in LaTeX documents (no need to convert to image first).

So, it all depends on the ultimate goal of your transformation, how to do it in the most appropriate way. I could give you more specific Ghostscript command line guidelines if I know your purpose.




Update:

After quickly adding a sample EPS (see the OP's Explained section), I can point out the following:

  • The so called EPS file was created using Adobe Photoshop
  • It consists of various pieces:
    • Unidentified piece of garbage bytes at the beginning ( 64400 Bytes

      )
    • A real EPS file, starting at byte offset 64400, consists of:
      • 13-line PostScript header
      • 156 lines containing smaller inline preview image ( 4874 Bytes

        )
      • 100 lines containing ICC hex profile ( 6749 Bytes

        )
      • OK. 300 lines of XML metadata from Photoshop ( 18746 Bytes

        )
      • OK. 7200 lines of raster data image, most likely TIFF ( 475213 Bytes

        )

It looks like all of the OP poster's (as well as the question catcher's) attempts to convert this not quite standard EPS file to a different image format (or to a "smaller" EPS) failed because the corresponding process used an embedded 240x240 pixel preview image instead of an embedded main TIFF ...

In any case, it seems that the creators of this so-called EPS file should order the Photoshop and Image Formats tutorial or similar.

Because if you create an EPS file with a simple black triangle composed of vector paths (which can be described and saved in less than 20 lines of code containing less than 200 bytes!), Then save it as a 500+ kB

TIFF to re-insert that into EPS you are doing it wrong ...




Update 2:

I asked a friend who has access to an Adobe Photoshop CC installation to open the file, enlarge the triangle image, screen what he sees, and send me a snapshot. He did. The zoom level was 500%.

Here he is:

Screenshot at 500%

As you can see, even the original Photoshop source file is "cool". And by no means is it 3854x8000 pixels like the OP's first states proposal.

If the EPS does not contain a vector representation of the triangle illustration, there is no way to avoid this "sharp" result when scaling it ...




Update 3:

Just to prove my point that you can have a vector EPS file of several tens of lines and several hundred bytes, here it is:

%!PS-Adobe-3.0 EPSF-3.0
%%Creator: Kurt Pfeifle (manually)
%%CreationDate: Wed Mar 25, 2015 (16:30 h)
%%Pages: 1
%%DocumentData: Clean7Bit
%%LanguageLevel: 2
% %%BoundingBox: 42 61 121 142
%%BoundingBox: 0  0  240 240
%%EndComments
%%BeginProlog
%%EndProlog
%%BeginSetup
%%EndSetup
%%Page: 1 1
%%BeginPageSetup
%%EndPageSetup
gsave
    42 61 79 81 rectclip
    gsave
        0             setgray
         42.4  85.6   moveto
        100.8 141.6   lineto
        120.8  61.6   lineto
        closepath
         42.4  85.6   moveto
        eofill
    grestore
grestore
showpage
%EOF 

      

(You can easily write / output two alternative settings lines %%BoundingBox:

...)

+2


source


Try to set the density before reading the file as follows:



convert -density 300 picture.eps -resize 768x1024 picture_small.eps

      

+1


source







All Articles