Inkscape.org
Beginners' Questions Rotate entire image via the command line
  1. #1
    Nico Nico @nschloe
    *

    I would like to rotate an SVG file on the command-line. I've tried

    inkscape --actions "select-all;transform-rotate:90;export-filename:out.svg;export-do" in.svg

    This doesn't rotate the canvas though, so I usually end up with a cropped image.

    Any hints?

  2. #2
    inklinea inklinea @inklinea⛰️

    Rotate in svg is acutally rotate(angle_degrees, x, y)

    Where x, y are the centre of rotation for the operation.

    If not specified they are 0, 0 by default.

    So you could do two command lines, with a select-all;query-all and parse the first entry ( which should be the svg dimensions )

    Then use the centre obtained from that.

    Or you could just cheat.

    inkscapecom.com --actions="select-all;transform-rotate:90;fit-canvas-to-selection;export-filename:rotated.svg;export-do" drawing.svg

    (inkscapecom.com is for Windows, otherwise just use inkscape)

    Please note this will also crop the svg to the dimensions of the selection - so may not be idea.

    If you just want to rotate a selection on canvas without resizing, you would have to use the first method (2 command calls)

  3. #3
    Nico Nico @nschloe

    Thanks for the tip! fit-canvas-to-selection would actually work for me, but it fails on the first example I tried it on; see attachment.

    Might this be a bug in inkscape's embedded raster image handling?

     

    A
  4. #4
    inklinea inklinea @inklinea⛰️

    I'm not sure what the error is from the picture. 

    It could be a problem with the select-all

    select-all          :  Select all; options: 'all' (every object including groups), 'layers', 'no-layers' (top level objects in layers), 'groups' (all groups including layers), 'no-groups' (all objects other than groups and layers, default)

    According to the documentation, 'no-groups' is the default.

    Possibly try select-all:all ?

     

  5. #5
    bgmi41075 bgmi41075 @bgmi41075

    Please note this will also crop the svg to the dimensions of the selection - so may not be idea.

Inkscape Inkscape.org Inkscape Forum Beginners' Questions Rotate entire image via the command line