It is currently Sat Sep 19, 2026 10:25 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Using Wavelet Sharpen for a batch process.
PostPosted: Wed Feb 08, 2012 11:42 am  (#1) 
Offline
GimpChat Member

Joined: May 09, 2011
Posts: 28
GIMP Version: 2.6.12
Operating System: Windows
OS Version: XP - SP3
GIMP Experience: Beginner Level



Does anyone know how I can use the wavelet sharpen plugin on a directory of images (batch)?

I tried in the command line:

gimp.exe -i -b '(batch-wavelet-sharpen "*.jpg" 0.3 1.0)' -b(gimp-quit 0)'

and

C:\Program Files\GIMP-2.0\bin\gimp.exe -i -b '(batch-wavelet-sharpen "*.jpg" 0.3 1.0)' -b(gimp-quit 0)'

and

C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe -i -b '(batch-wavelet-sharpen "*.jpg" 0.3 1.0)' -b(gimp-quit 0)'

which gets me not a recognized command


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: Using Wavelet Sharpen for a batch process.
PostPosted: Wed Feb 08, 2012 12:46 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
You would need to write a script incorporating the call to plug-in-wavelet-sharpen

the script would need to get a list of the files to process - all files ending *.jpg ?
open each file in turn
call plug-in-wavelet-sharpen passing in the image numeric id and drawable numeric id
save the file - overwrite the original?


Top
 Post subject: Re: Using Wavelet Sharpen for a batch process.
PostPosted: Wed Feb 08, 2012 2:56 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
And here's a script to do it:
Attachment:
File comment: As usual a zip file because I can't attach plain script files.
batch_capnhud_wave_sharp.zip [1.13 KiB]
Downloaded 186 times


I've put the plug-inwavelet-sharpen parameters inside the script, but it would be relatively simple to make them command line values if you want.
      ; Adjust these values to suit
      (amount 0.3)
      (radius 1.0)
      (luminance TRUE)


From the Windows command line:
"C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe" -i -f -d --verbose -b "(batch_capnhud_wave_sharp \".jpg\" \"sharpened\")" -b "(gimp-quit 0)"
You may need to edit the path to the GIMP executable to match your system.

In the example above I've made the command line save the sharpened images into a folder called sharpened. If you want to overwrite your existing images change \"sharpened\" to \".\"

Kevin


Top
 Post subject: Re: Using Wavelet Sharpen for a batch process.
PostPosted: Wed Feb 08, 2012 3:58 pm  (#4) 
Offline
GimpChat Member

Joined: May 09, 2011
Posts: 28
paynekj wrote:
You would need to write a script incorporating the call to plug-in-wavelet-sharpen

the script would need to get a list of the files to process - all files ending *.jpg ?
open each file in turn
call plug-in-wavelet-sharpen passing in the image numeric id and drawable numeric id
save the file - overwrite the original?



Well that explains why running the commmand was not working.


paynekj wrote:
And here's a script to do it:


:coolthup Thank you for taking the time to do this.


Just one question what if the directory contained .png and .jpg would the part in the script change to \".jpg, .png\"


Top
 Post subject: Re: Using Wavelet Sharpen for a batch process.
PostPosted: Wed Feb 08, 2012 4:21 pm  (#5) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
capnhud wrote:
Just one question what if the directory contained .png and .jpg would the part in the script change to \".jpg, .png\"


No. The way the script is written it can only do one file type at a time, so run it on .jpg then change to .png and run it again.

Correction: if you make it \".*g\" then that matches .jpg and .png, but be warned this will match other things as well: .gig .pig .zog .anything_at_all_ending_in_a_g ..... you get the idea ;)

capnhud wrote:
:coolthup Thank you for taking the time to do this.


I feel I must confess that I didn't take all that much time as I've now made a template for this kind of request, mostly thanks to doing something very similar yesterday: http://gimpforums.com/thread-batch-despeckle

Kevin


Top
 Post subject: Re: Using Wavelet Sharpen for a batch process.
PostPosted: Thu Mar 15, 2012 11:03 am  (#6) 
Offline
GimpChat Member

Joined: May 09, 2011
Posts: 28
maybe I am doing something wrong with the script, but each time that I run the .bat file I get a command window that ends up indicating the following when attempting to process an image.

The .bat file is in the directory that the images are in so all I am trying to do is just process and overwrite but error prevents any processing from happening.

when I run the following from the command line or .bat file
"C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe" -i -f -d --verbose -b "(batch_capnhud_wave_sharp \".jpg\" \".\")" -b "(gimp-quit 0)"


i experience



No batch interpreter specified, using the default 'plug-in-script-fu-eval'.
script-fu.exe-Warning: processing-th_alps_60266_6743902.jpg

batch command experienced an execution error
EXIT: gimp_exit
EXIT: gimp_real_exit
Writing 'C:\Documents and Settings\Owner\.gimp-2.6\templaterc'
Writing 'C:\Documents and Settings\Owner\.gimp-2.6\parasiterc'
Writing 'C:\Documents and Settings\Owner\.gimp-2.6\unitrc'
EXIT: batch_exit_after_callback

(Type any character to close this window)



and script
;
; Version 1.0 07.02.2012 for capnhud

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

; command line for Windows:
; "C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe" -i -f -d --verbose -b "(batch_capnhud_wave_sharp \".jpg\" \"sharpened\")" -b "(gimp-quit 0)"

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

; Batch mode wrapper
(define (batch_capnhud_wave_sharp 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 0.5)
      (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
    )
  )
)


Top
 Post subject: Re: Using Wavelet Sharpen for a batch process.
PostPosted: Thu Mar 15, 2012 12:28 pm  (#7) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
You have commented out the definition of the amount variable:
      ;(amount 0.3)


So when the script gets to the place where it is used:
              (plug-in-wavelet-sharpen RUN-NONINTERACTIVE image drawable amount radius luminance)
It will be throwing up an unbound variable: amount error.

Kevin


Top
 Post subject: Re: Using Wavelet Sharpen for a batch process.
PostPosted: Thu Mar 15, 2012 1:42 pm  (#8) 
Offline
GimpChat Member

Joined: May 09, 2011
Posts: 28
:oops: I tabbed the wrong word when using autocomplete to help keep the original, but make changes as I needed. It never occurred to me that something was wrong with the script, since I have used it with no problems before. thank you for pointing out my mistake.

batch command executed successfully


Top
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group