[Gimp-user] gimp-file-save : how to specify the JPEG quality



Hi,

I've found a script for batch "wavelet sharpening" all images in a folder.
This .scm script uses the function gimp-file-save.
The (sharpened) image has only 6 instead of 10 Mbytes. A JPEG quality estimator shows
98% for the original file and only 90% for the sharpened file.
When exporting a file to JPEG interactively one can specify the quality.
But how to do this in a non-interactive procedure.

Here is the full procedure
;
; Version 1.0 07.02.2012 for capnhud

; See http://gimpchat.com/viewtopic.php?f=8&t=3701

; command line
; gimp -i -f -d --verbose -b "(batch_wavelet_sharpen <AMOUNT> <RADIUS> \".jpg\" \"sharpened\")" -b "(gimp-quit 0)"

(define selffilename "\n- batch_wavelet_sharpen.scm")

; Batch mode wrapper
(define (batch_wavelet_sharpen amount radius file_extension destination_directory)
  (let*
    (
      (destination_file "")
(varFileList (cadr (file-glob (string-append "*" file_extension) 1))) ; make a list of all the files that match the file extension

      ; Adjust these values to suit
;      (amount 0.3)
;      (radius 1.0)
      (luminance TRUE)
    )
    (gimp-message-set-handler ERROR-CONSOLE)
    (if (not (file-exists? destination_directory))
(error (string-append "Error: directory " destination_directory " doesn't exist"))
      (if (= (file-type destination_directory) FILE-TYPE-DIR)
        ()
(error (string-append destination_directory " is not a directory"))
      )
    )

    ; loop through all the files in the list
    (for-each
      (lambda (filename)
        (let* (
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename))) ; load the image
               (drawable (car (gimp-image-flatten image)))
              )
              (gimp-message (string-append "processing-" filename))

;             Thing to do goes here
(plug-in-wavelet-sharpen RUN-NONINTERACTIVE image drawable amount radius luminance)

(set! destination_file (string-append destination_directory DIR-SEPARATOR filename)) (gimp-file-save RUN-NONINTERACTIVE image drawable destination_file destination_file) (gimp-image-delete image) ; unload the image
        )
      )
      varFileList
    )
  )
)




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]