Changeset 307
- Timestamp:
- 07/23/08 10:44:41 (6 months ago)
- Author:
- bob
- Message:
-
Fixed the PSD importation
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r303
|
r307
|
|
| 460 | 460 | |
| 461 | 461 | if filename.endswith('.psd'): |
| 462 | | from PythonMagick import Image |
| 463 | | img = Image(str(filename)) |
| | 462 | import PIL.Image |
| | 463 | img = PIL.Image.open(str(filename)) |
| 464 | 464 | base = str(filename[:-4]) + '.png' |
| 465 | 465 | import tempfile |
| 466 | | import os.path |
| 467 | | import os |
| 468 | 466 | import exceptions |
| 469 | | import glob |
| | 467 | import shutil |
| 470 | 468 | |
| 471 | 469 | tempdir = tempfile.gettempdir() |
| 472 | | infos = img.get_layer_names() |
| 473 | | infos = infos.split('\n') |
| 474 | | layers = [] |
| 475 | | for i in infos: |
| 476 | | n, x, y = i.split('|') |
| 477 | | x = int(x) |
| 478 | | y = int(y) |
| 479 | | layers.append((n, x, y)) |
| 480 | 470 | tempdir = tempdir + '/psd_outputs' |
| | 471 | shutil.rmtree(tempdir, ignore_errors=True) |
| | 472 | |
| 481 | 473 | try: os.mkdir(tempdir) |
| 482 | | except exceptions.OSError: |
| 483 | | for i in glob.glob(tempdir + '/*'): |
| 484 | | os.remove(i) |
| 485 | | |
| 486 | | img.write_files(tempdir + '/' + os.path.basename(base)) |
| | 474 | except: pass |
| | 475 | |
| | 476 | for index, layer in enumerate(img.layers): |
| | 477 | img.seek(index) |
| | 478 | img.save(join(tempdir, os.path.basename(base) + "_" + layer[0].decode('utf-8') + ".png")) |
| | 479 | |
| 487 | 480 | dlg = ib.ImageDialog(self, tempdir) |
| 488 | 481 | dlg.Centre() |
| 489 | 482 | |
| 490 | 483 | if dlg.ShowModal() == wx.ID_OK: |
| 491 | | import shutil |
| 492 | 484 | filename = wx.GetApp().frame.project.project_path + '/' + os.path.basename(dlg.GetFile()) |
| 493 | 485 | shutil.copyfile(dlg.GetFile(), filename) |
| … |
… |
|
| 498 | 490 | return |
| 499 | 491 | |
| 500 | | for i in glob.glob(tempdir + '/*'): |
| 501 | | os.remove(i) |
| 502 | | os.rmdir(tempdir) |
| | 492 | shutil.rmtree(tempdir, ignore_errors=True) |
| 503 | 493 | |
| 504 | | filename = filename.replace('\\', '\\\\') |
| 505 | 494 | nom = get_parent_class(self.iec.resource.__class__) |
| 506 | 495 | classe = res.get_class(nom) |
| 507 | 496 | c = classe.add_class(name, ["Animation"], [ |
| 508 | | "filenames = [u'" + filename + "']\n"]) |
| | 497 | "filenames = [" + repr(filename) + "]\n"]) |
| 509 | 498 | res.ast_has_changed = True |
| 510 | 499 | res.topy() |
| … |
… |
|
| 512 | 501 | wx.GetApp().artub_frame.update_treeitem(res) |
| 513 | 502 | self.iec.editorCtrl.SetValue(nom + '.' + name) |
| 514 | | import os |
| 515 | | if os.name != "posix": |
| | 503 | if os.name != "posix": # Hack |
| 516 | 504 | self.iec.editorCtrl.PopDown() |
| 517 | 505 | self.iec.propEditor.inspectorPost(False) |
| … |
… |
|
| 588 | 576 | self.cal.resource = self.resource |
| 589 | 577 | |
| 590 | | if value == "NoneType": value = "None" |
| 591 | 578 | self.editorCtrl.SetValue(value) |
| 592 | 579 | self.editorCtrl.SetPopupContent(self.win) |
Download in other formats:
|
|