[gimp] plug-ins: openraster fix for non-ascii layer names
- From: Jon Nordby <jonnor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: openraster fix for non-ascii layer names
- Date: Sat, 5 Feb 2011 13:41:14 +0000 (UTC)
commit 54792780fc3014e8c0236e400301f4625259692f
Author: Martin Renold <martinxyz gmx ch>
Date: Sat Jan 22 14:00:01 2011 +0100
plug-ins: openraster fix for non-ascii layer names
Set the utf-8 filename flag in the ZIP.
Before, layer PNG filenames were stored with undefined coding,
causing most ZIP libraries to interpret it as cp437, if anything.
We now pass a unicode object to ziplib, which does the right thing.
plug-ins/pygimp/plug-ins/file-openraster.py | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/pygimp/plug-ins/file-openraster.py b/plug-ins/pygimp/plug-ins/file-openraster.py
index 4c4ae67..a6e07fe 100755
--- a/plug-ins/pygimp/plug-ins/file-openraster.py
+++ b/plug-ins/pygimp/plug-ins/file-openraster.py
@@ -111,7 +111,7 @@ def save_ora(img, drawable, filename, raw_filename):
for lay in img.layers:
x, y = lay.offsets
opac = lay.opacity / 100.0 # needs to be between 0.0 and 1.0
- add_layer(x, y, opac, lay, 'data/%s.png' % lay.name, lay.visible)
+ add_layer(x, y, opac, lay, 'data/%s.png' % lay.name.decode('utf-8'), lay.visible)
# save thumbnail
w, h = img.width, img.height
@@ -168,7 +168,13 @@ def load_ora(filename, raw_filename):
# create temp file. Needed because gimp cannot load files from inside a zip file
tmp = os.path.join(tempdir, 'tmp.png')
f = open(tmp, 'wb')
- f.write(orafile.read(path))
+ try:
+ data = orafile.read(path)
+ except KeyError:
+ # support for bad zip files (saved by old versions of this plugin)
+ data = orafile.read(path.encode('utf-8'))
+ print 'WARNING: bad OpenRaster ZIP file. There is an utf-8 encoded filename that does not have the utf-8 flag set:', repr(path)
+ f.write(data)
f.close()
# import layer, set attributes and add to image
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]