It is currently Wed Jul 22, 2026 6:58 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Batch export all opened images script for GIMP [Update]
PostPosted: Sun Dec 10, 2023 1:42 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
EDIT:
Big huge update, I did re-do all, not the same script anymore (same purpose, though), but now your can use your own setting to export all opened images at once in GIMP
I did updated the manual as well (you won't believe it, but I think it's the longest part when you write a script or plugin, and the worse is that we know that nobody will read it :rofl )

Latest version to download is over there > https://gitlab.com/_PixLab/GIMP-Export-All-Images-As

Read my latest comments about this update

------------------------------------------------------------------
------------------ Original Post Below -------------------
------------------------------------------------------------------

Everything happened on G-F, inspired by Rich2005, and Ofnuts trying to put me on the right Path ;)
Starting from a script batch exporting only the selected layer in an image to a full export export of the image with more options.

Purpose.
Batch export all opened images in GIMP at once to JPG, PNG, WebP, TIFF, BMP, without the need to export them one by one, nor the need to interact with the user interface each time an image is exported as everything can be automated.

Use case example: you sliced your image from a guide’s grid of 10x10, and you have 100 new opened images (red rectangle below). Or simply, like everyday, you just did work on a dozen of images at a time and want them to be exported ASAP just to check the final image, but you need to work more on them and re-export them with the same setting at once.
This script will do the job in a matter of seconds.
Attachment:
screenshot_20231210-133825.jpg
screenshot_20231210-133825.jpg [ 151.19 KiB | Viewed 40062 times ]

Recommendation: This script will override existing image with the same name and extension, even though it will auto-number each exported image to not match an existing name, it’s better that you create a new folder for the exported images to not override the original images.

