Skip to main content
replaced http://graphicdesign.stackexchange.com/ with https://graphicdesign.stackexchange.com/
Source Link

I found a way to do this in this question: Inkscape - Center Drawing to Page via Command Line/TerminalInkscape - Center Drawing to Page via Command Line/Terminal

With "foo.svg" as the image to edit:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit foo.svg

To edit all svg images in the current directory:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileClose *.svg

But this second command opens a ton of windows, which will make your computer crash if you're editing too many images. For Linux only, this command will work better:

for img in $(ls *.svg) ; do inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; done

For the above command, if any of the files are symlinks, Inkscape will edit the target file that the symlink points to. If you don't want Inkscape to do this, you can filter out any symlinks with this command:

for img in $(ls *.svg) ; do if [[ $(readlink $img) == "" ]] ; then inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; fi ; done

While I'm at it, I might as well post the bash script I made for this:
#!/bin/bash
# inkscape-center <file-or-directory>...

_analyse() {
    if [ -d "${1}" ] ; then
        _centerAll "${1}" ;
    else
        _center "${1}" ;
    fi
}

_centerAll() {
    cd "${1}" ;
    for img in $(ls "*.svg") ; do
        _filterSyms "${img}" ;
    done
}

_filterSyms() {
    if [[ $(readlink "${1}") == "" ]] ; then
        _center "${1}"
    fi
}

_center() {
    inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit "${1}"
}

for arg ; do
    _analyse "${arg}" ;
done

I called it inkscape-center and run it like this:

inkscape-center <file-or-directory>

It takes as many arguments as you want, so you can do something like this:

inkscape-center 1st.svg 2nd.svg 3rd.svg 4th.svg

Be careful- If you specify a directory instead of a file, it'll edit every svg file in that directory.

I found a way to do this in this question: Inkscape - Center Drawing to Page via Command Line/Terminal

With "foo.svg" as the image to edit:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit foo.svg

To edit all svg images in the current directory:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileClose *.svg

But this second command opens a ton of windows, which will make your computer crash if you're editing too many images. For Linux only, this command will work better:

for img in $(ls *.svg) ; do inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; done

For the above command, if any of the files are symlinks, Inkscape will edit the target file that the symlink points to. If you don't want Inkscape to do this, you can filter out any symlinks with this command:

for img in $(ls *.svg) ; do if [[ $(readlink $img) == "" ]] ; then inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; fi ; done

While I'm at it, I might as well post the bash script I made for this:
#!/bin/bash
# inkscape-center <file-or-directory>...

_analyse() {
    if [ -d "${1}" ] ; then
        _centerAll "${1}" ;
    else
        _center "${1}" ;
    fi
}

_centerAll() {
    cd "${1}" ;
    for img in $(ls "*.svg") ; do
        _filterSyms "${img}" ;
    done
}

_filterSyms() {
    if [[ $(readlink "${1}") == "" ]] ; then
        _center "${1}"
    fi
}

_center() {
    inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit "${1}"
}

for arg ; do
    _analyse "${arg}" ;
done

I called it inkscape-center and run it like this:

inkscape-center <file-or-directory>

It takes as many arguments as you want, so you can do something like this:

inkscape-center 1st.svg 2nd.svg 3rd.svg 4th.svg

Be careful- If you specify a directory instead of a file, it'll edit every svg file in that directory.

I found a way to do this in this question: Inkscape - Center Drawing to Page via Command Line/Terminal

With "foo.svg" as the image to edit:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit foo.svg

To edit all svg images in the current directory:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileClose *.svg

But this second command opens a ton of windows, which will make your computer crash if you're editing too many images. For Linux only, this command will work better:

for img in $(ls *.svg) ; do inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; done

For the above command, if any of the files are symlinks, Inkscape will edit the target file that the symlink points to. If you don't want Inkscape to do this, you can filter out any symlinks with this command:

for img in $(ls *.svg) ; do if [[ $(readlink $img) == "" ]] ; then inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; fi ; done

While I'm at it, I might as well post the bash script I made for this:
#!/bin/bash
# inkscape-center <file-or-directory>...

_analyse() {
    if [ -d "${1}" ] ; then
        _centerAll "${1}" ;
    else
        _center "${1}" ;
    fi
}

_centerAll() {
    cd "${1}" ;
    for img in $(ls "*.svg") ; do
        _filterSyms "${img}" ;
    done
}

_filterSyms() {
    if [[ $(readlink "${1}") == "" ]] ; then
        _center "${1}"
    fi
}

_center() {
    inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit "${1}"
}

for arg ; do
    _analyse "${arg}" ;
done

