Skip to content

Commit 8d9392a

Browse files
committed
Merge pull request #21 from francesco-magnoni/francesco-magnoni-patch-1
Added "preserve not enlarge" functionality
2 parents 558078b + 4c04bc1 commit 8d9392a

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

README.mdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ There are two major functions: `identify` and `convert`, plus a helpful `selftes
9393

9494
`thumbnail` The new size of the image, in "WxH" format (e.g., `20x30`). Thumbnailing assumes the resulting image will be pretty small and makes some optimizations.
9595

96-
`shape` The shape of the image, when `resize`ing or `thumbnail`ing to a different aspect ratio. The value can be `preserve` which will preserve the original aspect ratio, `pad` which will add padding to keep the proper aspect ratio (you can supply a `background` parameter to choose the background color to pad with, or leave blank to pad with transparent color if the image format allows it), and `cut` which will cut the image to fit the new size. The default is `preserve`.
96+
`shape` The shape of the image, when `resize`ing or `thumbnail`ing to a different aspect ratio. The value can be `preserve` which will preserve the original aspect ratio, `pad` which will add padding to keep the proper aspect ratio (you can supply a `background` parameter to choose the background color to pad with, or leave blank to pad with transparent color if the image format allows it), and `cut` which will cut the image to fit the new size. Another option is "preserve-not-enlarge", it does the same as "preserve" but does nothing if the supplied image format is smaller than the desider one. The default is `preserve`.
9797

9898
`flip` Flip the image. The value can be `horizontal` or `vertical`.
9999

lib/imageproxy/convert.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def resize_thumbnail_options(size)
5959
"#{size}^ -background #{background} -gravity center -extent #{size}"
6060
when "preserve"
6161
size
62+
when "preserve-not-enlarge"
63+
"#{size}\\\> "
6264
when "pad"
6365
background = options.background ? %|"#{options.background}"| : %|none -matte|
6466
"#{size} -background #{background} -gravity center -extent #{size}"

0 commit comments

Comments
 (0)