Post Reply 

batch despeckle

Feb 6, 2012, 11:13
Post: #1
batch despeckle
Hi,
I'd like to get gimp to despeckle all images of one folder, with the options adaptive, recursive, Radius = 3, black level = -1 und white level = 256), afterwards save the images to another folder. Unfortunately I'm no programmer und don't get the tutorials to write a batch skript.
I know it should be

gimp -i -b '(skript "*.png" 1 2)' -b '(gimp-quit 0)'

[instead of 'skript' the despeckle funktion], but how to write it? And where to run the skript? In the folder, containing the gimp exe?

I'm thankful for any kind of help!

kkiel
Find all posts by this user
Quote this message in a reply
Feb 7, 2012, 07:08
Post: #2
RE: batch despeckle
That should be relatively straightforward to do.

I'll try and write something later today, but it would be helpful to know what operating system you are using (Windows XP/Vista/7 Linux etc) and do you have Python support enabled in GIMP?

Kevin
Visit this user's website Find all posts by this user
Quote this message in a reply
Feb 7, 2012, 08:29
Post: #3
RE: batch despeckle
Thanks Kevin!

I use windows and don't have python on my PC.
There already is a despeckle plugin on e can find in the skript-fu repository. That works fine for me from the gimp GUI. I now only need to run it in batch mode. Maybe it isn't necessary to programm something new but to simply get it run from the command line? But how?
Thanks for any help!

kkiel
Find all posts by this user
Quote this message in a reply
Feb 8, 2012, 14:31
Post: #4
RE: batch despeckle
It is necessary to write something new, and I've attached my attempt at it. Sorry it's a zip file but this forum doesn't allow me to attach the .scm file Huh

The zip file also contains a DOS batch file that has the command line in it:
Code:
"C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe" -i -f -d --verbose -b "(kkiel_batch_despeckle \".png\" \"despeckle\")" -b "(gimp-quit 0)"

Although you may have to alter the path to the GIMP executable.

Note, the script will not work if the destination directory doesn't exist.

Kevin


Attached File(s)
.zip  kkiel_batch_despeckle.zip (Size: 1.33 KB / Downloads: 266)
Visit this user's website Find all posts by this user
Quote this message in a reply
Feb 8, 2012, 15:03
Post: #5
RE: batch despeckle
Hi Kevin,

this looks great (in notepad), thank you very very much! I'll test it this evening (after doing some backups ...) and tell you how it went.

Thank you very much again,

kkiel
Find all posts by this user
Quote this message in a reply
Feb 8, 2012, 20:06 (This post was last modified: Feb 8, 2012 20:07 by kkiel.)
Post: #6
RE: batch despeckle
Hi Kevin,
I copied the .scm-file into the gimp skripts folder, opend skript-fu via the filter menu, clicked refresh
skripts afterwards, but it doesn't show up in the skripts list. Was this the wrong way to deal with it?
Then, I don't get from where to start the DOS batch file. Where are the image files expected to be?
Thanks a lot!
kkiel
Find all posts by this user
Quote this message in a reply
Feb 8, 2012, 21:12
Post: #7
RE: batch despeckle
Correct me if I'm wrong but you asked for a batch file, not a script to be run interactively? So for a batch file you don't start gimp - the batch file does that.

Put the DOS batch file into the folder where your images are. Create a folder in the same directory called despeckle and then run the batch file by double-clicking on it.

Kevin
Visit this user's website Find all posts by this user
Quote this message in a reply
Feb 9, 2012, 07:33
Post: #8
RE: batch despeckle
Hi Kevin,

since the skript was an scm, not an exe, I thought it should be started from gimp. Anyway - your skript runs smoothly! I really am thankful, this saves me weeks of work!

kkiel
Find all posts by this user
Quote this message in a reply
Feb 19, 2012, 11:45
Post: #9
batch despeckle and meta-data
Hi Kevin and other readers looking for a solution for the despeckle problem:

