Post Reply 

command-line optimizing

Jun 9, 2014, 08:37
Post: #1
command-line optimizing
Hi all,

after mixing-up multiple solutions, I finally got a batch command-line that performs my desired task. It runs on decent speed, but when I tried to process hundreds of files in one go, I would need to wait few minutes, so I'm wondering if the following command-line could be optimized, thank you.

for /f %f in ('dir /b c:\users\mini\desktop\testing') do "c:\program files\gimp 2\bin\gimp-console-2.8.exe" -i -d -f -s -b "(let* ((image (car (file-png-load 1 \"/Users/mini/Desktop/testing/%f\" \"/Users/mini/Desktop/testing/%f\") ) ) (drawable (car (gimp-image-active-drawable image ) ) ) ) (plug-in-colortoalpha 1 image drawable '(0 0 0) ) (gimp-file-save RUN-NONINTERACTIVE image drawable \"/Users/mini/Desktop/testing/%f\" \"/Users/mini/Desktop/testing/%f\") )" -b "(gimp-quit 0)"
Find all posts by this user
Quote this message in a reply
Jun 9, 2014, 10:57
Post: #2
RE: command-line optimizing
Looking at the examples on gimp org site

Ensure you're using the correct/proper function names.
Go to www gimp org / tutorials/Basic_Batch/ if you haven't already.

For example, here in your code...
(let* ((image (car (file-png-load

Did you mean "cadr" ?
In Gimps' last batch example, here is their code

(define (batch-unsharp-mask pattern
  (let* ((filelist (cadr (file-glob pattern 1))))
    (while (not (null? filelist))
           (let* ((filename (car filelist))
                  (image (car (gimp-file-load RUN-NONINTERACTIVE
                                              filename filename)))
                  (drawable (car (gimp-image-get-active-layer image))))
             (plug-in-unsharp-mask RUN-NONINTERACTIVE
                                   image drawable radius amount threshold)
             (gimp-file-save RUN-NONINTERACTIVE
                             image drawable filename filename)
             (gimp-image-delete image))
           (set! filelist (cdr filelist)))))

Last, try taking out one of each of the commands or using one at a time for each test run.

I see in your code you have all the commands at the start
... -i -d -f -s -b ...
Try one of the commands at a time with the exception of keeping the "-b" batch command in there to see if that speeds things up.

Hope this helps & if you get a new solution to it, please share so others can benefit ^_^

"In order to succeed, your desire for success should be greater than fear of failure." BC
[Image: 29uocaf.png]
iFS007 tut vids on YT ~ auto color B&W landscape tut
Visit this user's website Find all posts by this user
Quote this message in a reply
Jun 9, 2014, 16:37 (This post was last modified: Jun 9, 2014 17:04 by rich2005.)
Post: #3
RE: command-line optimizing
Am I reading that correctly? It applies color-to-alpha to a png file?

You can do that within Gimp with the BIMP batch plugin.

The simplest IM command (white to transparent) is
convert input.png -transparent white output.png

edit:pulled that out of my notes and it produces an indexed png file.
for RGB it is
convert input.png -transparent white png24:output.png

** now answering questions**
Find all posts by this user
Quote this message in a reply
Jun 11, 2014, 03:13 (This post was last modified: Jun 11, 2014 03:13 by wmichaelv.)
Post: #4
RE: command-line optimizing
Thanks for the replies, all.

(Jun 9, 2014 13:03)ofnuts Wrote:  For this kind of work, a gew minutes on several hundreds of files is OK. Your limiting factor could be disk I/O.

Since this is some very simple processing, you can try to use ImageMagick and command line scripts instead (IM is significantly easier than Gimp for this kind of batch processing, and writing scripts on OSX is eaasier than on WIndows). If you are not limited by your disk I/O, using IM will let you use all cores of your machine, either because it can use them natively, or because you can run several scripts in parallel.

I've used IM for this task, but I haven't found the solution to reproduce the color-to-alpha effect from GIMP on IM yet, so I ended up using GIMP instead.

I've tried various IM scripts though none of them give a result as good as gimp.

btw, this is based on your simple script on black color:

The car and cadr are based on the script-fu.
May I know why you are recommending on using cadr instead of car?
Find all posts by this user
Quote this message in a reply
Jun 11, 2014, 08:26 (This post was last modified: Jun 11, 2014 13:16 by rich2005.)
Post: #5
RE: command-line optimizing
hmm..never know what you are up against until you get a sample image and maybe still not exact.

The sample seems to have partial transparency and you get a reasonable result with

convert in.png -alpha set -channel RGBA -fill none -fuzz 30% -opaque black png24:out.png

more than 30% fuzz and you start removing bits of dark-red. Becoming almost as complicated as the gimp command line. As you say maybe not as good as gimp

The other suggestion was BIMP

looks like this

[Image: XTkNLdE.jpg]

comparison of results

[Image: A6CJ9RM.jpg]

edit: back to the original question -speed. Only a test with many images would determine.
I would think that IM would be quickest. Bimp is fast and of course flexible.

more edit: comparison speed test: 2097 100x100 tiles coloured with central black disk
read/write to the same hdd
BIMP 2 mins 20 seconds
IM 28 seconds including echoing the file name to show progress.

** now answering questions**
Find all posts by this user
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Freezes at start of line. DemonSlayer112 3 335 Mar 20, 2018 09:48
Last Post: paynekj
  command button changes mode during command "C" Terry50 1 266 Dec 29, 2017 04:50
Last Post: ythgilb
  Can't draw a clean line freehand Dave54 3 678 Jul 12, 2014 16:21
Last Post: Dave54
  How do I erase in a straight line? Terry50 2 1,924 May 12, 2014 03:11
Last Post: Terry50
  Can I make a line a specific size? jitter1127 2 1,849 Apr 25, 2014 08:58
Last Post: rich2005

Forum Jump:

GIMP ForumPortalArchiveContactTermsRSS