Skip to content

Possible logic error in scaling ('encodeMaxPixelSize' option) #64

@AlexDjr

Description

@AlexDjr

Hi!
I'm using SDWebImageWebPCoder to convert my images to WEBP and have stumbled upon what looks like a logic error in scaling with encodeMaxPixelSize option.

The case looks like this:

  • I have an image with size of 1253x403 and I'm trying to scale it to fit in 512x512 size

image

  • and it does nothing, the image's size remains 1253x403

  • I checked the code and found line 871 in SDImageWebPCoder:

image

What it says is that width and height of an image should be both larger than respective size values of encodeMaxPixelSize option. So in my case I don't meet this condition because my height (403) is smaller than 512.

Shouldn't it be OR instead of AND in this condition?
image

For my case such fix works correctly: 1253x403 image has been scaled to 512x165 size

Please guide me if I'm missing something about this logic

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