Skip to content

af_imageAspectScaled(size:) adds a white padding #417

@dvertovsek

Description

@dvertovsek

What did you do?

I called UIImage.af_imageAspectScaled(size: CGSize(2400, 2400))

What did you expect to happen?

IMG_0782

What happened instead?

white padding around the image

IMG_0781

AlamofireImage 3.5.2

If anyone encounters this problem:

Basically, replace the line inside UIImage.imageAspectScaled method

let origin = CGPoint(x: (size.width - scaledSize.width) / 2.0, y: (size.height - scaledSize.height) / 2.0)

with

let origin = .zero

AND

UIGraphicsBeginImageContextWithOptions(size, false, 0.0)

with

UIGraphicsBeginImageContextWithOptions(scaledSize, false, 0.0)

Can i add a PR ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions