From bf438cddd6ffe64f338f6d0ee60ec8a8e873d0db Mon Sep 17 00:00:00 2001 From: Helge Herz Date: Wed, 27 Feb 2013 22:24:14 +0000 Subject: [PATCH] Python less 3.x uses GdkPixbuf.new_subpixbuf instead dkPixbuf.subpixbuf issue 6487 svn: r21477 --- gramps/gen/utils/image.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/gramps/gen/utils/image.py b/gramps/gen/utils/image.py index 5ec6b679b..5a6b0a24e 100644 --- a/gramps/gen/utils/image.py +++ b/gramps/gen/utils/image.py @@ -31,6 +31,7 @@ Image manipulation routines. # #------------------------------------------------------------------------- import os +import sys import tempfile #------------------------------------------------------------------------- @@ -78,7 +79,10 @@ def resize_to_jpeg(source, destination, width, height, crop=None): end_x = int((crop[2]/100.0)*img.get_width()) end_y = int((crop[3]/100.0)*img.get_height()) - img = img.subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) + if sys.version_info[0] < 3: + img = img.new_subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) + else: + img = img.subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) # Need to keep the ratio intact, otherwise scaled images look stretched # if the dimensions aren't close in size @@ -209,8 +213,11 @@ def resize_to_buffer(source, size, crop=None): end_x = int((crop[2]/100.0)*img.get_width()) end_y = int((crop[3]/100.0)*img.get_height()) - img = img.subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) - + if sys.version_info[0] < 3: + img = img.new_subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) + else: + img = img.subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) + # Need to keep the ratio intact, otherwise scaled images look stretched # if the dimensions aren't close in size (size[0], size[1]) = image_actual_size(size[0], size[1], img.get_width(), img.get_height()) @@ -249,7 +256,10 @@ def resize_to_jpeg_buffer(source, size, crop=None): end_x = int((crop[2]/100.0)*img.get_width()) end_y = int((crop[3]/100.0)*img.get_height()) - img = img.subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) + if sys.version_info[0] < 3: + img = img.new_subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) + else: + img = img.subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) # Need to keep the ratio intact, otherwise scaled images look stretched # if the dimensions aren't close in size