09-06-2022, 10:37 AM
(09-06-2022, 07:08 AM)Ofnuts Wrote:(09-05-2022, 09:36 PM)cyril42e Wrote: However I didn't find anything about custom export actions, are you talking about writing a script ? I should indeed be able to reproduce the overwrite behavior (copy - flatten - save), maybe even without the confirmation dialog.
Yes, that's the file-jpeg-save call. Keep in mind that it takes a drawable (usually I do a gimp_layer_new_from_visible). Once saved do a gimp_image_clean_all so that Gimp doesn't pester you with the unsaved XCF when you want to quit.
Thanks for the advice, I used gimp-image-duplicate and gimp-image-flatten, seems to work as well, and gimp-file-save in order to avoid having to provide lots of quality parameters (anyway I did not find how to read the original file quality, so defaults are ok). gimp-image-clean-all is nice to save another click, thanks (I'll ignore the documentation warning "Note that save plug-ins must NOT call this function themselves after saving the image." as it is a "private" plugin ).
Here the complete script in case it can help someone:
Code:
(define (gimp-overwrite image)
(let*
(
(image_copy (car (gimp-image-duplicate image)))
(image_name (car (gimp-image-get-filename image)))
)
(gimp-image-flatten image_copy)
(define drawable (car (gimp-image-get-active-drawable image_copy)))
(gimp-file-save RUN-NONINTERACTIVE image_copy drawable image_name image_name)
(gimp-image-delete image_copy)
;(gimp-image-clean-all image)
)
)
(script-fu-register
"gimp-overwrite" ; func name
"Overwrite silently" ; menu label
"Silently overwrite the current JPEG file" ; description
"cyril42e" ; author
"" ; copyright
"2022" ; date
"" ; image type
SF-IMAGE "Image" 0
)
(script-fu-menu-register "gimp-overwrite" "<Image>/File")