Gif file import temporary hack

svn: r499
This commit is contained in:
Don Allingham 2001-10-20 01:35:48 +00:00
parent 3928629410
commit c5153af1c6
2 changed files with 13 additions and 13 deletions

View File

@ -259,7 +259,7 @@ class Gallery(ImageSelect):
try:
tfile,headers = u.retrieve(d)
except IOError, msg:
t = _("Counld not import %s") % d
t = _("Could not import %s") % d
GnomeErrorDialog("%s\n%s %d" % (t,msg[0],msg[1]))
return
@ -269,15 +269,20 @@ class Gallery(ImageSelect):
photo.setDescription(d)
photo.setLocal(1)
photo.setPath(tfile)
self.savephoto(photo)
self.db.addObject(photo)
oref = ObjectRef()
oref.setReference(photo)
self.dataobj.addPhoto(oref)
try:
name = RelImage.import_media_object(tfile,self.path,photo.getId())
id = photo.getId()
name = RelImage.import_media_object(tfile,self.path,id)
if name != None and name != "":
photo.setPath(name)
except:
photo.setPath(tfile)
w.drag_finish(context, TRUE, FALSE, time)
return
self.add_thumbnail(oref)
utils.modified()
else:
if self.db.getObjectMap().has_key(data.data):

View File

@ -65,15 +65,7 @@ def import_media_object(filename,path,base):
path = "%s/%s" % (thumb,base)
mk_thumb(filename,path,const.thumbScale)
if type == "image/jpeg":
shutil.copy(filename,name)
else:
if no_pil:
cmd = "%s '%s' '%s'" % (const.convert,filename,name)
os.system(cmd)
else:
PIL.Image.open(filename).save(name)
shutil.copy(filename,name)
except:
return None
else:
@ -123,12 +115,15 @@ def mk_thumb(source,dest,size):
GnomeErrorDialog(_("Could not create %s") % dir)
return
if no_pil:
print source[-3:]
if no_pil or source[-4:] == ".gif":
cmd = "%s -geometry %dx%d '%s' '%s'" % (const.convert,size,size,source,dest)
print cmd
os.system(cmd)
else:
try:
im = PIL.Image.open(source)
im.convert("RGB")
im.thumbnail((size,size))
im.save(dest,"JPEG")
except: