John Cupitt
John Cupitt
Don't use `thumbnail_image` -- it's much slower than `thumbnail`. You can open an image with `new_from_file` and then check `vips-loader` to get the file type: ``` >>> import pyvips >>>...
`new_from_buffer` is very quick -- you can do it just to get the image type. ```python #!/usr/bin/python3 # test with: # https://upload.wikimedia.org/wikipedia/en/b/b4/Sceicbia.jpg # https://upload.wikimedia.org/wikipedia/commons/6/69/F4-motion.gif import sys import requests import pyvips...
There's some demo code here: https://github.com/libvips/libvips/issues/1167#issuecomment-440598247 You'd need to run that after `thumbnail`.
Hello @zhaohuxing, Your libvips is probably too old. Do you know what version you are using?
Ooops, sorry, it should be: ```python x = pyvips.Image.thumbnail("3198.gif[n=-1]", 128) ```
Sorry, I should not post untested code. Here's a complete working program to thumbnail URLs, including animated images: ```python #!/usr/bin/python3 # test with: # https://upload.wikimedia.org/wikipedia/en/b/b4/Sceicbia.jpg # https://upload.wikimedia.org/wikipedia/commons/6/69/F4-motion.gif import sys import...
When you load an animated image, pyvips will just give you the first frame. You can select the number of frames to load with `n=` (1 meaning load 1 frame)...
I would use `thumbnail`. It has the extra logic for resizing animated images.
I had this example, it might help: ```C /* Compile with: * * gcc -g -Wall buffer.c `pkg-config vips --cflags --libs` */ #include #include #include int main( int argc, char...
There's an argument called `option_string` you can use to pass extra flags to the loader. In C: ```C vips_thumbnail_buffer( data, length, &image, 200, "option_string", "n=-1", NULL ) ``` Now I...