8000 Any way to constrain width, but not height? · Issue #150 · libvips/ruby-vips · GitHub
[go: up one dir, main page]

Skip to content
Any way to constrain width, but not height? #150
Closed
@kaspergrubbe

Description

@kaspergrubbe

Hi!

Is it possible to thumbnail or scale images with the --size argument described here

https://jcupitt.github.io/libvips/API/current/Using-vipsthumbnail.md.html

and here

https://github.com/jcupitt/libvips/issues/781 ?

Right now I am seeing something strange with the #thumbnail-method. Basically I have a 600x647 image that I want to scale down to a width of 100 (I do not care about height).

image = Vips::Image.new_from_file(stored_image.file.path)
=> #<Image 600x647 uchar, 4 bands, srgb>

image = image.thumbnail_image(100)
VIPS-INFO: selected loader is image source
VIPS-INFO: input size is 600 x 647
VIPS-INFO: converting to processing space srgb
VIPS-INFO: premultiplying alpha
VIPS-INFO: shrinkv by 3
VIPS-INFO: shrinkh by 3
VIPS-INFO: residual reducev by 0.463679
VIPS-INFO: reducev: 14 point mask
VIPS-INFO: residual reduceh by 0.463679
VIPS-INFO: reduceh: 14 point mask
VIPS-INFO: unpremultiplying alpha
=> #<Image 93x100 uchar, 4 bands, srgb>

image = image.thumbnail_image(100, height: 108)
VIPS-INFO: selected loader is image source
VIPS-INFO: input size is 93 x 100
VIPS-INFO: converting to processing space srgb
VIPS-INFO: premultiplying alpha
VIPS-INFO: residual scale 1.07527 x 1.07527
VIPS-INFO: unpremultiplying alpha
=> #<Image 100x108 uchar, 4 bands, srgb>

I think I understand the reason why #thumbnail_image(100) does not have a width of 100, and it is because it is interpreted as a box of 100x100, and then Vips will try to satisfy that.

So I guess what I want is to pass 100x (as discussed in the Github issue), but is there any way to achieve that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0