Fixed save and open images
This commit is contained in:
parent
5143fe7d45
commit
58b3abe5dd
|
|
@ -504,6 +504,10 @@ def open_file(widget=None):
|
|||
thetarfile.extractall(path=svlgui.SECURETEMPDIR)
|
||||
for i in svlgui.Library:
|
||||
if i.type=="Image":
|
||||
if not hasattr(i,'path'):
|
||||
i.val = svlgui.SECURETEMPDIR+"/"+i.val.split(os.sep)[-1]
|
||||
i.set_image(i.val)
|
||||
else:
|
||||
i.path = svlgui.SECURETEMPDIR+"/"+i.path.split(os.sep)[-1]
|
||||
i.set_image(i.path)
|
||||
if not hasattr(i, 'iname'):
|
||||
|
|
@ -529,6 +533,18 @@ def save_file(widget=None):
|
|||
lastpath = os.path.abspath(".")
|
||||
for i in svlgui.Library:
|
||||
if i.type=="Image":
|
||||
if not hasattr(i, 'path'):
|
||||
try:
|
||||
os.chdir(os.sep.join(i.val.split(os.sep)[:-1]) or i.origpath)
|
||||
i.val = i.val.split(os.sep)[-1]
|
||||
thetarfile.add(i.val.split(os.sep)[-1])
|
||||
except OSError:
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
os.chdir(tmpdir)
|
||||
i.pilimage.save(i.val)
|
||||
thetarfile.add(i.val)
|
||||
os.remove(i.val)
|
||||
else:
|
||||
print "i.path: ",i.path
|
||||
try:
|
||||
os.chdir(os.sep.join(i.path.split(os.sep)[:-1]) or i.origpath)
|
||||
|
|
@ -575,6 +591,10 @@ def import_to_stage(widget=None):
|
|||
for i in ("jpg","png","bmp"):
|
||||
if thefile.endswith(i):
|
||||
# im = svlgui.Image(thefile)
|
||||
if svlgui.PLATFORM=="osx":
|
||||
# sips is OSX's built-in image manipulation tool
|
||||
os.system("sips -s format png "+thefile+" --out "+svlgui.SECURETEMPDIR+"/"+thefile.split("/")[-1])
|
||||
thefile = svlgui.SECURETEMPDIR+"/"+thefile.split("/")[-1]
|
||||
im = box(100,100,200,200,svlgui.Color(thefile))
|
||||
print im.filled
|
||||
im.onMouseDown = onMouseDownObj
|
||||
|
|
|
|||
Loading…
Reference in New Issue