GNOME Bugzilla – Bug 767603
Add sample use of the with-files macro to the Basic Batch tutorial
Last modified: 2018-09-21 16:02:47 UTC
With bug 726947, a new and easy way to apply script code to a list of files has been applied to the development branch of GIMP. This obsoletes most of the code in our Basic Batch tutorial examples, namely all the file-globing and looping through the results returned by the loop - the user can concentrate on writing the actual image-manipulation code and only has to worry about exporting and/or saving the modified image afterwards.
Info for documenters, here is the documentation comment for the macro, which already has some examples: ; Allow command line usage of GIMP such as: ; ; gimp -i -b '(with-files "*.png" <body>)' ; ; where <body> is the code that handles whatever processing you want to ; perform on the files. There are four variables that are available ; within the <body>: 'basename', 'image', 'filename' and 'layer'. ; The 'basename' is the name of the file with its extension removed, ; while the other three variables are self-explanatory. ; You basically write your code as though it were processing a single ; 'image' and the 'with-files' macro applies it to all of the files ; matching the pattern. ; ; For example, to invert the colors of all of the PNG files in the ; start directory: ; ; gimp -i -b '(with-files "*.png" (gimp-invert layer) \ ; (gimp-file-save 1 image layer filename filename ))' ; ; To do the same thing, but saving them as jpeg instead: ; ; gimp -i -b '(with-files "*.png" (gimp-invert layer) \ ; (gimp-file-save 1 image layer \ ; (string-append basename ".jpg") \ ; (string-append basename ".jpg") ))' Obviously the tutorial could go further and show even more goodies done with this macro! :-)
(In reply to Michael Schumacher from comment #0) > With bug 726947, a new and easy way to apply script code to a list of files > has been applied to the development branch of GIMP. > > This obsoletes most of the code in our Basic Batch tutorial examples, namely > all the file-globing and looping through the results returned by the loop - > the user can concentrate on writing the actual image-manipulation code and > only has to worry about exporting and/or saving the modified image > afterwards. What is the action item on this then? Do we need to revisit and re-write the Basic Batch tutorial?
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/Infrastructure/gimp-web/issues/65.