libvips / nip2

A spreadsheet-like GUI for libvips.
https://libvips.github.io/libvips/
GNU General Public License v2.0
362 stars 13 forks source link

How does the `resize` function work? #101

Closed mhirsch closed 3 years ago

mhirsch commented 3 years ago

In nipguide.pdf, p.49 it lists a resize function defined in _stdenv. In nip2 8.7.1 it's defined in my _stdenv.def file as

resize kernel xfac yfac image
        = oo_unary_function resize_op image, is_class image
        = resize_im image, is_image image
        = error (_ "bad arguments to " ++ "resize")

When I try to use it like resize Kernel_type.LINEAR 1.2 1.2 Image_new_item.Image_black_item.action I get an error:

Bad left hand side of '.'.

Apologies if I'm misunderstanding something. I'd like to iterate over a list of images and resize each one, where the scale factor is determined programmatically.

Thanks for your help!

jcupitt commented 3 years ago

Hi @mhirsch, you need:

resize (Kernel Kernel_type.LINEAR) 1.2 1.2 A1

Kernel_type.LINEAR is an enum which numbers / names / describes the basic kernel types. Kernel is the class, an instance of which you need to pass to resize.

mhirsch commented 3 years ago

Thanks!