pyvips
pyvips copied to clipboard
TypeError: don't know the size pointed to by 'void *'
Environment
- Vips:
vips-8.14.1 - pyvips: 2.2.1
- gcc
$ g++ --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
- cffi:
$pip show cffi
Name: cffi
Version: 1.15.1
Summary: Foreign Function Interface for Python calling C code.
Home-page: http://cffi.readthedocs.org
Author: Armin Rigo, Maciej Fijalkowski
Author-email: [email protected]
License: MIT
Location: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages
Requires: pycparser
Required-by: pyvips
Problem Description
Unable to write on TargetCustom
Sample Code
import os
import pyvips
from google.cloud import storage
from google.cloud.storage.fileio import BlobWriter, BlobReader
from pyvips import Image
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "gc_a.json"
source_client = storage.Client("a-project")
source_bucket = source_client.get_bucket("a-bucket")
source_file_path = "path/source.jpg"
source_blob = source_bucket.blob(source_file_path)
source_file: BlobReader = source_blob.open(mode="rb")
def read_handler(size):
return source_file.read(size)
source = pyvips.SourceCustom()
source.on_read(read_handler)
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "gc_b.json"
destination_client = storage.Client("b-project")
destination_bucket = destination_client.get_bucket("b-bucket")
destination_file_path = "path/dest.dz"
destination_blob = destination_bucket.blob(destination_file_path)
destination_file: BlobWriter = destination_blob.open(mode="wb")
def write_handler(chunk):
return destination_file.write(chunk)
def finish_handler():
destination_file.close()
target = pyvips.TargetCustom()
target.on_write(write_handler)
target.on_finish(finish_handler)
image: Image = pyvips.Image.new_from_source(source, '')
image.write_to_target(target, "dest.dz")
Traceback:
Exception ignored from cffi callback <function _marshal_write at 0x113177490>:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyvips/gobject.py", line 77, in _marshal_write
buf = ffi.buffer(pointer, length)
TypeError: don't know the size pointed to by 'void *'