returnnil,status.Errorf(codes.Internal,"failed to save attachment blob: %v",err)
returnnil,status.Errorf(codes.Internal,"failed to save attachment blob: %v",err)
}
}
@ -531,13 +544,12 @@ const (
thumbnailMaxSize=600
thumbnailMaxSize=600
// defaultJPEGQuality is the default JPEG quality for downscaling images.
// defaultJPEGQuality is the default JPEG quality for downscaling images.
defaultJPEGQuality=85
defaultJPEGQuality=85
// defaultThumbnailJPEGQuality is the JPEG quality for generated thumbnails.
defaultThumbnailJPEGQuality=75
// maxAttachmentImageDimension is the maximum size in pixels for the largest dimension when storing images. Images larger than this will be downscaled before storage.
maxAttachmentImageDimension=2048
)
)
// downscaleImage takes an image blob and returns a downscaled version as a blob.
// The maxDimension parameter specifies the maximum size in pixels for the largest dimension.
// The quality parameter specifies the JPEG encoding quality (1-100, where 100 is best quality).
// PNG images are preserved as PNG, other formats are encoded as JPEG.
// Images smaller than maxDimension are not enlarged.