Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def save_load_buffer(self, saver, loader, im, max_diff=0, **kwargs):
buf = pyvips.Operation.call(saver, im, **kwargs)
x = pyvips.Operation.call(loader, buf)
assert im.width == x.width
assert im.height == x.height
assert im.bands == x.bands
assert (im - x).abs().max() <= max_diff
def save_load_buffer(self, saver, loader, im, max_diff=0, **kwargs):
buf = pyvips.Operation.call(saver, im, **kwargs)
x = pyvips.Operation.call(loader, buf)
assert im.width == x.width
assert im.height == x.height
assert im.bands == x.bands
assert (im - x).abs().max() <= max_diff
def file_loader(self, loader, test_file, validate):
im = pyvips.Operation.call(loader, test_file)
validate(im)
im = pyvips.Image.new_from_file(test_file)
validate(im)
def save_buffer_tempfile(self, saver, suf, im, max_diff=0):
filename = temp_filename(self.tempdir, suf)
buf = pyvips.Operation.call(saver, im)
f = open(filename, 'wb')
f.write(buf)
f.close()
x = pyvips.Image.new_from_file(filename)
assert im.width == x.width
assert im.height == x.height
assert im.bands == x.bands
assert (im - x).abs().max() <= max_diff
def save_load_buffer(self, saver, loader, im, max_diff=0, **kwargs):
buf = pyvips.Operation.call(saver, im, **kwargs)
x = pyvips.Operation.call(loader, buf)
assert im.width == x.width
assert im.height == x.height
assert im.bands == x.bands
assert (im - x).abs().max() <= max_diff