Post Reply 

Using Smart Sharpen in batch mode?

Jun 26, 2011, 15:02
Post: #1
Question Using Smart Sharpen in batch mode?
Hi
I use a lot the very useful smart sharpen plug-in for my pictures.
However in order to use it I have to manually open an image and go to Filter→Enhance →Sharpen (Smart Redux) and this take quite some time to do for every image.
I was thus wondering if it was possible to use it in batch mode.
I am not familiar with this mode but I read the tutorial about it on the gimp website and came up with the following script:
Code:
(define (smartsharpen filename
                      radius
              amount
              threshold
              refocus
              size
              circle
              gauss
              correlation
              noise
              edgedetect
              edgeamount
              flatten)
    (let* ((filelist (cadr (file-glob pattern 1))))
        (while (not (null? filelist))
            (let* ((filename (car filelist))
            (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
            (drawable (car (gimp-image-get-active-layer image))))
            (script-fu-Eg-SmartSharpen RUN-NONINTERACTIVE
                image drawable radius amount threshold refocus size circle gauss correlation noise edgedetect edgeamount flatten)
            (set! drawable (car (gimp-image-get-active-layer image)))
            (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
            (gimp-image-delete image)))

Which I then executed in a terminal like this:
Code:
gimp-2.7 -i -b '(smartsharpen "*.jpg" 2.00 1.00 0.00 TRUE 5.00 1.00 0.00 0.50 0.01 6.00 6.00 TRUE)' -b '(gimp-quit 0)'

And I also tried to use the smartsharpen script directly like that:
Code:
gimp-2.7 -i -b '(-Eg-SmartSharpen "*.jpg" 2.00 1.00 0.00 TRUE 5.00 1.00 0.00 0.50 0.01 6.00 6.00 TRUE)' -b '(gimp-quit 0)'

But every time I get the following error and the pictures aren't processed...
Code:
This is a development version of GIMP.  Debug messages may appear here.


(gimp:4266): Gimp-Core-CRITICAL **: gimp_viewable_get_stock_id: assertion `GIMP_IS_VIEWABLE (viewable)' failed
gimp: fatal error: Segmentation fault
gimp (pid:4266): [E]xit, [H]alt, show [S]tack trace or [P]roceed:

I am using gimp 2.7 on Ubuntu 11.04 with gimp-plugin-registry which contains the smart redux sharpen and refocus scripts.

So what am I doing wrong here?
Thanks for your answers!
Find all posts by this user
Quote this message in a reply
Jun 26, 2011, 16:02
Post: #2
RE: Using Smart Sharpen in batch mode?
Obviously something is trying to display something, and since there is no display...

I don't see anything obvious in your code that requires the availability of a display. It could be the filter trying to show a dialog despite the RUN-NONINTERACTIVE. Start Gimp without the "-i" to enable the display...

[Image: 2Tvo0.png]

Visit this user's website Find all posts by this user
Quote this message in a reply
Jun 26, 2011, 18:16
Post: #3
RE: Using Smart Sharpen in batch mode?
(Jun 26, 2011 16:02)ofnuts Wrote:  Obviously something is trying to display something, and since there is no display...

I don't see anything obvious in your code that requires the availability of a display. It could be the filter trying to show a dialog despite the RUN-NONINTERACTIVE. Start Gimp without the "-i" to enable the display...

Thanks for the answer. Indeed the -i option seems responisble for the Seg Fault. However I have an new problem...
I had some trouble with the batch process of multiple files so I to limit the numbers of problem I just changed my script to work on a single file and I will include everything in a bach script to have the multiple files.

Anyway, with the following script:
Code:
(define (batch-smartsharpen filename
                      radius
              amount
              threshold
              refocus
              size
              circle
              gauss
              correlation
              noise
              edgedetect
              edgeamount
              flatten)
   (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
          (drawable (car (gimp-image-get-active-layer image))))
            (script-fu-Eg-SmartSharpen RUN-NONINTERACTIVE
                image drawable radius amount threshold refocus size circle gauss correlation noise edgedetect edgeamount flatten)
            (set! drawable (car (gimp-image-get-active-layer image)))
            (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
            (gimp-image-delete image)))

and the following command:
Code:
gimp -b '(batch-smartsharpen "IMG_0065.jpg" 2.00 1.00 0.00 TRUE 5.00 1.00 0.00 0.50 0.01 6.00 6.00 TRUE)' -b '(gimp-quit 0)'

I get the following error (both in a pop-up and in the terminal):
Code:
batch command experienced an execution error:
Error: Procedure execution of gimp-image-convert-rgb failed on invalid input arguments: Image 'IMG_0065.jpg' (1) is already of type 'rgb'

plug-in 'script-fu' aborted before sending its procedure return values

And I don't know what to do. This seems to be a problem in script-fu-Eg-SmartSharpen. I gave a quick look to the script and it uses gimp-image-convert-rgb but with a if condition especially to check that the layer is not rgb...
The picture file is a standard jpeg (.jpg) picture taken directly from my canon 40D. I can open it without problem in Gimp or any other program... A .xcf version of the picture gives me the same error...
The script-fu-Eg-SmartSharpen works fine when used manually (and with the GUI) in Gimp so I am guessing I have to add something in my own script, but what?
Find all posts by this user
Quote this message in a reply
Jun 26, 2011, 20:20
Post: #4
RE: Using Smart Sharpen in batch mode?
I would first check that your "drawable" actually contains what you think it does.

Also nothing prevents you from taking the original script and adding whatever is needed to make it suit your particular needs (that's one of the benefits of GPL licensing). Doing so will likely give you a better understanding of how it works...

[Image: 2Tvo0.png]

Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Batch processing script Help jarboe3142 3 188 Jun 1, 2014 21:53
Last Post: paynekj
  GIMP batch process script run-time error Paddy Landau 4 474 Apr 8, 2014 22:42
Last Post: ofnuts
Question Unable to perform tasks in batch mode gnanasenthil654321 2 294 Mar 4, 2014 09:07
Last Post: paynekj
  Is there a Batch Plug-In for 2.8? RomanHoliday 2 294 Feb 12, 2014 03:00
Last Post: fluffybunny2
  Plugins in Batch Mode fergusondavid6 3 482 Jan 20, 2014 10:22
Last Post: rich2005

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS