Center image of SVG or EPS inside its bounding box?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
nycionx
Posts: 14
Joined: 2015-11-21T19:20:50-07:00
Authentication code: 1151

Center image of SVG or EPS inside its bounding box?

Post by nycionx »

Is it possible with imagemagick (ie. the convert command line tool) to center an image of an svg inside its bounding box? or crop the image to the bounding box somehow? if not then is there ANY tool out there (command line im looking for only) that can do this? ie. ghostscript, inkscape, etc.

here is an example of my problem(s): svg viewed in adobe illustrator

btw i also have the original eps of the file which i converted using ghostscript to svg but the eps is ALSO outside the bounding box...

Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Center image of SVG or EPS inside its bounding box?

Post by fmw42 »

Please provide your source file and your IM version and platform. Please read viewtopic.php?f=1&t=9620
nycionx
Posts: 14
Joined: 2015-11-21T19:20:50-07:00
Authentication code: 1151

Re: Center image of SVG or EPS inside its bounding box?

Post by nycionx »

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

Re: Center image of SVG or EPS inside its bounding box?

Post by fmw42 »

These work for me on IM 6.9.2.9 Q16 Mac OSX.

Code: Select all

convert J.eps -trim +repage J2.eps
convert J.eps -trim +repage J2.svg
nycionx
Posts: 14
Joined: 2015-11-21T19:20:50-07:00
Authentication code: 1151

Re: Center image of SVG or EPS inside its bounding box?

Post by nycionx »

Ok thx I'll try this out and report back, sorry for late reply busy with so many things (holiday season :D
nycionx
Posts: 14
Joined: 2015-11-21T19:20:50-07:00
Authentication code: 1151

Re: Center image of SVG or EPS inside its bounding box?

Post by nycionx »

neither worked for me, got awful results. and converting eps to svg created a 60MB svg file wtf lol?\
the first command created ugly jagged edges like it was rasterized.
plus it didnt do wut i asked for. the bounding box remained the same size (really small).
id like to see ur results, i dont know how it could possibly work for u those commands...

found this btw but havent tried it yet:
http://superuser.com/questions/198460/c ... svg-format

states:

Uniconverter is currently the most convenient option.

It's a command-line tool that shares code with the sK1 Project. You won't have to bother cropping the image in sK1 if you use uniconverter, so it's more automated.

Run it like this:

uniconverter before.eps after.svg
And that's it. I tried it on one EPS, but the SVG was offset improperly, but it may work for you.

Here's a list of alternatives and reasons why they suck:

The sK1 Project

It has the sense of a "page" that you put your drawing on, so after you import an EPS, you have to move it around and manually crop the page.

ImageMagick

For EPS to SVG conversion, ImageMagick does some really stupid bitmap conversion and will render SVG files that are 50mb, when they should be a few kb. It doesn't actually have a real vector conversion algorithm for these formats.


InkScape

Every time I've converted an EPS with InkScape, it's messed up the colours. This is due to an Inkscape bug with importing EPS files. (Update: Fix Released for this bug on February 2015)

Gimp

Gimp just does the same stupid bitmap conversion that ImageMagick does.

Scribus

It gets the colours of my EPS file even more wrong than Inkscape, while Preview for Mac can read it just fine.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Center image of SVG or EPS inside its bounding box?

Post by snibgo »

ImageMagick is a raster image processor, not a vector image processor. If you want to process a vector image and keep it as a vector, IM is not the correct tool.
snibgo's IM pages: im.snibgo.com
nycionx
Posts: 14
Joined: 2015-11-21T19:20:50-07:00
Authentication code: 1151

Re: Center image of SVG or EPS inside its bounding box?

Post by nycionx »

snibgo wrote:ImageMagick is a raster image processor, not a vector image processor. If you want to process a vector image and keep it as a vector, IM is not the correct tool.
Ok thx I didn't know that
marios
Posts: 2
Joined: 2016-01-13T09:52:16-07:00
Authentication code: 1151

Re: Center image of SVG or EPS inside its bounding box?

Post by marios »

I think, Illustrator or Corel will help you to solve this case.
ImageMagick user. Design like Culina aus Polen
Post Reply