Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve sharing large images #2020

Merged
merged 3 commits into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions DcShare/Helper/ShareAttachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ShareAttachment {
case let url as URL:
result = SDAnimatedImage(contentsOfFile: url.path)
default:
logger.debug("Unexpected data: \(type(of: data))")
logger.error("Unexpected data: \(type(of: data))")
}
if let result = result {
let path = ImageFormat.saveImage(image: result, directory: .cachesDirectory)
Expand Down Expand Up @@ -108,10 +108,12 @@ class ShareAttachment {
case let data as Data:
result = ImageFormat.loadImageFrom(data: data)
case let url as URL:
result = ImageFormat.loadImageFrom(url: url)
if let nsurl = NSURL(string: url.absoluteString) {
// scaleDownImage() uses less memory than core and avoids exhausing the 120 mb memory restriction of extensions (see #1330)
result = ImageFormat.scaleDownImage(nsurl, toMax: 1280)
}
default:
logger.debug("Unexpected data: \(type(of: data))")
result = nil
logger.error("Unexpected data: \(type(of: data))")
}
if let result = result,
let path = ImageFormat.saveImage(image: result, directory: .cachesDirectory) {
Expand Down Expand Up @@ -146,7 +148,7 @@ class ShareAttachment {

}
default:
logger.debug("Unexpected data: \(type(of: data))")
logger.error("Unexpected data: \(type(of: data))")
}
if let error = error {
logger.error("Could not load share item as video: \(error.localizedDescription)")
Expand Down Expand Up @@ -182,7 +184,7 @@ class ShareAttachment {
self.generateThumbnailRepresentations(url: url)
}
default:
logger.debug("Unexpected data: \(type(of: data))")
logger.error("Unexpected data: \(type(of: data))")
}
if let error = error {
logger.error("Could not load share item: \(error.localizedDescription)")
Expand Down Expand Up @@ -231,7 +233,7 @@ class ShareAttachment {
case let url as URL:
delegate.onUrlShared(url: url)
default:
logger.debug("Unexpected data: \(type(of: data))")
logger.error("Unexpected data: \(type(of: data))")
}
if let error = error {
logger.error("Could not share URL: \(error.localizedDescription)")
Expand Down