Open maqsudinamdar opened 1 year ago
Hi again,
I can't reproduce your problem, so I can't fix it. You need to post a complete, runnable program I can test. What cffi are you using, what python version are you using, what platform are you using, what C compiler are you using, how did you install pyvips (ABI or API mode) etc.
There have been some changes to void*
use in libvips 8.14.2 which might help, see: https://github.com/libvips/libvips/pull/3383
Sample code:
#!/usr/bin/python3
import sys
import pyvips
image = pyvips.Image.new_from_file(sys.argv[1], access="sequential")
file = open(sys.argv[2], "wb")
def write_handler(chunk):
return file.write(chunk)
def end_handler():
# you can't throw exceptions over on_ handlers, you must return an
# error code
try:
file.close()
except IOError:
return -1
else:
return 0
target = pyvips.TargetCustom()
target.on_write(write_handler)
target.on_end(end_handler)
image.write_to_target(target, ".dz")
Run like this:
$ ./targetsave2.py ~/pics/k2.jpg x
$ file x
x: Zip archive data, at least v4.5 to extract, compression method=store
libvips 8.14.1, python 3.10 in API mode, cffi 1.15.1, gcc 12, ubuntu 22.10.
Environment
vips-8.14.1
Problem Description
Unable to write on TargetCustom
Sample Code
Traceback:
Edit:
vips
using brew command [link]pyvips
using API mode [link]