Gif file import temporary hack
svn: r499
This commit is contained in:
parent
3928629410
commit
c5153af1c6
@ -259,7 +259,7 @@ class Gallery(ImageSelect):
|
|||||||
try:
|
try:
|
||||||
tfile,headers = u.retrieve(d)
|
tfile,headers = u.retrieve(d)
|
||||||
except IOError, msg:
|
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]))
|
GnomeErrorDialog("%s\n%s %d" % (t,msg[0],msg[1]))
|
||||||
return
|
return
|
||||||
@ -269,15 +269,20 @@ class Gallery(ImageSelect):
|
|||||||
photo.setDescription(d)
|
photo.setDescription(d)
|
||||||
photo.setLocal(1)
|
photo.setLocal(1)
|
||||||
photo.setPath(tfile)
|
photo.setPath(tfile)
|
||||||
self.savephoto(photo)
|
self.db.addObject(photo)
|
||||||
|
oref = ObjectRef()
|
||||||
|
oref.setReference(photo)
|
||||||
|
self.dataobj.addPhoto(oref)
|
||||||
try:
|
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 != "":
|
if name != None and name != "":
|
||||||
photo.setPath(name)
|
photo.setPath(name)
|
||||||
except:
|
except:
|
||||||
photo.setPath(tfile)
|
photo.setPath(tfile)
|
||||||
w.drag_finish(context, TRUE, FALSE, time)
|
w.drag_finish(context, TRUE, FALSE, time)
|
||||||
return
|
return
|
||||||
|
self.add_thumbnail(oref)
|
||||||
utils.modified()
|
utils.modified()
|
||||||
else:
|
else:
|
||||||
if self.db.getObjectMap().has_key(data.data):
|
if self.db.getObjectMap().has_key(data.data):
|
||||||
|
@ -65,15 +65,7 @@ def import_media_object(filename,path,base):
|
|||||||
path = "%s/%s" % (thumb,base)
|
path = "%s/%s" % (thumb,base)
|
||||||
|
|
||||||
mk_thumb(filename,path,const.thumbScale)
|
mk_thumb(filename,path,const.thumbScale)
|
||||||
|
|
||||||
if type == "image/jpeg":
|
|
||||||
shutil.copy(filename,name)
|
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)
|
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
@ -123,12 +115,15 @@ def mk_thumb(source,dest,size):
|
|||||||
GnomeErrorDialog(_("Could not create %s") % dir)
|
GnomeErrorDialog(_("Could not create %s") % dir)
|
||||||
return
|
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)
|
cmd = "%s -geometry %dx%d '%s' '%s'" % (const.convert,size,size,source,dest)
|
||||||
|
print cmd
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
im = PIL.Image.open(source)
|
im = PIL.Image.open(source)
|
||||||
|
im.convert("RGB")
|
||||||
im.thumbnail((size,size))
|
im.thumbnail((size,size))
|
||||||
im.save(dest,"JPEG")
|
im.save(dest,"JPEG")
|
||||||
except:
|
except:
|
||||||
|
Loading…
Reference in New Issue
Block a user