Zdravim, potrebujem v pythone robit s viacstrankovymi tiff subormi a po roznych testoch a googlovani som skoncil na tom, ze cisto python riesenie neexistuje. Najrozumnejsie sa mi javi pouzitie ctypes a kniznice leptonica. Problem je v tom, ze v niektorych pripadoch jej potrebujem posunut file object.
Napr. (C kod): filein = "phototest.tif"; fp = fopen(filein, "r"); tiffGetCount(fp, &npages); fprintf(stderr, " Tiff: %d pages\n", npages); fclose(fp); Ked to skusim spravit v pythone, tak dostanem chybu: import ctypes leptonica = ctypes.CDLL("liblept.so") filein = "phototest.tif" fp = open(filein, "r") npages = leptonica.tiffGetCount(fp) Traceback (most recent call last): File "<stdin>", line 1, in <module> ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't know how to convert parameter 1 Skusal som to aj cez PyFile_AsFile ale to tiez skonci s chybou: >>> import ctypes as C >>> lib = C.CDLL("liblept.so") >>> class FILE(C.Structure): ... pass ... >>> FILE_P = C.POINTER(FILE) >>> C.pythonapi.PyFile_AsFile.argtypes = [C.py_object] >>> C.pythonapi.PyFile_AsFile.restype = FILE_P >>> fp = C.pythonapi.PyFile_AsFile("phototest.tif") >>> npages = lib.tiffGetCount(fp) Error in tiffGetCount: stream not defined Skusal som googlovat, ale sa nic funkcne sa mi nepodarilo zostavit... Vie mi s tym niekto pomoc? Zd.
_______________________________________________ Python mailing list Python@py.cz http://www.py.cz/mailman/listinfo/python