Add "letterbox" image transform mode #8848
-
Letterbox is a transform mode used in imager/imager-x plugin. It adds an empty area to top and bottom or left and right area of an image in order to fit it into specific dimensions. Personally, I find it extremely useful, especially for things like product listings where each image needs to have same dimensions and images should not be cropped. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
Hm, this seems like it would be better handled with CSS that adds a background color to the image container or something, rather than adding additional pointless image data. I’ll leave it open though. |
Beta Was this translation helpful? Give feedback.
-
I dont think that the background color is the important thing with letterbox mode. I think the important part is that you can generete a grid of images, for instance for a webshop, where all images are the same dimensions. |
Beta Was this translation helpful? Give feedback.
-
We’ve just added a new “Letterbox” transform mode for Craft 4.4 🎉 (via #12214) Unlike Fill transforms, Letterbox transforms will always generate images with the exact width and height specified by the transform. The surrounding pixels can either be transparent or a certain color fill. You can define Letterbox transforms in your templates by setting {% do asset.setTransform({
mode: 'letterbox',
width: 200,
height: 200,
position: 'top-center',
fill: '#000000',
}) %} We’ve also added a new “Allow Upscaling” setting to all transforms, which takes precedence over the We did that because there’s a good chance that upscaling would be desired when using Letterbox transforms (so you don’t end up with images that have padding on all sides), even if in general upscaling should be avoided. |
Beta Was this translation helpful? Give feedback.
We’ve just added a new “Letterbox” transform mode for Craft 4.4 🎉 (via #12214)
Unlike Fill transforms, Letterbox transforms will always generate images with the exact width and height specified by the transform. The surrounding pixels can either be transparent or a certain color fill.
You can define Letterbox transforms in your templates by setting
mode
to'letterbox'
:We’ve also added a new “Allow Upscaling” setting to all transforms, which takes precedence over the
upscaleImages
config setting when specified. (Template-defined transforms can set this via anup…