#!/bin/bash

# SPDX-FileCopyrightText: 2022 J.C. Mariscal-Melgar <jc@hsu-hh.de>
# SPDX-FileCopyrightText: 2022 Pieter Hijma <pieter@hiww.de>
#
# SPDX-License-Identifier: Apache-2.0

if [ $# = 1 ]
then
    if inkscape --version | grep "Inkscape 1.1.2" > /dev/null 2>&1
    then
	inkscape --batch-process --actions="select-all:all;FitCanvasToSelection;FileSave;FileClose;" "$1"
    elif inkscape --version | grep "Inkscape 1.2" > /dev/null 2>&1
    then
	inkscape --batch-process --actions="select-all:all;fit-canvas-to-selection;export-filename:$1;export-do" "$1"
    fi
else
    echo "USAGE: $(basename $0) <file.svg>"
fi
