Re: [Gimp-user] Script-fu in GIMP - and batch processing.

2021-06-09 Thread Kevin Cozens

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.

2021-05-30 Thread Ofnuts via gimp-user-list

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.

2021-05-30 Thread Kevin Cozens

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.

2021-05-30 Thread ludo0565
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.

2021-05-15 Thread ludo0...@dbmail.com
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