question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

image resize: unsupported gap

See original GitHub issue

Hello, I have a question about a discrepancy between the docs and the actual package. I want to use image resize with sending optional gap as it is referred to in docs, but it crashes with an error…

Package: 2.2.0 (from conda) Docs: https://libvips.github.io/pyvips/vimage.html?highlight=resize#pyvips.Image.resize image Code:

img = pyvips.Image.new_from_file(img_path).resize(0.05, gap=2.0).numpy()

Output:

opt/conda/lib/python3.7/site-packages/pyvips/vimage.py in call_function(*args, **kwargs)
   1345         @_add_doc(name)
   1346         def call_function(*args, **kwargs):
-> 1347             return pyvips.Operation.call(name, self, *args, **kwargs)
   1348 
   1349         return call_function

/opt/conda/lib/python3.7/site-packages/pyvips/voperation.py in call(operation_name, *args, **kwargs)
    287                     name not in intro.optional_output):
    288                 raise Error('{0} does not support optional argument {1}'
--> 289                             .format(operation_name, name))
    290 
    291             value = kwargs[name]

Error: resize does not support optional argument gap

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kleisaukecommented, Jul 24, 2022

I commented on https://github.com/conda-forge/pyvips-feedstock/pull/24#issuecomment-1193322009 to mention that pyvips should be backward compatible with older libvipses. Hopefully they will update it to v2.2.1.

1reaction
jcupittcommented, Jul 24, 2022

The python wrapper is (largely) generated at runtime, so the API you get is the API of the underlying libvips binary. Just drop in the libvips.so for 8.13 and you should get the new API.

The thumbnail operation knows about the various WSI formats and will pick the fastest resize method for you. For example, on this seven year old laptop:

john@kiwi:~/pics/openslide$ vipsheader CMU-3.mrxs 
CMU-3.mrxs: 109240x220696 uchar, 4 bands, srgb, openslideload
john@kiwi:~/pics/openslide$ time vipsthumbnail CMU-3.mrxs --size 2000

real	0m0.875s
user	0m1.036s
sys	0m0.075s
john@kiwi:~/pics/openslide$ vipsheader tn_CMU-3.jpg 
tn_CMU-3.jpg: 990x2000 uchar, 3 bands, srgb, jpegload

Or in python:

image = pyvips.Image.thumbnail("CMU-3.mrxs", 2000)
image.write_to_file("thumb.jpg")
Read more comments on GitHub >

github_iconTop Results From Across the Web

Catalog image resizing performance problems #8145 - GitHub
I ran bin/magento catalog:image:resize . I then ran your find pub/media/catalog/product/cache -type f -exec shasum {} \; | sort command, and ...
Read more >
MATLAB imresize - Resize image - MathWorks
Shrink the image to 40% of the original size using nearest-neighbor interpolation. This is the fastest method, but it has the lowest quality....
Read more >
Resize image with javascript canvas (smoothly) - Stack Overflow
The first one is a normal resized image tag, and the second one is canvas. Notice how the canvas one is not as...
Read more >
tf.image.resize | TensorFlow v2.11.0
Used in the notebooks. Resized images will be distorted if their original aspect ratio is not the same as size . To avoid...
Read more >
Resizing or Scaling -- IM v6 Examples - ImageMagick
However, many filters (even the default filters) can blur images slightly. It is part of their nature. So normally this 'short-circuit' for a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found