Sorry if i'm sending this twice, not sure the prev sending went fine (i didn't received it).
I generally do something similar in PHP, but as i simply call inkscape executable you should be able to do the same with every scripting language that supports shell command execution (system, exec and similar).
For your case, it seems you simply need to nest 2 different SVGS into one, placing them accordingly.
A generic syntax is in this form:
<svg width="[SVG_W]in" height="[SVG_H]in"> <g transform="translate(0,0)"> [SVG FILE 1] </g> <g transform="translate(0,0)"> [SVG FILE 2] </g> </svg>
There are some things o keep in mind anyhow. This general form will show an effect like gravity="NortWest" in Magick. If you want to simulate the gravity="center" effect, you will have to alter the "translate" property of the SVG nested images. But again, remember that vectors may generally be sizeless, so to calc the sizes correctly you will first need to determine your [SVG FILE 1] and [SVG FILE 2] width and height. To do this i generally use a small trick and i create aspect ratios. Here's the full steps i'd suggest (combining inkscape and magick):
Let's say what you know are the SVG filenames, call the [SVG FILE 1] and [SVG FILE 2] [SVG FILE 1] is the BG image.
----------------- inkscape -z -d 90 -e temp.png [SVG FILE 1] [SVG FILE 1 W] = identify -format "%w" temp.png [SVG FILE 1 H] = identify -format "%h" temp.png
inkscape -z -d 90 -e temp.png [SVG FILE 2] [SVG FILE 2 W] = identify -format "%w" temp.png [SVG FILE 2 H] = identify -format "%h" temp.png
delete temp.png -----------------
This first part will give you real sizes of both images at 90 DPI. It's just something to calc on real numbers. Next you need to alter my initial generic synatx in this way:
-----------------
[SVG_W]=max([SVG FILE 1 W],[SVG FILE 2 W]) [SVG_H]=max([SVG FILE 1 H],[SVG FILE 2 H]) [SVG FILE 1 X]=([SVG_W]-[SVG FILE 1 W])/2 [SVG FILE 1 Y]=([SVG_H]-[SVG FILE 1 H])/2 [SVG FILE 2 X]=([SVG_W]-[SVG FILE 2 W])/2 [SVG FILE 2 Y]=([SVG_H]-[SVG FILE 2 H])/2
<svg width="[SVG_W]in" height="[SVG_H]in"> <g transform="translate([SVG FILE 1 X],[SVG FILE 1 Y])"> [SVG FILE 1] </g> <g transform="translate([SVG FILE 2 X],[SVG FILE 2 Y])"> [SVG FILE 2] </g> </svg>
-----------------
Hope this helps,
Alex
Marcin Kasperski wrote:
Is it possible to use inkscape (if not, something else) to do simple SVG editing, like combining two images into one? So one can script it...
My typical use case is - I have collection of images and I need to generate their versions on a few different backgrounds. Doing it manually is very tedious.
With bitmaps Image::Magick works great, sth like $img->Read(picture); $img2->Read(background); $img2->Composite(image => $img, gravity => 'center'); $img2->Write(output) and I am done (here it is perl scripting, but that's not very important).
Any chance for something similar with SVG?
This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user