Results 1568 comments of John Cupitt

> Can you check how it's handled in pyvips? Yes, it's -1 in pyvips too. The -1 is a libvips thing, it's not part of the binding, so it'll be...

Hi @amtsak, That's interesting, I've never looked at pickling (obviously). I'll see if I can fix the error.

I fixed the obvious issue, but it's still not working. With git master pyvips I now see: ``` $ python3 Python 3.10.7 (main, Nov 24 2022, 19:45:47) [GCC 12.2.0] on...

I had a quick read and I don't think pyvips could ever support pickle. An image in pyvips is (behind the scenes) a pointer owned by a huge C library,...

I had a thought: perhaps you could just pass filenames into the multiprocessing function and do `new_from_file` there? It's very fast on slide images, so there's no real benefit to...

Yes, you'd need to generate quite a few tiles in the multiprocessing method to overcome the cost of the `new_from_file`.

There's an example using multiprocessing here: https://github.com/libvips/pyvips/blob/master/examples/thumb-dir.py Does that help? I'll have a look at your code.

Ah your code fails because you have a local function. You can only use global functions with pickle. Try making `extract_and_save_patch` into a top level definition.

I'd swap this code: ```python mask_w, mask_h = Image.open(mask_path).size resized_mask = vips.Image.new_from_file(mask_path).flatten() \ .colourspace("b-w").resize(w/mask_w, vscale=h/mask_h) ``` For `vips.thumbnail()`, it should be much faster. What format are your mask images in?...

You could probably make that a lot faster. Post a sample mask image and the size of the ndpi you are benchmarking with and I'll have a go at tuning...