What is the hash (#) resize option in ImageMagick?

Just stumbled upon this 300x300 # size option and I wonder what the hash option means. The official ImageMagick documentation seems to have nothing.

+7
ruby-on-rails imagemagick paperclip
source share
2 answers

According to the Paperclip API documentation :

Paperclip also adds the "#" option (for example, "50x50 #"), which resizes the image as close as possible, and then crop the rest (center-weighted).

So, if you upload a 120x100 image and crop to “50x50 #”, it will resize the image to 60x50 and then crop 50x50 using the centroid of the image as an anchor (thereby removing 5px on the left and 5px on the right).

+8
source share

It seems that there are at least a couple of gems that have independently expanded the syntax of ImageMagick geometry lines by adding a # option. Paperclip does this as described in Jacob's answer . Dragonfly also does this , giving # the same meaning as Paperclip. They list a geometric string like '400x300#' as the value:

resize, crop if necessary, maintain aspect ratio (center of gravity)

+1
source share

All Articles