mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-09-21 14:11:22 +02:00
Add a huge comment on DPR compenation in calcScale
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user