Re: [Gimp-user] Script-fu in GIMP - and batch processing.
On 2021-06-09 11:22 a.m., ludo0...@dbmail.com wrote: (let* ((filename (car filelist)) (filenamenew (string-append (car filelist) "-new")) ; as well as (filenamenew (string-append filename "-new")) (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) (drawable (car (gimp-image-get-active-layer image (plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable radius amount threshold) (gimp-file-save RUN-NONINTERACTIVE image drawable filenamenew filenamenew) [snip] calling the programme with this command: gimp -i -b '(batch-unsharp-mask "*.JPG" 5.0 0.5 0)' -b '(gimp-quit 0)' Unfortunately I did not have the expected success, as I got this result: batch command experienced an execution error: Error: Procedure execution of gimp-file-save failed: unknown file type If the first entry in the list is "somefile.JPG" what you have above will attempt to save out a new version with the name "somefile.JPG-new". What you need to do is get the root filename "somefile" and append "-new.JPG" to create the new filename of "somefile-new.JPG". The simplest way to handle the situation is to read the files from one directory and save the modified version to another. The not so easy method is to split the string on the . in the filename in to "simefile" and ".JPG" so you can create a string with the new name for the modified file. -- Cheers! Kevin. http://www.ve3syb.ca/ | "Nerds make the shiny things that https://www.patreon.com/KevinCozens | distract the mouth-breathers, and | that's why we're powerful" Owner of Elecraft K2 #2172 | #include | --Chris Hardwick ___ gimp-user-list mailing list List address:gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list List archives: https://mail.gnome.org/archives/gimp-user-list
Re: [Gimp-user] Script-fu in GIMP - and batch processing.
Hello everyone, I tried this: (define (batch-unsharp-mask pattern radius amount threshold) (let* ((filelist (cadr (file-glob pattern 1 (while (not (null? filelist)) (let* ((filename (car filelist)) (filenamenew (string-append (car filelist) "-new")) ; as well as (filenamenew (string-append filename "-new")) (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) (drawable (car (gimp-image-get-active-layer image (plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable radius amount threshold) (gimp-file-save RUN-NONINTERACTIVE image drawable filenamenew filenamenew) (gimp-image-delete image)) (set! filelist (cdr filelist) calling the programme with this command: gimp -i -b '(batch-unsharp-mask "*.JPG" 5.0 0.5 0)' -b '(gimp-quit 0)' Unfortunately I did not have the expected success, as I got this result: batch command experienced an execution error: Error: Procedure execution of gimp-file-save failed: unknown file type It looks like this variable I call "filenamenew" is not accepted. I don't know if it's because of my GIMP version (2.10.8 for Debian GNU-Linux 10)... But well, anyway, I don't mind anymore. I was just trying to face a challenge, but I can get around and avoid it: I'll just accept that my edited files do not get a new name; I will just have to keep the originals stored elsewhere, so no need to bother... So, thanks very much to all of you for your suggestions, I really appreciated you taking my question seriously. Cheers. Ludo Message: 3 Date: Sun, 30 May 2021 13:30:26 -0400 From: Kevin Cozens <mailto:ke...@ve3syb.ca> To: gimp-user-list@gnome.org<mailto:gimp-user-list@gnome.org> Subject: Re: [Gimp-user] Script-fu in GIMP - and batch processing. Message-ID: <94e20ccd-ee8a-aa44-9d8b-3a0ef6ad8...@ve3syb.ca><mailto:94e20ccd-ee8a-aa44-9d8b-3a0ef6ad8...@ve3syb.ca> Content-Type: text/plain; charset=utf-8; format=flowed On 2021-05-15 11:45 a.m., ludo0...@dbmail.com<mailto:ludo0...@dbmail.com> wrote: Then I tried with this: [snip] ?? ??? ? (filenamenew (+ "(car filelist)" "-new")) [snip] But that didn't work either, because the argument to " + " (sum) must be a number. The problem with that line is that you are passing two strings to + instead of passing numbers to it. The + symbol means add two numbers together. What you want is string concatenation. Try the following: (filenamenew (string-append (car filelist) "-new")) -- Cheers! Kevin. http://www.ve3syb.ca/ | "Nerds make the shiny things that https://www.patreon.com/KevinCozens | distract the mouth-breathers, and | that's why we're powerful" Owner of Elecraft K2 #2172 | #include | --Chris Hardwick ___ gimp-user-list mailing list List address:gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list List archives: https://mail.gnome.org/archives/gimp-user-list
Re: [Gimp-user] Script-fu in GIMP - and batch processing.
You can write your scripts in Python, this can be simpler to master: https://stackoverflow.com/questions/44430081/how-to-run-python-scripts-using-gimpfu-from-windows-command-line/44435560#44435560 On 30/05/2021 10:14, ludo0565 wrote: Hello Robbie, First of all I present my excuses to you: My mail box placed your mail in spam - and I only saw it yesterday. So thanks a lot for your answer. It's not so easy to find someone interested in a question about scheme & script-fu ... ;-) I'll try this as soon as I get time - which is pretty scarce at the moment... unfortunately. And I I'll let you know as soon as I do. Thanks again. ludo Le 26 mai 2021 00:26:56 GMT+02:00, Robbie Huffman a écrit : On Sat, May 15, 2021 at 05:45:47PM +0200, ludo0...@dbmail.com wrote: Then I tried with this: (define (batch-unsharp-mask pattern radius amount threshold filenamenew) (let* ((filelist (cadr (file-glob pattern 1 (while (not (null? filelist)) (let* ((filename (car filelist)) (filenamenew (+ "(car filelist)" "-new")) (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) (drawable (car (gimp-image-get-active-layer image (plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable radius amount threshold) (gimp-file-save RUN-NONINTERACTIVE image drawable filenamenew filenamenew) (gimp-image-delete image)) (set! filelist (cdr filelist) But that didn't work either, because the argument to " + " (sum) must be a number. I think you could (string-append filename "-new") to get something that works OK. ___ gimp-user-list mailing list List address:gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list List archives: https://mail.gnome.org/archives/gimp-user-list
Re: [Gimp-user] Script-fu in GIMP - and batch processing.
On 2021-05-15 11:45 a.m., ludo0...@dbmail.com wrote: Then I tried with this: [snip] (filenamenew (+ "(car filelist)" "-new")) [snip] But that didn't work either, because the argument to " + " (sum) must be a number. The problem with that line is that you are passing two strings to + instead of passing numbers to it. The + symbol means add two numbers together. What you want is string concatenation. Try the following: (filenamenew (string-append (car filelist) "-new")) -- Cheers! Kevin. http://www.ve3syb.ca/ | "Nerds make the shiny things that https://www.patreon.com/KevinCozens | distract the mouth-breathers, and | that's why we're powerful" Owner of Elecraft K2 #2172 | #include | --Chris Hardwick ___ gimp-user-list mailing list List address:gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list List archives: https://mail.gnome.org/archives/gimp-user-list
Re: [Gimp-user] Script-fu in GIMP - and batch processing.
Hello Robbie, First of all I present my excuses to you: My mail box placed your mail in spam - and I only saw it yesterday. So thanks a lot for your answer. It's not so easy to find someone interested in a question about scheme & script-fu ... ;-) I'll try this as soon as I get time - which is pretty scarce at the moment... unfortunately. And I I'll let you know as soon as I do. Thanks again. ludo Le 26 mai 2021 00:26:56 GMT+02:00, Robbie Huffman a écrit : >On Sat, May 15, 2021 at 05:45:47PM +0200, ludo0...@dbmail.com wrote: >> Then I tried with this: >> >> (define (batch-unsharp-mask pattern radius amount threshold >filenamenew) >> (let* ((filelist (cadr (file-glob pattern 1 >> (while (not (null? filelist)) >> (let* ((filename (car filelist)) >> (filenamenew (+ "(car filelist)" "-new")) >> (image (car (gimp-file-load RUN-NONINTERACTIVE >filename filename))) >> (drawable (car (gimp-image-get-active-layer >image >> (plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable >radius amount threshold) >> (gimp-file-save RUN-NONINTERACTIVE image drawable >filenamenew filenamenew) >> (gimp-image-delete image)) >> (set! filelist (cdr filelist) >> >> But that didn't work either, because the argument to " + " (sum) must >be a number. > >I think you could (string-append filename "-new") to get something that >works OK. -- Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté. ___ gimp-user-list mailing list List address:gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list List archives: https://mail.gnome.org/archives/gimp-user-list
[Gimp-user] Script-fu in GIMP - and batch processing.
Hello everyone, As a user of GIMP 2.10, I am at the moment very interested by the possibilities to do batch processing with script-fu in GIMP. So I found this page and took a close look at it: https://www.gimp.org/tutorials/Basic_Batch/ My problem is that I want to save a processed file with a new name. So it didn't take me too much time to figure out how to do it for the first example - and I came up with this: (define (simple-unsharp-mask filename radius amount threshold filenamenew) (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) (drawable (car (gimp-image-get-active-layer image (plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable radius amount threshold) (gimp-file-save RUN-NONINTERACTIVE image drawable filenamenew filenamenew) (gimp-image-delete image))) The procedure is being called with this command line: gimp -i -b '(simple-unsharp-mask "foo.png" 5.0 0.5 0 "foo-new.png")' -b '(gimp-quit 0)' Now I'm wondering how to get the second example, the actual batch processing script, to give new names for each and everyone of the processed images. I tried with this: (define (batch-unsharp-mask pattern radius amount threshold patternnew) (let* ((filelist (cadr (file-glob pattern 1))) (filelistnew (cadr (file-glob patternnew 1 (while (not (null? filelist)) (let* ((filename (car filelist)) (filenamenew (car filelistnew)) (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) (drawable (car (gimp-image-get-active-layer image (plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable radius amount threshold) (gimp-file-save RUN-NONINTERACTIVE image drawable filenamenew filenamenew) (gimp-image-delete image)) (set! filelist (cdr filelist)) (set! filelistnew (cdr filelistnew) But this didn't work because a list may not be empty: I understand now that it must exist beforehand and have at least 2 elements ("pair"). Then I tried with this: (define (batch-unsharp-mask pattern radius amount threshold filenamenew) (let* ((filelist (cadr (file-glob pattern 1 (while (not (null? filelist)) (let* ((filename (car filelist)) (filenamenew (+ "(car filelist)" "-new")) (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) (drawable (car (gimp-image-get-active-layer image (plug-in-unsharp-mask RUN-NONINTERACTIVE image drawable radius amount threshold) (gimp-file-save RUN-NONINTERACTIVE image drawable filenamenew filenamenew) (gimp-image-delete image)) (set! filelist (cdr filelist) But that didn't work either, because the argument to " + " (sum) must be a number. Where am I mistaken? Could you help? Or should I proceed in a totally different direction? Thanks a lot in advance. Ludo ___ gimp-user-list mailing list List address:gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list List archives: https://mail.gnome.org/archives/gimp-user-list