Download (I did wrote a manual in PDF included, inspired by Ofnuts but I'm less technical :hehe )
I'm thinking about Tin (trandoductin), and for me it's a good idea to put also the code written in the comment like he does, because Wayback Machine, rarely save the zips, thus in case of, people can still access the code, even if archive.org did not save the zip
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
; This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
; See the GNU General Public License for more details
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Original script from Lauchlin Wilkinson (& Saul Goode) from 2014/04/21 see at the end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; added section for webp - rich 2023/08/06
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Now Export full images with options PixLab 2023/08/10 & 2023/12/06
; changed numbers of numbering to higger numbering (substring "00000" (string-length and (list 0 0 9000 1 100 0 SF-SPINNER)
; changed menu entry "<Image>/File/Save ALL As" and added  (script-fu-menu-register "script-fu-save-all-images" "<Image>/File/E_xport") to not be at the bottom
; 2023/12/06 changed (car (gimp-image-get-active-layer image)) to (car (gimp-layer-new-from-visible image image "export")), changed the default directory to Desktop
; 2023/12/06 Added JPG, PNG, WEBP, BMP, TIF to be customizable, changed file-webp-save to file-webp-save2 latest version + settings, commented all settings by image type from procedure browser
; 2023/12/07 Added choice for the user to choose all auto (RUN-NONINTERACTIVE), or from image setting all auto (RUN-WITH-LAST-VALS) or manually (RUN-INTERACTIVE)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (pxl-script-fu-save-all-images-as inDir inSaveType
inFileName inFileNumber runChoice)
  (let* (
          (i (car (gimp-image-list)))
          (ii (car (gimp-image-list)))  ; I did not pay attention but I could use this one instead of creating j
       ;  (j (car (gimp-image-list)))  ; to keep the total image number to compare to "i" minused by 1 with each loop
          (image)
          (isInteractive)              ; declare isInteractive to set it later on
          (newFileName "")
          (saveString "")
          (pathchar (if (equal?
                 (substring gimp-dir 0 1) "/") "/" "\\"))
        )
    (set! saveString
      (cond
        (( equal? inSaveType 0 ) ".jpg" )
        (( equal? inSaveType 1 ) ".webp" )
        (( equal? inSaveType 2 ) ".png" )
        (( equal? inSaveType 3 ) ".tif" )
        (( equal? inSaveType 4 ) ".bmp" )
      )
    )

    (set! isInteractive              ; no more, the other isInteractive works as intended https://www.gimp-forum.net/Thread-RUN-WITH-LAST-VALS-in-Script-Fu-is-not-what-you-might-think
      (cond
        (( equal? runChoice 0 ) RUN-NONINTERACTIVE )
        (( equal? runChoice 1 ) RUN-INTERACTIVE )
        (( equal? runChoice 2 ) RUN-WITH-LAST-VALS )
      )
    )
   
    (while (> i 0)
      ;(set! isInteractive
      ;  (cond
      ;      ((= i j) RUN-INTERACTIVE)
      ;      (else RUN-WITH-LAST-VALS) ; last vals is the last values used IF the image has already been exported, then runs auto, but if never export during SESSION it will ask for settings
      ;  )
      ;)

      (set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
      (set! newFileName (string-append inDir
              pathchar inFileName
              (substring "0000000" (string-length
              (number->string (+ inFileNumber i))))
              (number->string (+ inFileNumber i)) saveString))
     
      (cond
        ((equal? saveString ".webp")
                           
           (file-webp-save2 isInteractive ;RUN-NONINTERACTIVE
                      image
                      (car (gimp-layer-new-from-visible image image "export"))
                      newFileName
                      newFileName
                      1    ; preset 0=default 1=pic 2=photo 3=drawing 4=icon 5=text
                      0    ; Use lossless encoding (0/1)
                      90   ; Quality of the image (0 <= quality <= 100)
                      90   ; alpha-quality  0<>100
                      0    ; Use layers for animation (0/1)
                      0    ; Loop animation infinitely (0/1)
                      0    ; Minimize animation size (0/1)
                      0    ; Maximum distance between key-frames (>=0)
                      0    ; Toggle saving exif data (0/1)
                      0    ; Toggle saving iptc data (0/1) works only if save XMP data is also checked ?
                      0    ; Toggle saving xmp data (0/1)
                      0    ; Toggle saving thumbnail (0/1)
                      0    ; Delay to use when timestamps are not available or forced
                      0    ; Force delay on all frames (0/1)

          ))
     
         ((equal? saveString ".jpg")
           
            (file-jpeg-save isInteractive ;RUN-NONINTERACTIVE
                      image
                      (car (gimp-layer-new-from-visible image image "export"))
                      newFileName
                      newFileName
                      0.88 ;  Float Quality of saved image (0 => quality <= 1)
                      0    ;  Float Smoothing factor for saved image (0 => smoothing <= 1)
                      1    ;  Use optimized tables during Huffman coding (0/1)
                      1    ;  Create progressive JPEG images (0/1)
                      ""   ;  String Image comment (if you want to put "Image made by me!")
                      2    ;  Sub-sampling type { 0, 1, 2, 3 } 0 == 4:2:0 (chroma quartered), 1 == 4:2:2 Horizontal (chroma halved), 2 == 4:4:4 (best quality), 3 == 4:2:2 Vertical (chroma halved)
                      1    ;  Force creation of a baseline JPEG (non-baseline JPEGs can't be read by all decoders) (0/1)
                      0    ;  Interval of restart markers (in MCU rows, 0 = no restart markers)
                      2    ;  DCT method to use { INTEGER (0), FIXED (1), FLOAT (2) }
          ))
         
        ((equal? saveString ".png")

           (file-png-save2 isInteractive  ;RUN-NONINTERACTIVE
                      image
                      (car (gimp-layer-new-from-visible image image "export"))
                      newFileName
                      newFileName
                      1    ; Use Adam7 interlacing? (0/1)
                      9    ; Deflate Compression factor (0--9)
                      1    ; Write bKGD chunk? (0/1)
                      0    ; Write gAMA chunk? (0/1)
                      0    ; Write oFFs chunk? (0/1)
                      0    ; Write pHYs chunk? (0/1)
                      1    ; Write tIME chunk? (0/1)
                      0    ; Write comment?
                      0    ; Preserve color of transparent pixels? (0/1)

          ))
         
        ((equal? saveString ".tif")

           (file-bigtiff-save isInteractive  ;RUN-NONINTERACTIVE
                      image
                      (car (gimp-layer-new-from-visible image image "export"))
                      newFileName
                      newFileName
                      3    ; Compression type: { NONE (0), LZW (1), PACKBITS (2), DEFLATE (3), JPEG (4), CCITT G3 Fax (5), CCITT G4 Fax (6) }
                      1    ; Keep the color data masked by an alpha channel intact (do not store premultiplied components) (0/1)
                      0    ; Export in BigTIFF variant file format (0/1)

          ))

        (else

          (gimp-file-save isInteractive ;RUN-NONINTERACTIVE
                      image
                      (car (gimp-layer-new-from-visible image image "export"))
                      newFileName
                      newFileName
          ))
      )

      (gimp-image-clean-all image)
      (set! i (- i 1))


)))

(script-fu-register "pxl-script-fu-save-all-images-as"
"Export All Images As..."
"Export all opened images at once\nSupported Export types: WebP, JPG, PNG, BMP, and TIF\nBigTiff accessible in manual mode first "
"PixLab (& Rich (& Lauchlin Wilkinson (& Saul Goode)))"
"PixLab (& Rich (& Lauchlin Wilkinson (& Saul Goode)))"
"2023/12/07"
"----------"
SF-DIRNAME    "Select a Directory to Export Images" "Desktop"
SF-OPTION     "Select an Image Type to Export" (list "JPG" "WebP" "PNG" "TIFF" "BMP")
SF-STRING     "Input an Image Base Name" "IMAGE-"
SF-ADJUSTMENT "Input a Start Number (Auto-Numbering)" (list 0 0 999999 1 100 0 SF-SPINNER)
SF-OPTION     "Select How to Export:\n[1] Settings from the script (recommended):\n[2] You confirm settings for each image:\n[3] Image Was Never Exported = Manual\n       Image Was Exported Before = Auto"
                                         (list "[1] Default (fully automated)" "[2] Full control (Manual Mode)" "[3] Settings From Latest Export per Image\n\n      First Time Image is Exported is Manual\n      Then, All Next Export are Automated")
)
(script-fu-menu-register "pxl-script-fu-save-all-images-as" "<Image>/File/E_xport")

;;;;;;;;;;;;;;;;;;;;;;;;;;;; ORIGINAL SCRIPT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; (define (script-fu-save-all-images inDir inSaveType
; inFileName inFileNumber)
;  (let* (
;          (i (car (gimp-image-list)))
;          (ii (car (gimp-image-list)))
;          (image)
;          (newFileName "")
;          (saveString "")
;          (pathchar (if (equal?
;                 (substring gimp-dir 0 1) "/") "/" "\\"))
;        )
;    (set! saveString
;      (cond
;        (( equal? inSaveType 0 ) ".jpg" )
;        (( equal? inSaveType 1 ) ".bmp" )
;        (( equal? inSaveType 2 ) ".png" )
;        (( equal? inSaveType 3 ) ".tif" )
;      )
;    )
;    (while (> i 0)
;      (set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
;      (set! newFileName (string-append inDir
;              pathchar inFileName
;              (substring "00000" (string-length
;              (number->string (+ inFileNumber i))))
;              (number->string (+ inFileNumber i)) saveString))
;      (gimp-file-save RUN-NONINTERACTIVE
;                      image
;                      (car (gimp-image-get-active-layer image))
;                      newFileName
;                      newFileName
;      )
;      (gimp-image-clean-all image)
;      (set! i (- i 1))
;    )
;  )
;)
;
;(script-fu-register "script-fu-save-all-images"
; "<Image>/File/Save ALL As"
; "Save all opened images as ..."
; "Lauchlin Wilkinson (& Saul Goode)"
; "Lauchlin Wilkinson (& Saul Goode)"
; "2014/04/21"
; ""
; SF-DIRNAME    "Save Directory" ""
; SF-OPTION     "Save File Type" (list "jpg" "bmp" "png" "tif")
; SF-STRING     "Save File Base Name" "IMAGE"
; SF-ADJUSTMENT "Save File Start Number"
;      (list 0 0 9000 1 100 0 SF-SPINNER)
; )

_________________
Patrice


Last edited by PixLab on Mon Feb 19, 2024 12:02 am, edited 7 times in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Batch export all opened images script for GIMP
PostPosted: Wed Dec 13, 2023 4:44 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1459
I actually don't understand why you would batch export all images (layers) at the same time? I do all layers in series (but at the same time) with ofnuts 'export all layers'.
Do you have multiple canvasses open at the same time or have I missed something?


Top
 Post subject: Re: Batch export all opened images script for GIMP
PostPosted: Wed Dec 13, 2023 5:57 pm  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jul 04, 2019
Posts: 282
Location: Lake Havasu City, Arizona, USA
Patrice,
Have you thought about creating a code repository on GitHub? It's pretty easy to do.

_________________
Charles


Top
 Post subject: Re: Batch export all opened images script for GIMP
PostPosted: Sat Dec 16, 2023 12:14 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
Tas_mania wrote:
I actually don't understand why you would batch export all images (layers) at the same time? I do all layers in series (but at the same time) with ofnuts 'export all layers'.
Do you have multiple canvasses open at the same time or have I missed something?

Hi Tas_mania
No layers, all opened images (multiple canvas)
You can go very quickly to 25 new images with this example:
Make a grid of 5x5 guides
Attachment:
screenshot_20231216-130631.jpg
screenshot_20231216-130631.jpg [ 229.46 KiB | Viewed 38787 times ]

Then go to Image > Slice Using Guides... and you got 25 new images, and there is nothing in GIMP to Batch Export them all at once, or you do it manually by going to File > Export... one by one where also... you need to enter a new name each time if you don't want the original name.
Attachment:
screenshot_20231216-130928.jpg
screenshot_20231216-130928.jpg [ 90.33 KiB | Viewed 38787 times ]


BTW I did completely re-do the script, to let users input their own settings for each type of image type, I'm gonna open a thread for it on GC

_________________
Patrice


Top
 Post subject: Re: Batch export all opened images script for GIMP
PostPosted: Sat Dec 16, 2023 12:24 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
gasMask wrote:
Patrice,
Have you thought about creating a code repository on GitHub? It's pretty easy to do.

Thanks, for the suggestion, but I got one from years ago to report bugs or ask questions (still never use it for something else, thus I don't know how to use it, even if I tried to push some buttons there or over there, not knowing what did I do :hehe )
Anyway now it's GitHub = Microsoft = the Damocles' sword... Hum... I don't like to have the sword of Damocles hanging around above my head :mrgreen: and still, I'm very much holding the grudge about what they did to Atom :cry

_________________
Patrice


Top
 Post subject: Re: Batch export all opened images script for GIMP
PostPosted: Sat Dec 16, 2023 2:50 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1459
I see it slices and dices? Like a kitchen appliance :) That's kinda neat.


Top
 Post subject: Re: Batch export all opened images script for GIMP
PostPosted: Thu Dec 21, 2023 11:38 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
I did rewrite the script completely, new user interface, new menu.
Now you can export all opened images with your own setting,
also before, once your images exported, GIMP did not ask if you want to save the XCF when closing GIMP, (thanks to Michael Schumacher to have point this out), now it's an option, etc... etc...

Download it at the 1st original post (thread begining) I did left the old script (they can work side by side), but it's recommended to remove the old one from your scripts folder
A PDF manual is provided..., I recommend the read, even though no-one will read it :mrgreen:

Where to find it in the menu?
Attachment:
screenshot_20231215-121856.jpg
screenshot_20231215-121856.jpg [ 62.45 KiB | Viewed 37342 times ]


How it looks now?
Attachment:
screenshot_20231215-140503-1.jpg
screenshot_20231215-140503-1.jpg [ 175.33 KiB | Viewed 37342 times ]


For perinity with webarchive.org: the code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
; This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
; See the GNU General Public License for more details https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Created by PixLab 2023/12/12
; Download > http://gimpchat.com/viewtopic.php?f=9&t=20667
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    WEBP      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (script-fu-pxl-save-all-images-as-webp inDir inAskAfter inFileName inFileNumber inPreset inLossLess inQuality inAlphaQuality inAnimation inLoop inMiniSize inKeyframe inExif inIPTC inXMP inThumbnail inDelay inForceDelay runChoice)
  (let* (
          (i (car (gimp-image-list)))
          (ii (car (gimp-image-list)))
          (image)
          (isInteractive)         
          (newFileName "")
          (pathchar (if (equal?
                 (substring gimp-dir 0 1) "/") "/" "\\"))
          (webPreset) 
          (isLossless)   
          (qualityImage)
          (qualityAlpha)
          (isAnimation)
          (isLoop)
          (isMinimize)
          (keyframeNum)
          (isExif)
          (isIPTC)
          (isXMP)
          (isThumb)
          (delayNum)
          (isForceDelay)
        )
    (set! isInteractive
      (cond
        (( equal? runChoice 0 ) RUN-NONINTERACTIVE )
        (( equal? runChoice 1 ) RUN-INTERACTIVE )
        (( equal? runChoice 2 ) RUN-WITH-LAST-VALS )
      )
    )
    (set! webPreset                      ; re-order as I did "Picture" first
        (cond
        ((equal? inPreset 0) 1 )
        ((equal? inPreset 1) 2 )
        ((equal? inPreset 2) 3 )
        ((equal? inPreset 3) 4 )
        ((equal? inPreset 4) 5 )
        ((equal? inPreset 5) 0 )
        )
    )
    (set! isLossless
       (cond
       ((equal? inLossLess FALSE) 0 )
       ((equal? inLossLess TRUE) 1 )
       )
    )
    (set! qualityImage inQuality )
    (set! qualityAlpha inAlphaQuality )
    (set! isAnimation
       (cond
       ((equal? inAnimation FALSE) 0 )
       ((equal? inAnimation TRUE) 1 )
       )
    )
    (set! isLoop
       (cond
       ((equal? inLoop FALSE) 0 )
       ((equal? inLoop TRUE) 1 )
       )
    )
    (set! isMinimize
       (cond
       ((equal? inMiniSize FALSE) 0 )
       ((equal? inMiniSize TRUE) 1 )
       )
    )
    (set! keyframeNum inKeyframe)   
    (set! isExif
       (cond
       ((equal? inExif FALSE) 0 )
       ((equal? inExif TRUE) 1 )
       )
    )
    (set! isIPTC
       (cond
       ((equal? inIPTC FALSE) 0 )
       ((equal? inIPTC TRUE) 1 )
       )
    )
    (set! isXMP
      (cond
       ((equal? inXMP FALSE) 0 )
       ((equal? inXMP TRUE) 1 )
      )
    )
    (set! isThumb
      (cond
       ((equal? inThumbnail FALSE) 0 )
       ((equal? inThumbnail TRUE) 1 )
      )
    )
    (set! delayNum inDelay)
    (set! isForceDelay
      (cond
       ((equal? inForceDelay FALSE) 0 )
       ((equal? inForceDelay TRUE) 1 )
      )
    )

    (while (> i 0)

      (set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
      (set! newFileName (string-append inDir
              pathchar inFileName
              (substring "0000000" (string-length
              (number->string (+ inFileNumber i))))
              (number->string (+ inFileNumber i)) ".webp"))
     
          (file-webp-save2 isInteractive
                      image
                      (car (gimp-layer-new-from-visible image image "export"))
                      newFileName
                      newFileName
                      webPreset        ; preset 0=default 1=pic 2=photo 3=drawing 4=icon 5=text
                      isLossless       ; Use lossless encoding (0/1)
                      qualityImage     ; Quality of the image (0 <= quality <= 100)
                      qualityAlpha     ; alpha-quality  0<>100
                      isAnimation      ; Use layers for animation (0/1)
                      isLoop           ; Loop animation infinitely (0/1)
                      isMinimize       ; Minimize animation size (0/1)
                      keyframeNum      ; Maximum distance between key-frames (>=0)
                      isExif           ; Toggle saving exif data (0/1)
                      isIPTC           ; Toggle saving iptc data (0/1) works only if save XMP data is also checked ?
                      isXMP            ; Toggle saving xmp data (0/1)
                      isThumb          ; Toggle saving thumbnail (0/1)
                      delayNum         ; Delay to use when timestamps are not available or forced
                      isForceDelay     ; Force delay on all frames (0/1)

          )

      (if (not (= inAskAfter TRUE)) (gimp-image-clean-all image))
      (set! i (- i 1))


)))

(script-fu-register "script-fu-pxl-save-all-images-as-webp"
"1 - As WebP..."
"Export all opened images at once as WebP with your settings..."
"PixLab"
"GPL-v2+"
"2023/12/12"
"*"
SF-DIRNAME    "Select a directory to export your images" "Desktop"
SF-TOGGLE     "Ask me to save the XCF when closing GIMP or an image" TRUE
SF-STRING     "Input an image base name" "IMAGE-"
SF-ADJUSTMENT "Input a start number for image name auto-numbering" (list 0 0 999999 1 100 0 SF-SPINNER)
SF-OPTION     "Select a WebP Preset" (list "Picture" "Photo" "Drawing" "Icon" "Text" "Default")
SF-TOGGLE     "Use lossless encoding" FALSE
SF-ADJUSTMENT "Quality of the image" (list 90 0 100 1 1 0 SF-SLIDER)
SF-ADJUSTMENT "Quality of Transparency" (list 90 0 100 1 1 0 SF-SLIDER)
SF-TOGGLE     "Use Layers for Animation" FALSE
SF-TOGGLE     "Loop Animation Infinitely" TRUE
SF-TOGGLE     "Minimize Animation Size" FALSE
SF-ADJUSTMENT "Maximum distance between key-frames:\n    0 = No Keyframes:\n    1 = All Frames are Keyframes" (list 50 0 10000 1 1 0 SF-SPINNER)
SF-TOGGLE     "Save Exif Data" TRUE
SF-TOGGLE     "Save IPTC Data" FALSE
SF-TOGGLE     "Save XMP Data" FALSE
SF-TOGGLE     "Save Thumbnail" FALSE
SF-ADJUSTMENT "Delay to use between frames when unspecified" (list 100 0 10000 1 1 0 SF-SPINNER)
SF-TOGGLE     "Use delay entered above for all frames" FALSE
SF-OPTION     "Select How to Export (Explanations in the manual)" (list "Automated: Above settings for all images" "Full control: You confirm each setting on each image" "Use settings from latest Export")
)
(script-fu-menu-register "script-fu-pxl-save-all-images-as-webp" "<Image>/File/E_xport/Export All Images As")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  JPG  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (script-fu-pxl-save-all-images-as-jpg inDir inAskAfter inFileName inFileNumber inQuality inSmooth inHuffman inProgressive inComment inSubsampling inBaseLine inMCU inDCT runChoice)
  (let* (
          (i (car (gimp-image-list)))
          (ii (car (gimp-image-list)))
          (image)
          (isInteractive)         
          (newFileName "")
          (pathchar (if (equal?
                 (substring gimp-dir 0 1) "/") "/" "\\"))
          (isHuffman)
          (qualityJPG)
          (smoothJPG)
          (isHuffman)
          (isProgressive)
          (commentString "")
          (subSamplingSet)
          (isBaseLine)
          (isMCU)
          (isDCT)
        )

    (set! isInteractive
      (cond
        (( equal? runChoice 0 ) RUN-NONINTERACTIVE )
        (( equal? runChoice 1 ) RUN-INTERACTIVE )
        (( equal? runChoice 2 ) RUN-WITH-LAST-VALS )
      )
    )
    (set! qualityJPG (/ inQuality 100))   ; I did put the setting on the UI of 0 <> 100 to be user friendly but the scale in file-jpeg-save is 0 <> 1 float 2 decimal
    (set! smoothJPG inSmooth )
    (set! isHuffman
       (cond
       ((equal? inHuffman FALSE) 0 )
       ((equal? inHuffman TRUE) 1 )
       )
    )
    (set! isProgressive
       (cond
       ((equal? inProgressive FALSE) 0 )
       ((equal? inProgressive TRUE) 1)
       )
    )
    (set! commentString inComment)
    (set! subSamplingSet                 ; re-order as I did put "best quality" first to be default if user don't change
      (cond
        (( equal? inSubsampling 0 ) 2 )
        (( equal? inSubsampling 1 ) 0 )
        (( equal? inSubsampling 2 ) 1 )
        (( equal? inSubsampling 3 ) 3 )
      )
    )
    (set! isBaseLine
       (cond
       ((equal? inBaseLine FALSE) 0 )
       ((equal? inBaseLine TRUE) 1 )
       )
    )
    (set! isMCU inMCU)   
    (set! isDCT                         ; re-order as I did put "FLOAT" first to be default if user don't change
      (cond
        (( equal? inDCT 0 ) 2 )
        (( equal? inDCT 1 ) 0 )
        (( equal? inDCT 2 ) 1 )
      )
    )       
    (while (> i 0)

      (set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
      (set! newFileName (string-append inDir
              pathchar inFileName
              (substring "0000000" (string-length
              (number->string (+ inFileNumber i))))
              (number->string (+ inFileNumber i)) ".jpg"))
     
      (file-jpeg-save isInteractive
                      image
                      (car (gimp-layer-new-from-visible image image "export"))
                      newFileName
                      newFileName
                      qualityJPG        ;  Float Quality of saved image (0 => quality <= 1)
                      smoothJPG         ;  Float Smoothing factor for saved image (0 => smoothing <= 1)
                      isHuffman         ;  Use optimized tables during Huffman coding (0/1)
                      isProgressive     ;  Create progressive JPEG images (0/1)
                      commentString     ;  String Image comment (if you want to put "Image made by me!")
                      subSamplingSet    ;  Sub-sampling type { 0, 1, 2, 3 } 0 == 4:2:0 (chroma quartered), 1 == 4:2:2 Horizontal (chroma halved), 2 == 4:4:4 (best quality), 3 == 4:2:2 Vertical (chroma halved)
                      isBaseLine        ;  Force creation of a baseline JPEG (non-baseline JPEGs can't be read by all decoders) (0/1)
                      isMCU             ;  Interval of restart markers (in MCU rows, 0 = no restart markers)
                      isDCT             ;  DCT method to use { INTEGER (0), FIXED (1), FLOAT (2) }
      )

      (if (not (= inAskAfter TRUE)) (gimp-image-clean-all image))
      (set! i (- i 1))


)))

(script-fu-register "script-fu-pxl-save-all-images-as-jpg"
"2 - As JPG..."
"Export all opened images at once as JPG with your settings..."
"PixLab"
"GPL-v2+"
"2023/12/12"
"*"
SF-DIRNAME    "Select a directory to export your images" "Desktop"
SF-TOGGLE     "Ask me to save the XCF when closing GIMP or an image" TRUE
SF-STRING     "Input an image base name" "IMAGE-"
SF-ADJUSTMENT "Input a start number for image name auto-numbering" (list 0 0 999999 1 100 0 SF-SPINNER)
SF-ADJUSTMENT "Image Quality ( > 95 Not recommended, RTM)" (list 88 0 100 1 1 0 SF-SLIDER)
SF-ADJUSTMENT "Smoothing (can help reduce file size)" (list 0.00 0.00 1.00 0.01 0.01 2 SF-SLIDER)
SF-TOGGLE     "Use optimized tables during Huffman coding" TRUE
SF-TOGGLE     "Create progressive JPEG (NOT recommended for software compatibility)" FALSE
SF-STRING     "Input a comment inside your image" "@ made with GIMP"
SF-OPTION     "Sub-sampling type" (list "4:4:4 (best quality)" "4:2:0 (chroma quartered)" "4:2:2 Horizontal (chroma halved)" "4:2:2 Vertical (chroma halved)")
SF-TOGGLE     "Force baseline JPEG (recommended for software compatibility)" TRUE
SF-ADJUSTMENT "Restart markers MCU rows (0 = no restart, recommended)" (list 0 0 64 1 1 0 SF-SPINNER)
SF-OPTION     "DCT method to use" (list "Float" "Integer" "Fixed")
SF-OPTION     "Select How to Export (Explanations in the manual)" (list "Automated: Above settings for all images" "Full control: You confirm each setting on each image" "Use settings from latest Export")
)
(script-fu-menu-register "script-fu-pxl-save-all-images-as-jpg" "<Image>/File/E_xport/Export All Images As")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   PNG   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (script-fu-pxl-save-all-images-as-png inDir inAskAfter inFileName inFileNumber inAdam inDeflate inBackground inGamma inOffset inResolution inDate inComment inTransparentColor runChoice)
  (let* (
          (i (car (gimp-image-list)))
          (ii (car (gimp-image-list)))
          (image)
          (isInteractive)         
          (newFileName "")
          (pathchar (if (equal?
                 (substring gimp-dir 0 1) "/") "/" "\\"))
          (isAdam) 
          (isDeflate)   
          (isBackground)
          (isGamma)
          (isOffset)
          (isResolution)
          (isDate)
          (isComment)
          (isTransparentColor)
        )
    (set! isInteractive
      (cond
        (( equal? runChoice 0 ) RUN-NONINTERACTIVE )
        (( equal? runChoice 1 ) RUN-INTERACTIVE )
        (( equal? runChoice 2 ) RUN-WITH-LAST-VALS )
      )
    )
    (set! isAdam
       (cond
       ((equal? inAdam FALSE) 0 )
       ((equal? inAdam TRUE) 1 )
       )
    )
    (set! isDeflate inDeflate )
    (set! isBackground
       (cond
       ((equal? inBackground FALSE) 0 )
       ((equal? inBackground TRUE) 1 )
       )
    )
    (set! isGamma
       (cond
       ((equal? inGamma FALSE) 0 )
       ((equal? inGamma TRUE) 1 )
       )
    )
    (set! isOffset
       (cond
       ((equal? inOffset FALSE) 0 )
       ((equal? inOffset TRUE) 1 )
       )
    )   
    (set! isResolution
       (cond
       ((equal? inResolution FALSE) 0 )
       ((equal? inResolution TRUE) 1 )
       )
    )
    (set! isDate
       (cond
       ((equal? inDate FALSE) 0 )
       ((equal? inDate TRUE) 1 )
       )
    )
    (set! isComment
      (cond
       ((equal? inComment FALSE) 0 )
       ((equal? inComment TRUE) 1 )
      )
    )
    (set! isTransparentColor
      (cond
       ((equal? inTransparentColor FALSE) 0 )
       ((equal? inTransparentColor TRUE) 1 )
      )
    )

    (while (> i 0)

      (set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
      (set! newFileName (string-append inDir
              pathchar inFileName
              (substring "0000000" (string-length
              (number->string (+ inFileNumber i))))
              (number->string (+ inFileNumber i)) ".png"))
     
           (file-png-save2 isInteractive
                      image
                      (car (gimp-layer-new-from-visible image image "export"))
                      newFileName
                      newFileName
                      isAdam                ; Use Adam7 interlacing? (0/1)
                      isDeflate             ; Deflate Compression factor (0--9)
                      isBackground          ; Save Background Color? (0/1)
                      isGamma               ; Save gAMA chunk? (0/1)
                      isOffset              ; Save Layer oFFsets chunk? (0/1)
                      isResolution          ; Save Resolution chunk? (0/1)
                      isDate                ; Save creation date chunk? (0/1)
                      isComment             ; Write comment (taken from GIMP comment)
                      isTransparentColor    ; Preserve color of transparent pixels? (0/1)

          )

      (if (not (= inAskAfter TRUE)) (gimp-image-clean-all image))
      (set! i (- i 1))


)))

(script-fu-register "script-fu-pxl-save-all-images-as-png"
"3 - As PNG..."
"Export all opened images at once as PNG with your settings..."
"PixLab"
"GPL-v2+"
"2023/12/12"
"*"
SF-DIRNAME    "Select a directory to export your images" "Desktop"
SF-TOGGLE     "Ask me to save the XCF when closing GIMP or an image" TRUE
SF-STRING     "Input an image base name" "IMAGE-"
SF-ADJUSTMENT "Input a start number for image name auto-numbering" (list 0 0 999999 1 100 0 SF-SPINNER)
SF-TOGGLE     "Use Adam7 interlacing?" FALSE
SF-ADJUSTMENT "Compression factor (0-9)" (list 9 0 9 1 1 0 SF-SLIDER)
SF-TOGGLE     "Save Background Color" TRUE
SF-TOGGLE     "Save gamma" FALSE
SF-TOGGLE     "Save layer offset" FALSE
SF-TOGGLE     "Save resolution" TRUE
SF-TOGGLE     "Save creation time" TRUE
SF-TOGGLE     "Save comment" TRUE
SF-TOGGLE     "Preserve color of transparent pixels?" FALSE
SF-OPTION     "Select How to Export (Explanations in the manual)" (list "Automated: Above settings for all images" "Full control: You confirm each setting on each image" "Use settings from latest Export")
)
(script-fu-menu-register "script-fu-pxl-save-all-images-as-png" "<Image>/File/E_xport/Export All Images As")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  TIFF  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (script-fu-pxl-save-all-images-as-tif inDir inAskAfter inFileName inFileNumber inCompression runChoice)  ;inKeepColor inBigTiff
  (let* (
          (i (car (gimp-image-list)))
          (ii (car (gimp-image-list)))
          (image)
          (isInteractive)         
          (newFileName "")
          (pathchar (if (equal?
                 (substring gimp-dir 0 1) "/") "/" "\\"))
          (isCompression) 
;          (isKeepColor)   
;          (isBigTiff)
        )
    (set! isInteractive
      (cond
        (( equal? runChoice 0 ) RUN-NONINTERACTIVE )
        (( equal? runChoice 1 ) RUN-INTERACTIVE )
        (( equal? runChoice 2 ) RUN-WITH-LAST-VALS )
      )
    )
    (set! isCompression                    ; re-order as I did "DEFLATE" first
       (cond
        (( equal? inCompression 0 ) 3 )
        (( equal? inCompression 1 ) 1 )
        (( equal? inCompression 2 ) 2 )
        (( equal? inCompression 3 ) 4 )
        (( equal? inCompression 4 ) 5 )
        (( equal? inCompression 5 ) 6 )
        (( equal? inCompression 6 ) 0 )
       )
    )
;    (set! isKeepColor
;       (cond
;       ((equal? inKeepColor FALSE) 0 )
;       ((equal? inKeepColor TRUE) 1 )
;       )
;    )
;    (set! isBigTiff
;       (cond
;       ((equal? inBigTiff FALSE) 0 )
;       ((equal? inBigTiff TRUE) 1 )
;       )
;    )

    (while (> i 0)

      (set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
      (set! newFileName (string-append inDir
              pathchar inFileName
              (substring "0000000" (string-length
              (number->string (+ inFileNumber i))))
              (number->string (+ inFileNumber i)) ".tif"))
     
           (file-tiff-save isInteractive  ; file-bigtiff-save
                      image
                      (car (gimp-layer-new-from-visible image image "export"))
                      newFileName
                      newFileName
                      isCompression      ; Compression type: { NONE (0), LZW (1), PACKBITS (2), DEFLATE (3), JPEG (4), CCITT G3 Fax (5), CCITT G4 Fax (6) }
                      ;isKeepColor       ; Keep the color data masked by an alpha channel intact (do not store premultiplied components) (0/1)
                      ;isBigTiff         ; Export in BigTIFF variant file format up to 18 exabytes (18000 PB petabytes) (0/1)
                     
          )

      (if (not (= inAskAfter TRUE)) (gimp-image-clean-all image))
      (set! i (- i 1))


)))

(script-fu-register "script-fu-pxl-save-all-images-as-tif"
"4 - As TIFF..."
"Export all opened images at once as TIFF with your settings..."
"PixLab"
"GPL-v2+"
"2023/12/12"
"*"
SF-DIRNAME    "Select a directory to export your images" "Desktop"
SF-TOGGLE     "Ask me to save the XCF when closing GIMP or an image" TRUE
SF-STRING     "Input an image base name" "IMAGE-"
SF-ADJUSTMENT "Input a start number for image name auto-numbering" (list 0 0 999999 1 100 0 SF-SPINNER)
SF-OPTION     "Compression type" (list "DEFLATE" "LZW" "PACKBITS" "JPEG" "CCITT G3 Fax" "CCITT G4 Fax" "None...")
; SF-TOGGLE     "Keep the color data masked by an alpha channel intact" TRUE
; SF-TOGGLE     "Export in BigTIFF variant up to 18000 PB (petabytes)" FALSE
SF-OPTION     "Select How to Export (Explanations in the manual)" (list "Automated: Above settings for all images" "Full control: You confirm each setting on each image" "Use settings from latest Export")
)
(script-fu-menu-register "script-fu-pxl-save-all-images-as-tif" "<Image>/File/E_xport/Export All Images As")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  BMP  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (script-fu-pxl-save-all-images-as-bmp inDir inAskAfter inFileName inFileNumber inRLE inColorSpace inRGBformat runChoice)
  (let* (
          (i (car (gimp-image-list)))
          (ii (car (gimp-image-list)))
          (image)
          (isInteractive)         
          (newFileName "")
          (pathchar (if (equal?
                 (substring gimp-dir 0 1) "/") "/" "\\"))
          (isRLE) 
          (isColorSpace)   
          (isRGBformat)
        )
    (set! isInteractive
      (cond
        (( equal? runChoice 0 ) RUN-NONINTERACTIVE )
        (( equal? runChoice 1 ) RUN-INTERACTIVE )
        (( equal? runChoice 2 ) RUN-WITH-LAST-VALS )
      )
    )
    (set! isRGBformat                     ; re-order as I did "32-bit RGBA 8888" first
       (cond
        (( equal? inRGBformat 0 ) 4 )
        (( equal? inRGBformat 1 ) 5 )
        (( equal? inRGBformat 2 ) 3 )
        (( equal? inRGBformat 3 ) 0 )
        (( equal? inRGBformat 4 ) 1 )
        (( equal? inRGBformat 5 ) 2 )
       )
    )
    (set! isColorSpace
       (cond
       ((equal? inColorSpace FALSE) 0 )
       ((equal? inColorSpace TRUE) 1 )
       )
    )
    (set! isRLE
       (cond
       ((equal? inRLE FALSE) 0 )
       ((equal? inRLE TRUE) 1 )
       )
    )

    (while (> i 0)

      (set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
      (set! newFileName (string-append inDir
              pathchar inFileName
              (substring "0000000" (string-length
              (number->string (+ inFileNumber i))))
              (number->string (+ inFileNumber i)) ".bmp"))
     
           (file-bmp-save2 isInteractive
                      image
                      (car (gimp-layer-new-from-visible image image "export"))
                      newFileName
                      newFileName
                      isRLE              ; Use run-length-encoding (RLE) compression (only valid for 4 and 8-bit indexed images)
                      isColorSpace       ; write-color-space Whether or not to write BITMAPV5HEADER color space data 0 = write, 1 = do not write
                      isRGBformat        ; Export format for RGB images (0=RGB_565, 1=RGBA_5551, 2=RGB_555, 3=RGB_888, 4=RGBA_8888, 5=RGBX_8888)
                     
          )

      (if (not (= inAskAfter TRUE)) (gimp-image-clean-all image))
      (set! i (- i 1))


)))

(script-fu-register "script-fu-pxl-save-all-images-as-bmp"
"5 - As BMP..."
"Export all opened images at once as BMP with your settings..."
"PixLab"
"GPL-v2+"
"2023/12/12"
"*"
SF-DIRNAME    "Select a directory to export your images" "Desktop"
SF-TOGGLE     "Ask me to save the XCF when closing GIMP or an image" TRUE
SF-STRING     "Input an image base name" "IMAGE-"
SF-ADJUSTMENT "Input a start number for image name auto-numbering" (list 0 0 999999 1 100 0 SF-SPINNER)
SF-TOGGLE     "RLE Compression (Only valid for 4 & 8-bit indexed images)" FALSE
SF-TOGGLE     "Do Not Write BITMAPV5HEADER color space data" FALSE
SF-OPTION     "Advanced options: Export format for RGB images" (list "32-bit RGBA 8888" "32-bit RGBX 8888" "24-bit RGB 888" "16-bit RGB 565" "16-bit RGBA 5551" "16-bit RGB 555")
SF-OPTION     "Select How to Export (Explanations in the manual)" (list "Automated: Above settings for all images" "Full control: You confirm each setting on each image" "Use settings from latest Export")
)
(script-fu-menu-register "script-fu-pxl-save-all-images-as-bmp" "<Image>/File/E_xport/Export All Images As")


hopping some will find it useful ;)

_________________
Patrice


Top
 Post subject: Re: Batch export all opened images script for GIMP
PostPosted: Mon Dec 25, 2023 3:47 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
gasMask wrote:
Patrice,
Have you thought about creating a code repository on GitHub? It's pretty easy to do.

Yeah... OK, on a second though, you're right
I had an "old" account (used mostly to comment or post issues) that I "revived", it's over-there now > https://github.com/PatLabGit/GIMP-Export-All-Images-As

_________________
Patrice


Top
 Post subject: Re: Batch export all opened images script for GIMP [Update]
PostPosted: Mon Feb 19, 2024 12:03 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
Updated the script > https://gitlab.com/_PixLab/GIMP-Export-All-Images-As

_________________
Patrice


Top
 Post subject: Re: Batch export all opened images script for GIMP
PostPosted: Mon Feb 19, 2024 12:06 am  (#10) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
PixLab wrote:
gasMask wrote:
Patrice,
Have you thought about creating a code repository on GitHub? It's pretty easy to do.

Thanks, for the suggestion, but I got one from years ago to report bugs or ask questions (still never use it for something else, thus I don't know how to use it, even if I tried to push some buttons there or over there, not knowing what did I do :hehe )
Anyway now it's GitHub = Microsoft = the Damocles' sword... Hum... I don't like to have the sword of Damocles hanging around above my head :mrgreen: and still, I'm very much holding the grudge about what they did to Atom :cry


I was so damn right with github and Micro$oft.. Now I'm fvcked, cannot connect anymore to my account without giving them my phone number, no F@#$%& way!

Attachment:
screenshot_20240219-124228.jpg
screenshot_20240219-124228.jpg [ 71.11 KiB | Viewed 33635 times ]

_________________
Patrice


Top
 Post subject: Re: Batch export all opened images script for GIMP [Update]
PostPosted: Mon Feb 19, 2024 4:04 am  (#11) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2610
I use a YUBIkey (usb device) for my Google email accounts.

edit: Been using this for the last 3 years: https://www.amazon.co.uk/Thetis-Two-Fac ... th=1&psc=1

It might / might not still be possible to use one for GitHub

https://docs.github.com/en/authenticati ... entication.

You might have to use the GitHub app initially to set it up. I do not know if you still have to give your phone number.
https://docs.github.com/en/get-started/ ... hub-mobile


Top
 Post subject: Re: Batch export all opened images script for GIMP [Update]
PostPosted: Mon Feb 19, 2024 10:50 pm  (#12) 
Offline
GimpChat Member
User avatar

Joined: Jul 04, 2019
Posts: 282
Location: Lake Havasu City, Arizona, USA
Patrice,
I agree with you. Github changed their security policy. It's a hassle now. IMHO, providing a phone number to a service provider is a global data broker scam.

_________________
Charles


Top
 Post subject: Re: Batch export all opened images script for GIMP [Update]
PostPosted: Tue Feb 20, 2024 12:53 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
rich2005 wrote:
I use a YUBIkey (usb device) for my Google email accounts.

edit: Been using this for the last 3 years: https://www.amazon.co.uk/Thetis-Two-Fac ... th=1&psc=1

It might / might not still be possible to use one for GitHub

https://docs.github.com/en/authenticati ... entication.

You might have to use the GitHub app initially to set it up. I do not know if you still have to give your phone number.
https://docs.github.com/en/get-started/ ... hub-mobile


Thanks a lot Rich, but today I did found a way, I downloaded > https://2fas.com/ on my phone, and it worked, it's open source, no data collections, no phone number, no whatnot perso, although 30 seconds it's way too short for me, I got lucky to have input the code just a second before it changes...
Anyway, it's just to delete my forks and things on github.
Again, thank you Rich :tyspin

_________________
Patrice


Top
 Post subject: Re: Batch export all opened images script for GIMP [Update]
PostPosted: Tue Feb 20, 2024 1:36 am  (#14) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
gasMask wrote:
Patrice,
I agree with you. Github changed their security policy. It's a hassle now. IMHO, providing a phone number to a service provider is a global data broker scam.


I'm now on gitlab, they send you en email with a code when you connect, no BS, no app, no third party :bigthup
also transferring all my repos from github to gitlab was just 1 click simple and easy, as a matter of fact I was astonished how simple it was, great job gitlab :clap

_________________
Patrice


Top
 Post subject: Re: Batch export all opened images script for GIMP [Update]
PostPosted: Mon Jul 15, 2024 4:22 pm  (#15) 
Offline
GimpChat Member

Joined: Jul 15, 2024
Posts: 5
Hi PixLab

I have tons of JPG images on my mobile phone, each of which is more than 1.3MB in size.

I wish to reduce the file sizes of these JPG images.

I am using Microsoft Windows 11 64-bit and Gimp 2.10.38

When I open a JPG file, there's a dialog box with the title "Convert to RBG Working Space?"

I'm given two options: Convert or Keep

Well, I choose Convert

Next, I click on File --> Export As

I click on the button called Export and a dialog box appears with the words "A file named xxxxx.jpg already exists. Do you want to replace it?"

I click on the button called Replace

Next a box called Export Image as JPEG appears

I want to set the Quality at 50

I don't want to tick/check the boxes next to:

Save Exif data
Save XMP data
Save color profile

I don't wish to have automatic renaming of JPG files because I wish to keep the original JPG filenames.

Can you help me to come up with a script that does the above please?

Thank you in advance for your help.


Top
 Post subject: Re: Batch export all opened images script for GIMP [Update]
PostPosted: Tue Jul 16, 2024 2:27 am  (#16) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2610
Irrespective of PixLabs script, what you are describing is a batch plugin.

Quote:
I have tons of JPG images on my mobile phone, each of which is more than 1.3MB in size.
I wish to reduce the file sizes of these JPG images.


...but first a mention of jpeg compression. It is not linear, there is not much file size difference between quality=70 and quality=50 but you can get a lot of degradation at lower values. This is a typical curve (it always depends on the images and the purpose)

Attachment:
jpeg-compression.jpg
jpeg-compression.jpg [ 15.13 KiB | Viewed 16012 times ]


There is the Gimp batch plugin BIMP see: https://alessandrofrancesconi.it/projects/bimp/ and you can re-encode a folder full of jpegs like this:

Attachment:
bimp.jpg
bimp.jpg [ 96.44 KiB | Viewed 16012 times ]


Really recommend keeping the originals safe somewhere. Once squashed, always squashed. Those settings get the example image down from 1.26 MB to 334 KB


Top
 Post subject: Re: Batch export all opened images script for GIMP [Update]
PostPosted: Tue Jul 16, 2024 3:34 am  (#17) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 859
Location: SEA - South East Asia
My script has no access to these options (I would recommend to keep the color profile, though)
Save Exif data
Save XMP data
Save color profile

The plugin that rich2005 gave you is excellent, and I recommend it as well!
But for this very kind of batch processing, I won't use GIMP.
I would use ImageMagick > https://imagemagick.org/ but it's a command line software, for a graphical software I would use XnConvert > https://www.xnview.com/en/xnconvert/ , it's easy and it is extremely fast to batch process thousands of pictures.

_________________
Patrice


Top
 Post subject: Re: Batch export all opened images script for GIMP [Update]
PostPosted: Tue Jul 16, 2024 7:54 am  (#18) 
Offline
GimpChat Member

Joined: Jul 15, 2024
Posts: 5
rich2005 wrote:
It is not linear,


Could you explain that statement of yours please? I don't have much technical background in graphics.

rich2005 wrote:
This is a typical curve (it always depends on the images and the purpose)


Referring to the typical curve, could you tell me what the text in light blue/teal says please? I've a hard time reading the words.

rich2005 wrote:
There is the Gimp batch plugin BIMP see: https://alessandrofrancesconi.it/projects/bimp/ and you can re-encode a folder full of jpegs like this:


Thanks for your recommendation.

Is there a limit to the number of JPG files that I can process for the output folder? I have about two thousand photos stored on my mobile phone.

rich2005 wrote:
Really recommend keeping the originals safe somewhere. Once squashed, always squashed.


If that's the case, then I don't see any good reason to reduce the file sizes of my JPG files.

On the other hand, I don't want to buy a 2TB or 4TB portable SSD just for storing the screenshots that I take with my mobile phone.

rich2005 wrote:
Those settings get the example image down from 1.26 MB to 334 KB


That's quite a significant reduction in file size, don't you agree with me?

But then again, according to the very useful diagram that you attached to your reply, for archival of personal photos, the quality setting should be between 85 and 95, yes/no?


Top
 Post subject: Re: Batch export all opened images script for GIMP [Update]
PostPosted: Tue Jul 16, 2024 8:22 am  (#19) 
Offline
GimpChat Member

Joined: Jul 15, 2024
Posts: 5
Hello Patrice

Thanks for your reply.

PixLab wrote:
But for this very kind of batch processing, I won't use GIMP.
I would use ImageMagick > but it's a command line software,


I've heard about ImageMagick a lot because I use Debian 12 (a.k.a. bookworm) 64-bit version as well. I'm just a casual user of Linux distros and am not proficient in using them.

I prefer to use the Debian package manager to install ImageMagick. The version of ImageMagick for Debian Bookworm is 8:6.9.11.60+dfsg-1.6+deb12u1

Can you send me a PM containing the commands to reduce the file sizes of my JPG photos in bulk please?

PixLab wrote:
for a graphical software I would use XnConvert, it's easy and it is extremely fast to batch process thousands of pictures.


Thanks again, Patrice, for your recommendation.

Does XnConvert has a limit to the number of JPG files to be process each time? For example, XnConvert can only process 50 jpeg files each time??

P.S.: The forum forbids me to include off-site URLs for a new user (I'm a new user.)


Top
 Post subject: Re: Batch export all opened images script for GIMP [Update]
PostPosted: Tue Jul 16, 2024 9:02 am  (#20) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2610
The compression curve. As you can see it is a curve not a straight line. You can not use a linear interpolation. For example the amount of compression for quality=50 is not half of quality=100 (yes a 100 jpeg is still compressed). Do not worry about it.

Quote:
Referring to the typical curve, could you tell me what the text in light blue/teal says please? I've a hard time reading the words.


It says use quality 40 to 60 for posting images on the internet. Smaller file sizes = saving on band with / site storage...

Quote:
On the other hand, I don't want to buy a 2TB or 4TB portable SSD just for storing the screenshots that I take with my mobile phone.
rich2005 wrote: Those settings get the example image down from 1.26 MB to 334 KB
That's quite a significant reduction in file size, don't you agree with me?


Up to you, always a chance you lose all you work without backups. The reduction in size is what you get with your specified quality=50

------and I will throw this in-------

BIMP. Using Debian so that might not be available unless you compile it yourself. A flatpak Gimp does have it as a special flatpak BIMP version. No limit of the number of files but it might be slow. So lets forget BIMP

ImageMagick. This very straight forward. Go to the folder containing the jpegs and if you want a size of about say, 400 kb (your quality=50 requirement) the command in a terminal is:

mogrify -define jpeg:extent=400kb *.jpg


Beware mogrify will overwrite the original sized image. It might slow down where there are many images.

XnConvert - yes there is a linux version. I often use the larger XnViewMP - I use the linux appimage.


Top
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group