1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-02-07 11:36:25 +02:00

Convert all images to uchar

This commit is contained in:
DarthSim 2020-09-11 17:20:12 +06:00
parent dc2c23c01a
commit bdbb496c18

View File

@ -501,7 +501,15 @@ func transformImage(ctx context.Context, img *vipsImage, data []byte, po *proces
}
}
return img.RgbColourspace()
if err = img.RgbColourspace(); err != nil {
return err
}
if err := img.CastUchar(); err != nil {
return err
}
return copyMemoryAndCheckTimeout(ctx, img)
}
func transformAnimated(ctx context.Context, img *vipsImage, data []byte, po *processingOptions, imgtype imageType) error {
@ -599,6 +607,14 @@ func transformAnimated(ctx context.Context, img *vipsImage, data []byte, po *pro
}
}
if err = img.CastUchar(); err != nil {
return err
}
if err = copyMemoryAndCheckTimeout(ctx, img); err != nil {
return err
}
img.SetInt("page-height", frames[0].Height())
img.SetInt("gif-delay", delay)
img.SetInt("gif-loop", loop)
@ -769,12 +785,6 @@ func processImage(ctx context.Context) ([]byte, context.CancelFunc, error) {
return nil, func() {}, err
}
if po.Format == imageTypeGIF || po.Format == imageTypeBMP {
if err := img.CastUchar(); err != nil {
return nil, func() {}, err
}
}
if po.MaxBytes > 0 && canFitToBytes(po.Format) {
return saveImageToFitBytes(po, img)
}