Check for image load failure
svn: r69
This commit is contained in:
parent
b16ceb6be1
commit
ad0d5d0415
@ -26,6 +26,7 @@
|
|||||||
import os
|
import os
|
||||||
import const
|
import const
|
||||||
import intl
|
import intl
|
||||||
|
from gnome.ui import *
|
||||||
|
|
||||||
_ = intl.gettext
|
_ = intl.gettext
|
||||||
|
|
||||||
@ -76,11 +77,18 @@ def import_photo(filename,path,prefix):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def scale_image(path,size):
|
def scale_image(path,size):
|
||||||
import GdkImlib
|
import GdkImlib
|
||||||
|
|
||||||
|
try:
|
||||||
|
image1 = GdkImlib.Image(path)
|
||||||
|
except:
|
||||||
|
GnomeWarningDialog(_("Could load load image file %s") % path)
|
||||||
|
return
|
||||||
|
|
||||||
image1 = GdkImlib.Image(path)
|
|
||||||
width = image1.rgb_width
|
width = image1.rgb_width
|
||||||
height = image1.rgb_height
|
height = image1.rgb_height
|
||||||
|
|
||||||
scale = size / float(max(width,height))
|
scale = size / float(max(width,height))
|
||||||
image2 = image1.clone_scaled_image(int(scale*width), int(scale*height))
|
image2 = image1.clone_scaled_image(int(scale*width), int(scale*height))
|
||||||
return image2
|
return image2
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user