mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-10 17:18:31 +00:00
fixes
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user