--- This is just the first stepping stone to get Python3 support. The biggest blocker right now is the support of the binary string interface for encodeImage and decodeImage. The problem is described at http://www.swig.org/Doc3.0/Python.html#Python_nn77
This move to Python3 is necessary because Distributions start to drop Python2. And Python2 also has a schedule for EOL'ing this version. See https://pythonclock.org/ a not-so-very-suddle reminder. examples/test.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/test.py b/examples/test.py index 02271d3..5c8e349 100644 --- a/examples/test.py +++ b/examples/test.py @@ -8,19 +8,19 @@ import ExactImage image = ExactImage.newImage() if ExactImage.decodeImageFile (image, "testsuite/281-4.2.04.tif"): - print "image decoded all fine." + print("image decoded all fine.") else: - print "something went wrong ..." + print("something went wrong ...") exit if ExactImage.encodeImageFile (image, "test.jpg", 80, ""): - print "image written all fine." + print("image written all fine.") else: - print "something went wrong writing the image ..." + print("something went wrong writing the image ...") exit # advanced use, use in memory locations -f = open("testsuite/281-4.2.04.tif") +f = open("testsuite/281-4.2.04.tif", "rb") try: image_bits = f.read() @@ -28,39 +28,39 @@ finally: f.close() if ExactImage.decodeImage (image, image_bits): - print "image read from RAM." + print("image read from RAM.") else: - print "something went wrong decoding the RAM\n"; + print("something went wrong decoding the RAM\n") exit # image properties -print "Width: ", ExactImage.imageWidth (image) -print "Height: ", ExactImage.imageHeight (image) -print "Xres: ", ExactImage.imageXres (image) -print "Yres: ", ExactImage.imageYres (image) +print("Width: %u" % ExactImage.imageWidth (image)) +print("Height: %u" % ExactImage.imageHeight (image)) +print("Xres: %u" % ExactImage.imageXres (image)) +print("Yres: %u" % ExactImage.imageYres (image)) -print "Channels: ", ExactImage.imageChannels (image) -print "Channel depth: ", ExactImage.imageChannelDepth (image) +print("Channels: %u" % ExactImage.imageChannels (image)) +print("Channel depth: %u" % ExactImage.imageChannelDepth (image)) # setable as well ExactImage.imageSetXres (image, 144); ExactImage.imageSetYres (image, 144); -print "Xres: ", ExactImage.imageXres (image) -print "Yres: ", ExactImage.imageYres (image) +print("Xres: %u" % ExactImage.imageXres (image)) +print("Yres: %u" % ExactImage.imageYres (image)) # image data manipulation ExactImage.imageRotate (image, 90); ExactImage.imageScale (image, 4); ExactImage.imageBoxScale (image, .5); -image_bits = ExactImage.encodeImage (image, "jpeg", 80, ""); -print "size: ", len(image_bits) +image_bits = ExactImage.encodeImage (image, "jpeg", 80, "") +print("size: %u" % len(image_bits)) -f = open("python.jpg", "w") +f = open("python.jpg", "wb") try: image_bits = f.write(image_bits) -- 2.20.1
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [email protected] with a subject of: unsubscribe exact-image
