From 73b3ccbd0e4f9bc5b27d42eea46a39551330dc55 Mon Sep 17 00:00:00 2001 From: Josip Date: Fri, 8 Jan 2016 20:55:20 -0800 Subject: [PATCH] 9122: Complete Report about person (whole database) - PDF - crash --- gramps/gen/utils/image.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gramps/gen/utils/image.py b/gramps/gen/utils/image.py index 246a47690..4cc246b08 100644 --- a/gramps/gen/utils/image.py +++ b/gramps/gen/utils/image.py @@ -89,7 +89,9 @@ def resize_to_jpeg(source, destination, width, height, crop=None): (start_x, start_y, end_x, end_y ) = crop_percentage_to_pixel( img.get_width(), img.get_height(), crop) - img = img.new_subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) + if end_x-start_x > 0 and end_y-start_y > 0: + img = img.new_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 @@ -227,7 +229,9 @@ def resize_to_buffer(source, size, crop=None): (start_x, start_y, end_x, end_y ) = crop_percentage_to_pixel( img.get_width(), img.get_height(), crop) - img = img.new_subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) + if end_x-start_x > 0 and end_y-start_y > 0: + img = img.new_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 @@ -264,8 +268,9 @@ def resize_to_jpeg_buffer(source, size, crop=None): (start_x, start_y, end_x, end_y ) = crop_percentage_to_pixel( img.get_width(), img.get_height(), crop) - - img = img.new_subpixbuf(start_x, start_y, end_x-start_x, end_y-start_y) + if end_x-start_x > 0 and end_y-start_y > 0: + img = img.new_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