asilvas / node-image-steam

A simple, fast, and highly customizable on-the-fly image manipulation web server built atop Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: optionally cap the max pixel count instead of max dimensions

subtleGradient opened this issue · comments

Use case: we have a bunch of super tall and skinny images.
Since they're so tall, they're hitting the originalSteps maximum height limit.
But since they're so skinny, they shouldn't be unnecessarily scaled down.

So, I propose calculating a maximum pixel count instead of maximum dimensions.

I'm planning to implement this myself (if I can figure out how ;)

resize: { width: '2560', height: '2560', max: 'true', canGrow: 'false' },

maxSize: { width: 2560, height: 2560 }

if (context.options.maxSize) {
// request should never exceed permitted output size
if (stepInfo.width > context.options.maxSize.width) {
stepInfo.width = context.options.maxSize.width;
}
if (stepInfo.height > context.options.maxSize.height) {
stepInfo.height = context.options.maxSize.height;
}
}