saucecontrol / PhotoSauce

MagicScaler high-performance, high-quality image processing pipeline for .NET
http://photosauce.net/
MIT License
589 stars 49 forks source link

CropScaleMode.Max upscales the image ? #30

Closed hheexx closed 5 years ago

hheexx commented 5 years ago

As I thought CropScaleMode.Max only downscales images if needed. Looks like it also upscales so name is a little misleading.

Is there a mode that only downscales if needed?

saucecontrol commented 5 years ago

I don't believe there's anything misleading about the name. It resizes to the max of your requested width or height while maintaining aspect ratio. All modes will upscale or downscale as necessary to meet your requested output dimensions.

If you wish to prevent upscaling entirely, you can use ImageFileInfo to inspect your source image before resizing and clamp the requested output size to be no larger than the input.

hheexx commented 5 years ago

Found ImageFileInfo class now. It works. Consider adding boolean to settings to disable upscaling. I think it may be common need...

Thanks!

saucecontrol commented 5 years ago

Yep, that sounds reasonable. I built that option into the WebRSize module but it makes sense to get it moved into the main processor.

saucecontrol commented 4 years ago

FYI, I decided to update the behavior of CropScaleMode.Max so it no longer upscales starting from v0.10.0. There is a new CropScaleMode.Contain that maintains the old behavior.