Skip to content

Instantly share code, notes, and snippets.

@danstuken
Last active February 8, 2021 11:43
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save danstuken/3625841 to your computer and use it in GitHub Desktop.
Save danstuken/3625841 to your computer and use it in GitHub Desktop.
Batch Convert XCF to JPEG in GIMP
(define (script-fu-xcf2jpg-batch xcfDirectory inQuality)
(let* ((xcfList (cadr (file-glob (string-append xcfDirectory "/*.xcf") 1))))
(while (not (null? xcfList) )
(let* ((xcfFilename (car xcfList))
(jpgFilename (string-append (substring xcfFilename 0 (- (string-length xcfFilename) 4) ) ".jpg"))
(xcfImage (car (gimp-file-load RUN-NONINTERACTIVE xcfFilename xcfFilename)))
(xcfDrawable (car (gimp-image-flatten xcfImage))) )
(file-jpeg-save RUN-NONINTERACTIVE xcfImage xcfDrawable jpgFilename jpgFilename
inQuality 0.0 0 0 "" 0 1 0 2)
)
(set! xcfList (cdr xcfList))
)
)
)
(script-fu-register
"script-fu-xcf2jpg-batch"
"Batch XCF 2 JPEG"
"Converts all xcf files from a directory to JPEGS"
"Dan Kendall & Jérôme Combaz"
""
"Apr 20 2013"
""
SF-DIRNAME "Gimp Image Directory" "/tmp"
SF-ADJUSTMENT "Quality" '(0.85 0.00 1.00 0.01 0.1 2 0)
)
(script-fu-menu-register "script-fu-xcf2jpg-batch"
"<Toolbox>/Mine/Batch/2JPEG")
@danstuken
Copy link
Author

Updated to add a slider for the JPEG quality. Added Jérôme's name following some great contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment