Hi teapot, thanks for trying it out
You did not get an error? I mean, the script as it is throw an error if "Keep the original name" is ticked, at least on my distro (Ubuntu-MATE 20.04 /GIMP 2.10.38)
I found a partial "solution" but ... see below the code
Thanks for the "gimp-image-get-name" it worked,
I did find a partial solution with "strbreakup" to remove any file extension and add the extension I want, see code below.
but... (yes there is a "but" ) "gimp-image-get-name" take the temporary name in GIMP when we drag and drop images in GIMP
For instance if I drag and drop an image with the name "MyImage.jpg", in GIMP it will be called "[Myimage] (Imported)" and it is this name that GIMP will export with "gimp-image-get-name" ➤ [Myimage] (Imported).jpg
Drag and drop MyImage.jpg in GIMP look at the name
Result using "gimp-image-get-name", it export the "temporary?" name in GIMP
So, I'm telling myself that I need to use "gimp-image-get-filename", and get the name before the extension in the "list?".
There is another problem, on *nix system we can have names with multiple dot/period (and certainly on Windows nowadays), if I use (car (strbreakup (car (gimp-image-get-name image) ".") on an image named "this.is.my.image.xcf", I will only get "this" in the name...
The problem with car, cdr, cddr, cadar, and so on.. first is, that I have a very hard time to get it ,
second I did not find any explanations to fetch the last in the list or the one before the last, they (websites) are all speaking about fetching/catching the first in the list and the remaining list after the first.
If I can find out how to get only the name with this code just by using the right combination of "car" / "cdr" / "caaddr" / "whatnot", to get the one before the last (the extension) in the "list" that would be a huge step for me
-------------------------
(if (= isKeepName 1)
(set! newFileName (string-append inDir
pathchar (car (strbreakup (car (gimp-image-get-filename image)) ".")) ".webp"))
)
-----------------------
Indeed, you're right, but I'm a slow person, one thing at a time
The 1 Trillion dollar question
All started with with a simple saule goode script which was saving the active layer, it was an scm.
then rich2005 opened my eyes ➤ https://www.gimp-forum.net/Thread-Export...MP-at-once
Then add more option ➤ https://www.gimp-forum.net/Thread-Batch-...re-options
Then change the way the script works + a suggestion to reverse order by Krikor ➤ https://www.gimp-forum.net/Thread-Export...r-settings
Then a suggestion to add an option from Michael Schumacher on reddit ➤ https://www.gimp-forum.net/Thread-Batch-...3-22343567
Then few days ago I "updated" on my gitlab to make it compatible for GIMP 3 (I did not test yet)
Then I recall that many people asked to be able to save with the original name...
thus I get caught in that spiral down of the scheme scripting
Today I just want to finish this part, and "never" come back to it again if possible
Looks like I get lost during my searches
Thank you Ofnuts.
(10-08-2024, 05:39 AM)teapot Wrote: With 'Keep the original name' ticked got newFileName /home/teapot/Desktop//home/teapot/test.xcf.webp
This is not OK, the path is in 'twice' and there's a .xcf.
You did not get an error? I mean, the script as it is throw an error if "Keep the original name" is ticked, at least on my distro (Ubuntu-MATE 20.04 /GIMP 2.10.38)
I found a partial "solution" but ... see below the code
(10-08-2024, 05:39 AM)teapot Wrote: gimp-image-get-filename gives the whole path so /home/teapot/test.xcf
Whereas presumably what you want is gimp-image-get-name which will give test.xcf
Then you would need to strip off the .xcf
Thanks for the "gimp-image-get-name" it worked,
I did find a partial solution with "strbreakup" to remove any file extension and add the extension I want, see code below.
Code:
(if (= isKeepName 1)
(set! newFileName (string-append inDir
pathchar (car (strbreakup (car (gimp-image-get-name image)) ".")) ".webp"))
)
but... (yes there is a "but" ) "gimp-image-get-name" take the temporary name in GIMP when we drag and drop images in GIMP
For instance if I drag and drop an image with the name "MyImage.jpg", in GIMP it will be called "[Myimage] (Imported)" and it is this name that GIMP will export with "gimp-image-get-name" ➤ [Myimage] (Imported).jpg
Drag and drop MyImage.jpg in GIMP look at the name
Result using "gimp-image-get-name", it export the "temporary?" name in GIMP
So, I'm telling myself that I need to use "gimp-image-get-filename", and get the name before the extension in the "list?".
There is another problem, on *nix system we can have names with multiple dot/period (and certainly on Windows nowadays), if I use (car (strbreakup (car (gimp-image-get-name image) ".") on an image named "this.is.my.image.xcf", I will only get "this" in the name...
The problem with car, cdr, cddr, cadar, and so on.. first is, that I have a very hard time to get it ,
second I did not find any explanations to fetch the last in the list or the one before the last, they (websites) are all speaking about fetching/catching the first in the list and the remaining list after the first.
If I can find out how to get only the name with this code just by using the right combination of "car" / "cdr" / "caaddr" / "whatnot", to get the one before the last (the extension) in the "list" that would be a huge step for me
-------------------------
(if (= isKeepName 1)
(set! newFileName (string-append inDir
pathchar (car (strbreakup (car (gimp-image-get-filename image)) ".")) ".webp"))
)
-----------------------
(10-08-2024, 05:39 AM)teapot Wrote: Also you should consider the case when the user has a brand new .xcf file that's never been saved.
Indeed, you're right, but I'm a slow person, one thing at a time
(10-08-2024, 05:39 AM)teapot Wrote: Any reason why you aren't using python?
The 1 Trillion dollar question
All started with with a simple saule goode script which was saving the active layer, it was an scm.
then rich2005 opened my eyes ➤ https://www.gimp-forum.net/Thread-Export...MP-at-once
Then add more option ➤ https://www.gimp-forum.net/Thread-Batch-...re-options
Then change the way the script works + a suggestion to reverse order by Krikor ➤ https://www.gimp-forum.net/Thread-Export...r-settings
Then a suggestion to add an option from Michael Schumacher on reddit ➤ https://www.gimp-forum.net/Thread-Batch-...3-22343567
Then few days ago I "updated" on my gitlab to make it compatible for GIMP 3 (I did not test yet)
Then I recall that many people asked to be able to save with the original name...
thus I get caught in that spiral down of the scheme scripting
Today I just want to finish this part, and "never" come back to it again if possible
(10-08-2024, 07:22 AM)Ofnuts Wrote: You are looking at the doc for the C API. For script-fu, stick to the doc in the script-fu console, much less confusing (the C doc also contains a lot of calls that aren't available in script-fu.
Looks like I get lost during my searches
Thank you Ofnuts.
Patrice