Add a huge comment on DPR compenation in calcScale

This commit is contained in:
DarthSim
2025-09-20 00:27:01 +03:00
parent 5ac82cec34
commit a63778e3cf

View File

@@ -117,6 +117,16 @@ func (pctx *Context) calcScale(width, height int, po *options.ProcessingOptions)
wshrink /= minShrink
hshrink /= minShrink
// If we reached this point, this means that we can't reach the target size
// because the image is smaller than it, and the enlargement is disabled.
// If the DprScale is less than 1, the image will be downscaled, moving
// even further from the target size, so we need to compensate it.
// The compensation may increase the DprScale too much, but this is okay,
// because we'll handle this further in the code.
//
// If the Extend option is enabled, we want to keep the resulting image
// composition the same regardless of the DPR, so we don't apply this compensation
// in this case.
if !po.Extend.Enabled {
pctx.DprScale /= minShrink
}