Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Region.fetch operator yields unexpected buffer size when operating on a .v image #103

Closed
erdmann opened this issue Jun 8, 2019 · 3 comments

Comments

@erdmann
Copy link
Contributor

erdmann commented Jun 8, 2019

Hi John,

I'm experimenting with the new Region.fetch functionality, and I encountered an unexpected result. When I operate from a pipeline, it behaves as expected, but when operating from a .v file opened directly, it gives nonsensical buffer lengths:

import pyvips # version 2.1.6

b = pyvips.Image.black(1000, 1000)
reg = pyvips.Region.new(b)
print('buffer len from pipeline: ', len(reg.fetch(0, 0, 100, 100)))
b.write_to_file('black.v')


v_file = pyvips.Image.new_from_file('black.v')
reg2 = pyvips.Region.new(v_file)
print('buffer len from v file: ', len(reg2.fetch(0, 0, 100, 100)))

print('v_file:', v_file)

reg3 = pyvips.Region.new(v_file.cast('uchar'))
print('buffer len from v file in a do-nothing pipeline: ', len(reg3.fetch(0, 0, 100, 100)))

The result is as follows:

buffer len from pipeline:  10000 # expected
buffer len from v file:  356000 # unexpected
v_file: <pyvips.Image 1000x1000 uchar, 1 bands, multiband>
buffer len from v file in a do-nothing pipeline:  10000 # expected

Many thanks in advance for taking a look.

@jcupitt
Copy link
Member

jcupitt commented Jun 8, 2019

Oh hmm yes you're right, it won't work properly in cases like that.

I'll have a think.

@jcupitt
Copy link
Member

jcupitt commented Jun 9, 2019

OK, 8.8.1 should have this fix. Thanks!

jcupitt added a commit to libvips/libvips that referenced this issue Jun 10, 2019
we weren't clipping the fetch area against region valid, so in some
cases we could return many more pixels than expected

see libvips/pyvips#103
@erdmann
Copy link
Contributor Author

erdmann commented Jun 12, 2019

Works for me now. Thanks again!

@erdmann erdmann closed this as completed Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants