Skip to content

Instantly share code, notes, and snippets.

@trevorsheridan
Created August 1, 2012 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevorsheridan/3225504 to your computer and use it in GitHub Desktop.
Save trevorsheridan/3225504 to your computer and use it in GitHub Desktop.
Calculate the dimensions of a bitmap given a rotation and rotation width.
#!/bin/bash
temp="/tmp/size-"$(date +"%s")"-tmp.png"
em=10
convert $1 -rotate $2 $temp
convert $temp -scale $3 -rotate $(echo "$2 * -1" | bc) -trim -shave 2x2 $temp
identify -format "dimensions: %w x %h pixels\nwidth: %[fx:w/$em]em;\nheight: %[fx:h/$em]em;" $temp
rm -rf $temp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment