Page 1 of 1

Center image of SVG or EPS inside its bounding box?

Posted: 2015-12-22T13:12:33-07:00
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

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

Posted: 2015-12-22T14:40:34-07:00
by fmw42
Please provide your source file and your IM version and platform. Please read viewtopic.php?f=1&t=9620

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

Posted: 2015-12-23T09:55:53-07:00
by nycionx

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

Posted: 2015-12-23T11:53:46-07:00
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

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

Posted: 2015-12-25T16:28:21-07:00
by nycionx
Ok thx I'll try this out and report back, sorry for late reply busy with so many things (holiday season :D

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

Posted: 2016-01-03T11:29:13-07:00
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.

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

Posted: 2016-01-03T12:19:05-07:00
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.

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

Posted: 2016-01-10T03:41:22-07:00
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

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

Posted: 2016-01-13T10:17:45-07:00
by marios
I think, Illustrator or Corel will help you to solve this case.