This commit is contained in:
IC Rainbow
2024-10-31 13:32:45 +02:00
parent b7c77651bc
commit d91bae8c9c
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -319,7 +319,7 @@ private func getTimestamp() -> String {
}
public func dropImagePrefix(_ s: String) -> String {
dropPrefix(dropPrefix(s, "data:image/png;base64,"), "data:image/jpg;base64,")
dropPrefix(dropPrefix(dropPrefix(s, "data:image/png;base64,"), "data:image/jpg;base64,"), "data:image/jpeg;base64,")
}
private func dropPrefix(_ s: String, _ prefix: String) -> String {
+1 -1
View File
@@ -52,7 +52,7 @@ resizeImageToSize toURI maxSize (ResizeableImage fmt img encoder) = either resiz
| otherwise = fitQuality 33 99
where
encode q
| toURI = toDataUri "jpeg" $ enc q img
| toURI = toDataUri "jpg" $ enc q img -- the correct mime type is "jpeg", but only "jpg" is supported by older clients
| otherwise = enc q img
minSize = LB.length $ encode 33
fitQuality l u
+2 -2
View File
@@ -20,8 +20,8 @@ linkPreviewTests = do
resizeToStrTest :: FilePath -> FilePath -> IO ()
resizeToStrTest inputPath tmp = do
(ri@(ResizeableImage imgFormat _img encoder), metadata) <- either error pure =<< Image.readResizeable inputPath
logDebug $ tshow (metadata, imgFormat, either (const "png") (const "jpeg") encoder)
let res = Image.resizeImageToStrSize maxSize ri
logDebug $ tshow (metadata, imgFormat, either (const "png") (const "jpg") encoder)
let res = Image.resizeImageToSize True maxSize ri
finalSize = LB.length res
unless (finalSize <= maxSize) $ error $ "Final size larger than maximum size: " <> show (finalSize, maxSize)
let (fmt, b64) = fmap (LB.drop 8) . LB.break (== ';') $ LB.drop 11 res