mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-05 19:23:07 +02:00
Add image type check to calcShrink
This commit is contained in:
@@ -166,6 +166,7 @@ func calcShink(scale float64, imgtype imageType) int {
|
|||||||
return shrink
|
return shrink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if imgtype != imageTypeWEBP {
|
||||||
switch {
|
switch {
|
||||||
case shrink >= 16:
|
case shrink >= 16:
|
||||||
return 8
|
return 8
|
||||||
@@ -174,6 +175,7 @@ func calcShink(scale float64, imgtype imageType) int {
|
|||||||
case shrink >= 4:
|
case shrink >= 4:
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -235,8 +237,7 @@ func processImage(data []byte, imgtype imageType, po processingOptions, t *timer
|
|||||||
|
|
||||||
// Do some shrink-on-load
|
// Do some shrink-on-load
|
||||||
if scale < 1.0 {
|
if scale < 1.0 {
|
||||||
if imgtype == imageTypeJPEG || imgtype == imageTypeWEBP {
|
if shrink := calcShink(scale, imgtype); shrink != 1 {
|
||||||
shrink := calcShink(scale, imgtype)
|
|
||||||
scale = scale * float64(shrink)
|
scale = scale * float64(shrink)
|
||||||
|
|
||||||
if tmp, e := vipsLoadImage(data, imgtype, shrink); e == nil {
|
if tmp, e := vipsLoadImage(data, imgtype, shrink); e == nil {
|
||||||
|
Reference in New Issue
Block a user