I called it inkscape-center and run it like this:

inkscape-center <file-or-directory>

It takes as many arguments as you want, so you can do something like this:

inkscape-center 1st.svg 2nd.svg 3rd.svg 4th.svg

Be careful- If you specify a directory instead of a file, it'll edit every svg file in that directory.

pasted output of link
Source Link

I found a way to do this in this question: Inkscape - Center Drawing to Page via Command Line/Terminal

With "foo.svg" as the image to edit:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit foo.svg

To edit all svg images in the current directory:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileClose *.svg

But this second command opens a ton of windows, which will make your computer crash if you're editing too many images. For Linux only, this command will work better:

for img in $(ls *.svg) ; do inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; done

For the above command, if any of the files are symlinks, Inkscape will edit the target file that the symlink points to. If you don't want Inkscape to do this, you can filter out any symlinks with this command:

for img in $(ls *.svg) ; do if [[ $(readlink $img) == "" ]] ; then inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; fi ; done

While I'm at it, I might as well post the bash script I made for this:
#!/bin/bash
# inkscape-center <file-or-directory>...

_analyse() {
    if [ -d "${1}" ] ; then
        _centerAll "${1}" ;
    else
        _center "${1}" ;
    fi
}

_centerAll() {
    cd "${1}" ;
    for img in $(ls "*.svg") ; do
        _filterSyms "${img}" ;
    done
}

_filterSyms() {
    if [[ $(readlink "${1}") == "" ]] ; then
        _center "${1}"
    fi
}

_center() {
    inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit "${1}"
}

for arg ; do
    _analyse "${arg}" ;
done

I called it inkscape-center and run it like this:

inkscape-center <file-or-directory>

It takes as many arguments as you want, so you can do something like this:

inkscape-center 1st.svg 2nd.svg 3rd.svg 4th.svg

Be careful- If you specify a directory instead of a file, it'll edit every svg file in that directory.

I found a way to do this in this question: Inkscape - Center Drawing to Page via Command Line/Terminal

I found a way to do this in this question: Inkscape - Center Drawing to Page via Command Line/Terminal

With "foo.svg" as the image to edit:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit foo.svg

To edit all svg images in the current directory:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileClose *.svg

But this second command opens a ton of windows, which will make your computer crash if you're editing too many images. For Linux only, this command will work better:

for img in $(ls *.svg) ; do inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; done

For the above command, if any of the files are symlinks, Inkscape will edit the target file that the symlink points to. If you don't want Inkscape to do this, you can filter out any symlinks with this command:

for img in $(ls *.svg) ; do if [[ $(readlink $img) == "" ]] ; then inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; fi ; done

While I'm at it, I might as well post the bash script I made for this:
#!/bin/bash
# inkscape-center <file-or-directory>...

_analyse() {
    if [ -d "${1}" ] ; then
        _centerAll "${1}" ;
    else
        _center "${1}" ;
    fi
}

_centerAll() {
    cd "${1}" ;
    for img in $(ls "*.svg") ; do
        _filterSyms "${img}" ;
    done
}

_filterSyms() {
    if [[ $(readlink "${1}") == "" ]] ; then
        _center "${1}"
    fi
}

_center() {
    inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit "${1}"
}

for arg ; do
    _analyse "${arg}" ;
done

I called it inkscape-center and run it like this:

inkscape-center <file-or-directory>

It takes as many arguments as you want, so you can do something like this:

inkscape-center 1st.svg 2nd.svg 3rd.svg 4th.svg

Be careful- If you specify a directory instead of a file, it'll edit every svg file in that directory.

pointed to a different question to keep things clean
Source Link

To editI found a single image with the filename "foo.svg":

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit foo.svg`

To edit all svg imagesway to do this in the current directory:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileClose *.svg

But this second command will open a ton of windows, which is just bad news all around. Here's a better command (for Linux, at least)question: Inkscape - Center Drawing to Page via Command Line/Terminal

for img in $(ls *.svg) ; do inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; done

To edit a single image with the filename "foo.svg":

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit foo.svg`

To edit all svg images in the current directory:

inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileClose *.svg

But this second command will open a ton of windows, which is just bad news all around. Here's a better command (for Linux, at least):

for img in $(ls *.svg) ; do inkscape --verb=EditSelectAll --verb=AlignHorizontalCenter --verb=AlignVerticalCenter --verb=FileSave --verb=FileQuit $img ; done

I found a way to do this in this question: Inkscape - Center Drawing to Page via Command Line/Terminal

deleted 1 character in body
Source Link
Loading
added Linux command
Source Link
Loading
fixed command error
Source Link
Loading
Source Link
Loading