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, 18:16
Post: #2
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
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Batch create images from array edmilner 1 662 Jul 17, 2017 16:41
Last Post: ythgilb
  How to close gimp with batch command? flixe 1 685 Jun 19, 2017 12:29
Last Post: ythgilb
  Bashing my head - Batch Python Script nmiltner 1 783 Sep 5, 2014 00:58
Last Post: nmiltner
  Batch processing script Help jarboe3142 1 686 Jun 1, 2014 18:45
Last Post: rich2005
  GIMP batch process script run-time error Paddy Landau 2 1,506 Apr 8, 2014 20:33
Last Post: Paddy Landau

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS