GIMP Chat http://gimpchat.com/ |
|
Working with unicode filenames http://gimpchat.com/viewtopic.php?f=9&t=19674 |
Page 1 of 1 |
Author: | ecs1749 [ Sat Oct 30, 2021 8:25 pm ] |
Post subject: | Working with unicode filenames |
I like to share with you my experience in handling unicode pathnames. I had trouble with this import os image_filename = pdb.gimp_image_get_filename(image) (fileroot,filename)=os.path.split(image_filename) fileroot+="\\output" if not os.path.isdir(fileroot): os.makedirs(fileroot) The code would fail if the filename contains unicode. The simple fix is to add a unicode conversion right after the image_get_filename and everything works. import os image_filename = pdb.gimp_image_get_filename(image) image_filename = unicode(image_filename, "utf-8", errors="ignore") (fileroot,filename)=os.path.split(image_filename) fileroot+="\\output" if not os.path.isdir(fileroot): os.makedirs(fileroot) I hope this is useful info to others. |
Page 1 of 1 | All times are UTC - 5 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |