repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
80b474a
parent
4ae5e13
author
Eric Bower
date
2022-09-01 21:40:00 +0000 UTC
fix(imgs): jpg not always detected in exif scrubber
2 files changed,  +12, -4
M filehandlers/imgs/handler.go
+6, -2
 1@@ -170,8 +170,12 @@ func (h *UploadImgHandler) Write(s ssh.Session, entry *utils.FileEntry) (string,
 2 	if slices.Contains([]string{"image/png", "image/jpg", "image/jpeg"}, mimeType) {
 3 		noExifBytes, err := exifremove.Remove(text)
 4 		if err == nil {
 5-			text = noExifBytes
 6-			h.Cfg.Logger.Infof("(%s) stripped exif data", filename)
 7+			if len(noExifBytes) == 0 {
 8+				h.Cfg.Logger.Infof("(%s) silently failed to strip exif data", filename)
 9+			} else {
10+				text = noExifBytes
11+				h.Cfg.Logger.Infof("(%s) stripped exif data", filename)
12+			}
13 		} else {
14 			h.Cfg.Logger.Error(err)
15 		}
M shared/img.go
+6, -2
 1@@ -141,13 +141,17 @@ func NewImgOptimizer(logger *zap.SugaredLogger, optimized bool, dimes string) *I
 2 		Optimized:  optimized,
 3 		DeviceType: desktopDevice,
 4 		Quality:    75,
 5+		Ratio:      &Ratio{Width: 0, Height: 0},
 6 	}
 7 
 8 	ratio, err := GetRatio(dimes)
 9-	if err == nil {
10+	if ratio != nil {
11 		opt.Ratio = ratio
12-	} else {
13+	}
14+
15+	if err != nil {
16 		logger.Error(err)
17 	}
18+
19 	return opt
20 }