hsnr-gamera / gamera-4

Gamera 4 for Python 3
GNU General Public License v2.0
10 stars 8 forks source link

to_pil/from_pil not reliable #35

Closed rmast closed 3 years ago

rmast commented 3 years ago

Conversion back and forth between PIL and Gamera-4 is more buggy than it was with hsnr-gamera for python 2.7.

Try this with Python 2 and Python 3:

from gamera.plugins.pil_io import from_pil as _from_pil
from gamera.core import Image
from PIL import Image as im
image = im.open('ycbcr-jpeg.tiff')
ycbcr = image.convert('RGB')
ycbcr.show()
gamera_image = _from_pil(ycbcr)
pil_image = gamera_image.to_pil()
pil_image.show()
python2 -m pip list
Package    Version
---------- -------
gamera     3.4.2
Pillow     6.2.1
python3 -m pip list
Package                                Version
-------------------------------------- --------------------
gamera                                 4.0rc0
Pillow                                 7.0.0

ycbcr-jpeg.zip

You'll see the picture is ok with python 2, but becomes a green mess with python 3.

rmast commented 3 years ago

@Cyperghost Olaf,

If I just return this file to the 2011 version

git checkout 173cbefd7046a526c9238c337c15dc75bef42924 ./include/plugins/string_io.hpp

and replace PyString by PyBytes the issue is solved.

So your changes introduced this issue. Are you able to resolve it?

rmast commented 3 years ago

@Cyperghost, I made a fork with commit 2d9877a on master for solving the issue to get didjvu to work with it again. The other commit should be forgotten. If you see the possibility of any improvements or a suggestion of writing automatic tests to prevent this in the future you're welcome.

@cdalitz, as you are still working on this repository, please state if you would like a pull-request.

cdalitz commented 3 years ago

@rmast Yes, please make a pull-request. Thanks you very much for looking into this issue!

rmast commented 3 years ago

Done