Whitlisting file inputs - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: Whitlisting file inputs (/Thread-Whitlisting-file-inputs) |
Whitlisting file inputs - radzo73 - 12-22-2019 Hey, I have a script that takes all the files in a folder, crops them, and exports them. However, it tries to take things in that folder that aren't images (text files, pesky invisible metadata files) and tries to edit them, which throws an error. How do I fix that? RE: Whitlisting file inputs - Ofnuts - 12-22-2019 Just skip files with a extension which isn't PNG, something like: Code: filename,fileext = os.path.splitext(element) # replaces a line of yours You can also more directly get the files you need: Code: import glob Unless I'm mistaken the file_mask is always the same, so this will always yield the same result: Code: # Add mask to new layer over image So you can do it once for all, opening the mask as a separate image, that you discard once you have the values. RE: Whitlisting file inputs - radzo73 - 12-22-2019 Thanks for the ideas! However when you mentioned Code: filename,fileext = os.path.splitext(element) # replaces a line of yours nvm, got it working. Again, thanks! |