0

I am taking Gif images, and converting them to sprite sheets so that i can cut them out with my laser. I wrote a script that handles this, but when I convert the png to an SVG, the units always come out as pixels. When I send an SVG file to the laser with pixel units, I get an error that says (Basically) convert the units to inches or millimeters. At this point, I usually open up inkscape, press "ctrl+shift+D" and change the units to inches. That works, but it is more manual than I would like. Is there a command-line way to tell imagemagick, or the convert program to use inches as my units?

My shell script source code:

#!/bin/bash
#set -vx
# Takes an image via an argument, creates a montage. 

mkdir -p test2
rm test2/*.png 

n=`identify -format "%n\n" $1 | head -1`
m=`expr $n / 2`
outputFile=out`date +%s`.png
#outputFile=out.png
echo  "N: " + $n
echo  "M: " + $m

convert -resize 380x380 $1  test2/g.png
convert +append test2/g-*.png $outputFile
#convert -resize 2880x150 $outputFile
montage -border 5 -bordercolor red -geometry +1+1 test2/g-*.png $outputFile
convert $outputFile $1.svg
  • Read man convert, see ` -units type the units of image resolution` – waltinator Aug 31 '18 at 14:33
  • yeah, and -units inches doesnt work, and there is no example its not a good reference. – j0h Aug 31 '18 at 15:17
  • @j0h My suspicion is that you need to use -units PixelsPerInch in combination with a -density option. This nugget of information here: imagemagick.org/script/command-line-options.php#units But this is untested by me... – andrew.46 Aug 31 '18 at 22:34

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.