Created
April 7, 2014 18:31
-
-
Save jcracknell/10027521 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#========== | |
# Uses the GIMP to set the specified DPI value on the specified image without | |
# changing the dimensions of the image. | |
# | |
# This is useful as Inkscape provides no means of changing the DPI of an exported | |
# image without altering its pixel count, and also defaults to 90dpi. | |
# | |
# Note that gimp-console must be in your $PATH. | |
dpi=$1 | |
img=$2 | |
if [ "$dpi" -a "$img" ]; then | |
echo "Setting DPI of \"$img\" to $dpi... "; | |
gimp-console -i -b " | |
(let* ( | |
(image (car (gimp-file-load RUN-NONINTERACTIVE \"$img\" \"$img\"))) | |
(drawable (car (gimp-image-get-active-layer image))) | |
) ( | |
(gimp-image-set-resolution image $dpi $dpi) | |
(gimp-file-save RUN-NONINTERACTIVE image drawable \"$img\" \"$img\") | |
(gimp-quit 0) | |
)) | |
"; | |
else | |
echo "Usage: $0 <dpi> <img>"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment