Can you prevent upscaling when using Craft's image transforms? With Craft's image transforms used to resize images or generate thumbnails, can you prevent images from being upscaled? There's often cases where it makes no sense to increase the dimensions of an image.

It would be great if there was a setting for this, but I can't find one documented.

Otherwise, is the solution to fetch the image size in Twig and then conditionally apply the image transform?
As found here, this actually seems to be a requested feature that is not yet implemented. However, in the link given, Brandon also supplied a workaround for the time being:

{% set transform = {
width: min(150, image.width),
height: min(100, image.height)
} %}

&lt;img src="{{ image.getUrl(transform) }}"&gt;