Scale profile pictures to a consistent size

This commit is contained in:
Noah Petherbridge 2023-10-29 12:42:21 -07:00
parent bb0e7fa2fc
commit 3d01fc55f4

View File

@ -118,6 +118,9 @@ func UploadPhoto(cfg UploadConfig) (string, string, error) {
return filename, "", nil
}
// Scale profile photos down into consistent sizes.
croppedImg = Scale(croppedImg, image.Rect(0, 0, config.ProfilePhotoWidth, config.ProfilePhotoWidth), draw.ApproxBiLinear)
// Write that to disk, too.
log.Debug("Writing cropped image to disk: %s", cropFilename)
if err := ToDisk(cropFilename, extension, croppedImg, &cfg); err != nil {
@ -218,6 +221,9 @@ func ReCrop(filename string, x, y, w, h int) (string, error) {
return "", err
}
// Scale profile photos down into consistent sizes.
croppedImg = Scale(croppedImg, image.Rect(0, 0, config.ProfilePhotoWidth, config.ProfilePhotoWidth), draw.ApproxBiLinear)
// Write it.
err = ToDisk(cropFilename, ext, croppedImg, nil)
return cropFilename, err