mirror of
https://github.com/imgproxy/imgproxy.git
synced 2024-11-24 08:12:38 +02:00
Simplify scale-on-load code
This commit is contained in:
parent
c22d84e8dd
commit
27fb29706f
13
process.go
13
process.go
@ -333,18 +333,13 @@ func transformImage(ctx context.Context, img *vipsImage, data []byte, po *proces
|
||||
}
|
||||
|
||||
if !trimmed && scale != 1 && data != nil && canScaleOnLoad(imgtype, scale) {
|
||||
if imgtype == imageTypeWEBP || imgtype == imageTypeSVG {
|
||||
jpegShrink := calcJpegShink(scale, imgtype)
|
||||
|
||||
if imgtype != imageTypeJPEG || jpegShrink != 1 {
|
||||
// Do some scale-on-load
|
||||
if err = img.Load(data, imgtype, 1, scale, 1); err != nil {
|
||||
if err = img.Load(data, imgtype, jpegShrink, scale, 1); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if imgtype == imageTypeJPEG {
|
||||
// Do some shrink-on-load
|
||||
if shrink := calcJpegShink(scale, imgtype); shrink != 1 {
|
||||
if err = img.Load(data, imgtype, shrink, 1.0, 1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update scale after scale-on-load
|
||||
|
Loading…
Reference in New Issue
Block a user