Skip to content

Downsampling and scale #365

@InkyTsar

Description

@InkyTsar

Hello,
what is the correct way to handle scale and downsampling via SDImageResizingTransformer?

I noticed a large usage of RAM memory when loading images in my app. When I applied downsampling as below, the usage got 9x lower (as the math suggests) but now I am worried about the image quality (I haven't tested it for any differences yet). I would like to hear how such case is handled correctly.

Let's say I have an URL to 600x900 image and a view with .frame(width: 200, height: 300).

  1. Should I multiply the CGSize by UIScreen.main.scale or just leave it 200x300?
  2. Should I even use the .imageScaleFactor param? Is UIScreen.main.scale correct here?
  3. Should I use .scaleDownLargeImages option? I haven't noticed any difference here.
        WebImage(
            url: url,
            options: [.scaleDownLargeImages], // should I use it?
            context: [
                .imageScaleFactor: UIScreen.main.scale, // 2 or 3, depending on the device
                .imageTransformer: SDImageResizingTransformer(
                    size: CGSize(width: 200, height: 300),
                    scaleMode: .aspectFit
                )
            ]
        )

BR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions