Created
January 2, 2009 05:54
-
-
Save ryanfb/42473 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
proc crop_to_fit {url {xoff 0} {yoff 0} {w 63} {h 79}} {set ar [expr $w./$h.]; set dims [get_image_size $url]; if [expr $xoff == -1] {set xoff [expr round([lindex $dims 0]*$ar/4)]}; if [expr $yoff == -1] {set yoff [expr round([lindex $dims 1]/$ar/4)]}; set x [expr [lindex $dims 0]-$xoff]; set y [expr [lindex $dims 1]-$yoff]; set oar [expr $x./$y.]; if [expr $oar > $ar] {set crop [magick crop $url $xoff $yoff [expr $y*$ar] $y]} else {set crop [magick crop $url $xoff $yoff $x [expr $x/$ar]]}; . $crop} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment