8000 vips_thumbnail: Prefer width over height or vice versa · Issue #709 · libvips/libvips · GitHub
[go: up one dir, main page]

Skip to content
vips_thumbnail: Prefer width over height or vice versa #709
Open
@kleisauke

Description

@kleisauke

I like to see a (optional) prefer option in vips_thumbnail which can be set to a new enum (let's call it VIPS_PREFER_WIDTH or VIPS_PREFER_HEIGHT for example).

Use case scenario:
To prevent reduction or enlargement in the horizontal axis, I'm setting the target resize width to VIPS_MAX_COORD (which is currently 10000000), when a user only have specified a fixed height. I'm doing vice versa for the target resize height (so setting it to VIPS_MAX_COORD when a fixed width is specified). This feels somewhat hackish.

Example which currently fails due to reduction in the vertical axis (the dimensions of the input JPEG-file are 1600x622):
https://gist.github.com/kleisauke/8e090b4f83679cd536cd3bc7aebe60a2

thumbnail width = 499
expected width = 500
thumbnail height = 194
expected height = 194

This is fixable if we change the script to this:
https://gist.github.com/kleisauke/a7df1817fa7ed8f01a627a7eccd342c4

thumbnail width = 500
expected width = 500
thumbnail height = 194
expected height = 194

When a prefer option is in vips_thumbnail we can do:
https://gist.github.com/kleisauke/1dc424dfdf1b2b65192be4189a4c6364

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

      0