Comments (5)
This is expected behavior, as AlamofireImage uses the device's screen scale when decoding images. A 6000x3000 image will be 2000x1000 on a 3x device, like a Pro Max. Depending on your usage you should be able to disable the behavior.
from alamofireimage.
This is expected behavior, as AlamofireImage uses the device's screen scale when decoding images. A 6000x3000 image will be 2000x1000 on a 3x device, like a Pro Max. Depending on your usage you should be able to disable the behavior.
How I can disable this? Or maybe better question, do I want to disable this? Since I am using alamofireImage for downloading panorama and then showing it to the user. In terms of quality, I think it's better to have higher resolution images, but I don't want to overkill it with high quality image with big size when we talking about iPhone and iPad screens.
from alamofireimage.
Sorry, I should clarify. This setting simply sets the UIImage
's scale
property, it doesn't actually resize the image. You do need to be careful with very high res images, as the system can kill your app for using too much memory, or when the system is low on memory. The resolution you're seeing here is the "points" on the screen the UIImage
will appear, not the resolution of the underlying image.
Disabling it depends on how you're using AlamofireImage to download the image. What does your usage look like? Usually it's just a parameter for the responseImage
method.
from alamofireimage.
I was using this code:
let downloader = ImageDownloader()
let urlRequest = URLRequest(url: URL(string: "https://httpbin.org/image/jpeg")!)
downloader.download(urlRequest) { response in
print(response.request)
print(response.response)
debugPrint(response.result)
if case .success(let image) = response.result {
print(image)
}
}
So the downloader download the whole size image and then it rescale the image to the best scale for current device? Because I've recreated the original Alamofire request:
Future({ promise in
AF.download(
url,
method: .get,
encoding: JSONEncoding.default,
headers: nil,
to: self.destination)
.downloadProgress(closure: { (progress) in
//progress closure
})
.responseData(completionHandler: { (response) in
switch response.result {
case .success(let value):
promise(.success(value))
case .failure(let error):
promise(.failure(self.createError(response: response.response, AFerror: error, AFIerror: nil, data: response.value)))
}
})
})
To get the wholesize image as UIImage... but to be honest I cannot really see the difference between... My point is just to have a good quality panorama but in efficient way.
from alamofireimage.
No, as I said there is no resizing occurring. Instead, the UIImage
simply has its scale
set. From Apple's docs:
If you multiply the logical size of the image (stored in the size property) by the value in this property, you get the dimensions of the image in pixels.
There is no efficiency impact here, it only affects how the UIImage
is show in displays. If you want the UIImage
to be the original size, you can set the scale
to 1
. If you want to customize the scale
of the images you download using ImageDownloader
, you can pass an instance ImageResponseSerializer
initialized with an imageScale
of 1
.
downloader.download(urlRequest, serializer: .init(imageScale: 1)) { response in
// ...
}
I suggest you do some research into how to deal with large images on Apple's platforms. AlamofireImage can help you download, filter, and explicitly resize the images if you need but doesn't offer any help for efficiently displaying images. That's up to UIImage
and how you display it. You may be better off downloading the full resolution images to disk and using CoreGraphics to produce thumbnails as the user views the image, but you'll want to evaluate solutions appropriate to your use.
By the way, Alamofire already includes a DownloadResponsePublisher
, no need to wrap it in a Future
manually.
from alamofireimage.
Related Issues (20)
- Useless concurrent attribute for synchronizationQueue in AutoPurgingImageCache HOT 1
- Cannot find type 'ImageDownloader' in scope HOT 1
- how can I achieve an AutoPurgingImageCache with unlimited size? HOT 1
- Fix Package.swift and release 3.5.3 for older version use via SPM HOT 1
- Can't resolve dependencies starting on version 4.0.0 HOT 1
- unpredictable crash HOT 1
- Response Content-Type "text/plain" does not match any acceptable types HOT 1
- I
- Image is not cashing if we download image using ImageDownloader and restart the application HOT 2
- How do you cancel all pending and current image download requests in AlamofireImage? (Possible Feature Request) HOT 1
- Feature request: Support `image/avif` to Accept header for iOS 16, macOS Ventura and more. HOT 5
- App crash on ios 11.0.2, xcode 14.0.1 HOT 1
- Does AlamofireImage support resizing animated GIF? HOT 1
- Incorrect associatedObject use generates many Xcode 15 warnings HOT 2
- Is Alamofire image vulnerable to CVE-2023-4863 HOT 1
- ImageDownloader.download [EXC_BAD_ACCESS KERN_INVALID_ADDRESS]
- Apple Privacy Manifest HOT 10
- Customize interceptor on ImageDownloader's Session HOT 1
- Request for updated iOS SDK version with the xcprivacy manifest HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alamofireimage.