The skript still works fine and the despeckling effect is just what I need, but Gimp destroys the iptc-data and maybe some other metadata (icc profile). My despeckled images wont show up in Lightroom and Faststone, though other readers (irfanview, imatch, xnview) don't have problems .
So I won't be able to use it like that. Does anybody know how to avoid that? Is it another line of code in the skript? There must be some metadata skripts in Gimp.
Thanks for any help!

kkiel
Find all posts by this user
Quote this message in a reply
Feb 19, 2012, 12:30
Post: #10
RE: batch despeckle
Your problem is that you are using PNG and there is no provision for EXIF/IPTC/XMP in this format... There is only a provision for a generic text comment (and Gimp seems to have the code to support that).

So you have two solutions:

1) Use high quality JPEG. Yes, JPEG is a lossy format, but at hight quality the loss is negligible for most purposes(*), and in any case if would be far less than what you lose in the despeckling anyway... You could also use TIFF (which is a lossless format fit to save "natural" images, and also supports EXIF/TIFF/XMP). Gimp normally keeps these metadata for these formats.

2) use some command line utility to copy metadata between original and processed files.

(*) There is a lot of paronoia about data loss in JPEG. The usual argument is that you lose some each time you edit the file. This is untrue... The JPEG algorithm, when implemented properly, is stable. The decoded pixels are reencoded with the same values so there is zero loss. Change occurs when the computation is different which happens when:

1) Quality settings are changed, but this is in general for a lesser quality
2) General color processing is applied. Loss due to JPEG is smaller that the round-off errors caused by the 8-bit processing in Gimp.
3) File is cropped on a boundary that displaces the 8x8 pixels blocks.

In other cases, where only local edit is performed, unchanged pixels get reencoded with the same values, so the loss is restricted to the one caused by the original encoding.

[Image: 2Tvo0.png]

Find all posts by this user
Quote this message in a reply
Feb 19, 2012, 15:02
Post: #11
RE: batch despeckle
Hi Ofnuts,

thank you for your prompt reply. My images are saved as tif, lzw-compressed, grayscale mode. I thus changed the command line in the dos batch file.
Are there other ways I messed the meta-data up?

Thank you!

kkiel
Find all posts by this user
Quote this message in a reply
Feb 20, 2012, 09:47
Post: #12
RE: batch despeckle
You didn't mess anything up. GIMP doesn't handle IPTC data at all. It gets dis-guarded when GIMP loads the image.

The only way other people have solved this problem is to use another tool to copy the meta-data out of the images before processing, then write it into the images after processing:

http://www.gimptalk.com/index.php?/topic...iptc-info/
Visit this user's website Find all posts by this user
Quote this message in a reply
Feb 20, 2012, 09:58
Post: #13
RE: batch despeckle
Hi paynekj,

I can afford to loose the IPTC-data because I can easily write them back with IMatch but what bothers me is that the images wont show up as a Lightroomthumbnail before importing ('no preview available') and as a Faststone thumbnail (thumbnails turn black). After importing to Lightroom though they are visible and Faststone will process the images further (lzw-compressing for example) without problems (though lightroom will have problems to show the previews of those before importing). I just want to make sure that standard image viewers will be able to cope with my images and that no seminal image information (icc profile, whatever) got lost.
So I will do some more checking before despeckling thousands of images ...
Thanks for your help!

kkiel
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Trying to install David's Batch Processing plugin, but i have problems purselover 2 93 Oct 27, 2014 09:55
Last Post: rich2005
  Bashing my head - Batch Python Script nmiltner 3 415 Sep 5, 2014 07:03
Last Post: ofnuts
  Batch processing script Help jarboe3142 3 528 Jun 1, 2014 21:53
Last Post: paynekj
  GIMP batch process script run-time error Paddy Landau 4 956 Apr 8, 2014 22:42
Last Post: ofnuts
Question Unable to perform tasks in batch mode gnanasenthil654321 2 585 Mar 4, 2014 09:07
Last Post: paynekj

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS