mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-01-23 11:14:48 +02:00
Fix calcShrink 🤦
This commit is contained in:
parent
945ffb485b
commit
b51e5ca25e
10
process.go
10
process.go
@ -160,13 +160,12 @@ func calcScale(width, height int, po processingOptions) float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func calcShink(scale float64, imgtype imageType) int {
|
func calcShink(scale float64, imgtype imageType) int {
|
||||||
|
switch imgtype {
|
||||||
|
case imageTypeWEBP:
|
||||||
|
return int(1.0 / scale)
|
||||||
|
case imageTypeJPEG:
|
||||||
shrink := int(1.0 / scale)
|
shrink := int(1.0 / scale)
|
||||||
|
|
||||||
if imgtype != imageTypeJPEG {
|
|
||||||
return shrink
|
|
||||||
}
|
|
||||||
|
|
||||||
if imgtype != imageTypeWEBP {
|
|
||||||
switch {
|
switch {
|
||||||
case shrink >= 16:
|
case shrink >= 16:
|
||||||
return 8
|
return 8
|
||||||
@ -247,6 +246,7 @@ func processImage(data []byte, imgtype imageType, po processingOptions, t *timer
|
|||||||
if scale < 1.0 {
|
if scale < 1.0 {
|
||||||
if shrink := calcShink(scale, imgtype); shrink != 1 {
|
if shrink := calcShink(scale, imgtype); shrink != 1 {
|
||||||
scale = scale * float64(shrink)
|
scale = scale * float64(shrink)
|
||||||
|
log.Printf("Scale: %f, Shrink: %d", scale, shrink)
|
||||||
|
|
||||||
if tmp, e := vipsLoadImage(data, imgtype, shrink); e == nil {
|
if tmp, e := vipsLoadImage(data, imgtype, shrink); e == nil {
|
||||||
C.swap_and_clear(&img, tmp)
|
C.swap_and_clear(&img, tmp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user