A rotated SVG image when exported as PNG using Command Line option, resultant image skews & stretches a little.

Bug #1360284 reported by Raguraman S
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
New
Undecided
Unassigned

Bug Description

We need to export a PNG image from SVG through Inkscape command line options. When a rotated SVG image exported as PNG using Command Line option, resultant image skews & stretches a little.

Inkscape version 0.48
OS: Win7 Professional

Issue details including screenshots are mentioned in the attached PDF.

summary: - Rotate Svg Image is export to png not stretched correctly using Command
- Line option
+ Rotated SVG image when exported to PNG using Command Line option, skews
+ & stretches a little.
summary: - Rotated SVG image when exported to PNG using Command Line option, skews
- & stretches a little.
+ A rotated SVG image when exported as PNG using Command Line option,
+ skews & stretches a little.
summary: A rotated SVG image when exported as PNG using Command Line option,
- skews & stretches a little.
+ resultant image skews & stretches a little.
description: updated
Revision history for this message
Raguraman S (raguraman-s) wrote :

Different screenshots of image.

Revision history for this message
su_v (suv-lp) wrote :

Too bad no SVG test case was provided… - but the result as far as I understand is to be expected: you explicitly tell inkscape to scale both _width_ and _height_ on export:

<quote>
-w, --export-width

    An exported bitmap will be scaled so that the width is equal to the specified number of pixels. Overrides --export-dpi.

-h, --export-height

    An exported bitmap will be scaled so that the height is equal to the specified number of pixels. Overrides --export-dpi.
</quote>

Since the rotated path (a triangle) doesn't have the same proportions (its height is larger than its width), the export scales the width to match the size requested on the command line.

Possible solutions if you need to export to a square-sized bitmap (PNG) without scaling the content:
1) Don't use 'export-area-drawing' (use default; i.e. export area of the page), and make sure that the rotated object is still positioned in the center of the page (you'd have to adjust the rotate() property and add the center of rotation).
2) Add an invisible square (<rect> with no stroke, no fill defined) stacked below the path, and again when rotating the path, make sure to define the rotation center in order to keep the rotated path within the area of the square below. With either solution export via command line specifying target w=h=X will work as expected for any size and will produce square bitmap images with unscaled paths.

From the PDF:
> Export as PNG from Inkscape UI --> As expected

3) Export custom area: note that via GUI, it is not possible to export 'drawing' area of the rotated path with e.g. 152x152 px (the drawing area of the rotated path is not square). You can though export a custom size (define a square area) to a square bitmap image (PNG). This option is also available on the command line (the values may vary because they depend on the details how the path was rotated (no sample SVG file produced by fabricJS was provided, so no further details here)):

<quote>
-a, --export-area

    Specifies the rectangular region that should be exported. Requires the coordinates of the lower-left corner and the upper-right corner in the format: x0:y0:x1:y1. (The lower-left corner of the drawing has coordinates of 0,0.) The units are in SVG user units.

    Example: to export the left half of a 200 by 100 pixel drawing to a PNG:

    inkscape --export-area=0:0:100:100 --export-png=test.png test.svg
</quote>

Further information:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine-Export.html#CommandLine-Export-Region
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/File-Export.html#File-Export-PNG

Proposing to close as 'Invalid' - not a bug (AFAIU).

tags: added: bitmap cli exporting
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.