resizedSize method
Upstream rounds ties to even before checking the pixel budget. The budget is an area, despite the config's shortest_edge/longest_edge names.
Implementation
(int height, int width) resizedSize(int height, int width) {
if (height <= 0 ||
width <= 0 ||
math.max(height, width) / math.min(height, width) > 200) {
throw ArgumentError(
'image dimensions must be positive with aspect ratio <= 200',
);
}
var h = _roundEven(height / factor) * factor;
var w = _roundEven(width / factor) * factor;
if (h * w > maxPixels) {
final scale = math.sqrt(height * width / maxPixels);
h = math.max(factor, (height / scale / factor).floor() * factor);
w = math.max(factor, (width / scale / factor).floor() * factor);
} else if (h * w < minPixels) {
final scale = math.sqrt(minPixels / (height * width));
h = (height * scale / factor).ceil() * factor;
w = (width * scale / factor).ceil() * factor;
}
return (h, w);
}