Post Reply 

how do I pre-apply filters?

Jan 7, 2011, 00:22
Post: #1
how do I pre-apply filters?
I am using gimp 2 to make a cartoon/rotoscope video. I used a separate program to remove each individual frame (2400+ frames) from a video as still images that can then be edited in Gimp. What I do is open the image, add two filters, then I save the image. The problem is repeating this over and over for each frame is getting to be very cumbersome and annoying. Is there a way to have the filter apply themselves automatically each time I open a new image? It would make things a lot easier and it would make the process go by much faster. It's annoying having to choose the filters from the drop down list every single time, especially when i keep applying the same 2 filters with the same exact settings every time. The same goes for the size of the image. Is it possible to just set gimp to a certain size and have it open at that same size every single time? It keeps asking me what size I want every time I open a new file. Gimp does remember the last size I typed in, but it still asks me to confirm it every single time i click new.
Find all posts by this user
Quote this message in a reply
Jan 7, 2011, 18:14
Post: #2
RE: how do I pre-apply filters?
I have no idea how to do any scripting (the whole scripting thing is confusing to me). I did try some batch plug ins though , but unfortunately they don't work for what I need. They only do basic things such as crop or re -size. What I need is a batch plug-in/feature that will allow me to apply any of the gimp filters (for this particular project I'm using cartoon and photocopy) onto all the images all at once, bypassing the need for me to spend hours adding these filters individually to each frame.
Find all posts by this user
Quote this message in a reply
Jan 7, 2011, 21:18
Post: #3
RE: how do I pre-apply filters?
Ok, the frames that I'm working on are 640 x 480 (VGA resolution). I have about 2,430 frames (in jpg) that need the following two filters: Cartoon and Photocopy (both should be under artistic in the filters menu).

I'm using photocopy with the following settings:

Mask radius- 8.00
Sharpness- 0.800
Percent black- 0.200
Percent white- 0.200

...and cartoon with the following settings:

Mask radius- 7.00
Percent black- 0.200

Now, when I create the batch, I would like for all the newly filtered images/frames to stay individual. For example, after everything is done I want each image to be save-able individually and Not as one large file that contains all the images as one.

Thanks.
Find all posts by this user
Quote this message in a reply
Jul 16, 2013, 22:52 (This post was last modified: Jul 17, 2013 20:34 by chicortiz.)
Post: #4
How to apply filters to multiple images?
Hello! Sorry for reviving this old one but it addresses exactly what I need to know Wink

I Would like to make three questions.

Im following the instructions provided here, I need to apply the same filter for multiple images:

http://www.gimp.org/tutorials/Basic_Batch/

Im trying to execute the "Processing several files" section at the moment.

Im running GIMP version 2.8.4. on MacOSX 10.6.8

So here is how Im proceeding:

1) Starting the GIMP using "_-b_-" :

' Wrote:Macintosh:MacOS chicortiz$ ./GIMP -b -
GIMP
.
/Applications/GIMP.app/Contents/MacOS/:/Applications/GIMP.app/Contents/Resour
ces/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/loc
al/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/
2.6/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/loc
al/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/
bin:/usr/X11/bin

(GIMP-bin:38812): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
Cannot spawn a message bus without a machine-id: Unable to load /var/lib/dbus/machine-id or /etc/machine-id: Failed to open file '/var/lib/dbus/machine-
id': No such file or directory
Fontconfig warning: ignoring UTF-8: not a valid region tag

(script-fu:38821): GLib-WARNING **: (gerror.c:390):g_error_new_valist: runtime check failed: (domain != 0)
script-fu-Warning: Error while loading /Applications/GIMP.app/Contents/Resources/share/gimp/2.0/scripts/teste.scm:

Error: (/Applications/GIMP.app/Contents/Resources/share/gimp/2.0/scripts/teste.scm
: 1) eval: unbound variable: Welcome



(script-fu:38822): GLib-WARNING **: (gerror.c:390):g_error_new_valist: runtime check failed: (domain != 0)
Welcome to TinyScheme, Version 1.40
Copyright © Dimitrios Souflis

ts>
(script-fu:38832): GLib-WARNING **: (gerror.c:390):g_error_new_valist: runtime check failed: (domain != 0)

(script-fu:38832): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.

(script-fu:38832): Gtk-WARNING **: Error loading icon: Couldn't recognize the image
file format for file '/Applications/GIMP.app/Contents/Resources/share/gimp/2.0/themes/Default/images
/stock-question-64.png'

(script-fu:38873): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.

2) Ignoring what the terminal is returning and accessing menu bar "Filters" --> "Script
Fu" --> "Console"

3) Copying and pasting this to the console:

' Wrote:(define (batch-unsharp-mask pattern
radius
amount
threshold)
(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)))))

4) Saving the script inside: "Aplications/GIMP.app/Contents/Resources/share/gimp/2.0/scripts" As "test.scm" by using the save function inside the Gimp's console.

5) Accessing the menu bar "Filters" again and trying the "Refresh Scripts" option inside "Script Fu" gives me this inside the Gimp's console (I don't know why Im doing this step BTW):

' Wrote:> gimp -i -b '(batch-unsharp-mask "*.png" 5.0 0.5 0)' -b '(gimp-quit 0)'
Error: ( -i -b '(batch-unsharp-mask "*.png" 5.0 0.5 0)' -b '(gimp-quit 0)' : 2) eval:
unbound variable: gimp

So considering the proceeding above I have three questions:

I) Is it necessary to update the scripts described inside the GIMP -Batch Mode link ? If so please what is the current version for those:

A)
' Wrote:(set! drawable (car (gimp-image-get-active-layer image)))

B)
' Wrote:(define (batch-unsharp-mask pattern
radius
amount
threshold)
(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)))))

C)
Quote: gimp -i -b '(batch-unsharp-mask "*.png" 5.0 0.5 0)' -b '(gimp-quit 0)'

II) Im sorry but I don't know how to interpret where the images are being saved by reading those scripts. Is it mandatory to "open the image as layers"? If not how to specify the location?

III) How can I fix those dumb gigantic quotes to keep the alignment of this post fine? Blush EDIT: Fixed: press enter to break big lines.

Thank you very much for your time,

Ortiz
Find all posts by this user
Quote this message in a reply
Jul 17, 2013, 01:00 (This post was last modified: Jul 17, 2013 20:34 by chicortiz.)
Post: #5
RE: how do I pre-apply filters?
Thank you so much ofnuts for your quick reply!

I will try again with your instructions. I hope to post the result pretty son.

Already wrote to the Admin for more informations on how should I fix the alignment issue, i hope to fix this son too.
EDIT: Fixed: just use enter to break long lines.

Yours,

Ortiz
Find all posts by this user
Quote this message in a reply
Jul 18, 2013, 01:15 (This post was last modified: Jul 18, 2013 01:41 by chicortiz.)
Post: #6
RE: how do I pre-apply filters?
Im supposing that what this command
' Wrote:gimp -i -b '(batch-unsharp-mask "*.png" 5.0 0.5 0)' -b '(gimp-quit 0)'
does is:

It opens the Gimp and tell it to use the unsharp mask filter for all the files specified at the ".*png" field, replace them and then quit the GIMP.

If so, this is just what i need!

Considering that the above assumption is correct a few more questions:

1) Should I use the operational system terminal to use this command or the GIMP's console? (Just checking).

2) GIMP is located at:
' Wrote:/Applications/GIMP.app/Contents/MacOS

My folder (full of .pngs pictures) is located at:
' Wrote:/Desktop/test

So what is the correct command structure to make the magic happen?

Considering the sample I guess should be something like this:
' Wrote:./GIMP -i -b '(batch-unhsarp-mask "/Desktop/test/*png"' -b '(gimp-quit 0)'


Sample (from http://www.gimp.org/tutorials/Basic_Batch/)
' Wrote:./GIMP -i -b '(batch-unhsarp-mask "/Desktop/test/*png"' -b '(gimp-quit 0)'

Im trouble to manage the "*.png" field here, how should I handle the directory and the .png extension? The terminal is returning this:
' Wrote:GIMP
.
/Applications/GIMP.app/Contents/MacOS/:/Applications/GIMP.app/Contents/
Resources/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:
/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework
/Versions/2.6/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local
/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local
/bin:/opt/X11/bin:/usr/X11/bin
Fontconfig warning: ignoring UTF-8: not a valid region tag
batch command executed successfully

3) I would like to apply the same principle for the "Oilify" filter inside the "Artistic" submenu, but I don't know where the corresponding .scm file is located, and how to set the parameters using the command line for the Oilify filter.

Thank you very much for you time again!

Ortiz

###

Edit: Damit! Looks like Oilify is not ".scm" but ".so" What to do now? XD

(located at Contents/Resources/lib/gegl-0.2)
Find all posts by this user
Quote this message in a reply
Jul 18, 2013, 14:46 (This post was last modified: Jul 18, 2013 14:51 by chicortiz.)
Post: #7
RE: how do I pre-apply filters?
Ok.

I did a search at the Gimp's console and the results were:

plug-in-oilify

and

plug-in-oilify-enhanced

I think that "plug-in-oilify-enhanced" is what I need. I can't tell by the Script Fu procedure Browser where it's located in the system, but the browser gives me some interesting additional information which I think will be useful to generate the .scm script:

' Wrote:plug-in-oilify-enhanced
GIMP Plug-In

Smear colors to simulate an oil painting

Parameters
run-mode INT 32 The { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }

image IMAGE Input image (unused)
drawable DRAWABLE Input drawable
mode INT32 Algorithm { RGB (0), INTENSITY (1) }
mask-size INT32 Oil paint mask size
mask-size-map DRAWABLE Mask size control size
exponent INT32 Oil paint exponent
exponent-map DRAWABLE Exponent control map

Additional Information

This function performs the well-known oil-paint effect on the specified drawable.

Author: Torsten Martinsen, Daniel Richard G.
Date: 2007
Copyright: Torsten Matinsen, Daniel Richard G.


Forgive me any typos I copied it by hand since GIMP don't let me select the text Wink

So now i need to elaborate the .scm script, figure out where is the right place to put it in and use the right command to execute it for a bunch of pictures. I don't know how to program .scm but i found this sample (http://www.gimptalk.com/index.php?/topic...command/):

' Wrote:(define (batch-oilify-mask pattern mask_size mode)
(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-oilify RUN-NONINTERACTIVE image drawable mask_size mode)
(gimp-file-save RUN-NONINTERACTIVE
image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))

And the command should be something like:
' Wrote:(batch-oilify-mask "c:\anim\*.bmp" 7 1)

Because Im running on MacOSX the command for me it should be:
' Wrote:(batch-oilify-mask "/Desktop/test/*png" 7 1)

I executed it at the script fu console and got this in return:
' Wrote:> (batch-oilify-mask "/Desktop/test/*png" 7 1)
()

And there is nothing in the system Terminal.

I saved the scm script above as "batch-oilify-mask.scm" inside the following directory:
' Wrote:/Applications/GIMP.app/Contents/Resources/share/gimp/2.0/scripts


But the images didn't get affected by the oilily script. Maybe there is something wrong with this .scm sample or Im using the wrong directory to put the scm script? Help!

Thank you! Smile

Ortiz
Find all posts by this user
Quote this message in a reply
Jul 19, 2013, 02:35 (This post was last modified: Jul 19, 2013 02:37 by chicortiz.)
Post: #8
RE: how do I pre-apply filters?
Hi!

Here is my (still, Im sorry) failed scm attempt:
' Wrote:(define (batch-oilify-mask pattern mask_size mode)
(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-oilify RUN-NONINTERACTIVE image drawable INT32 { RGB (0), INTENSITY (1) })
(gimp-file-save RUN-NONINTERACTIVE
image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))

Im still using the following command:
' Wrote:(batch-oilify-mask "/Desktop/test/*png" 7 1)


Nothing inside the terminal and the console keep returning "()"

Here is a screenshot of the oilily tool:

[Image: GimpScreen.png]

So probably intensity "(1)" stands for true since the default value is intensity algorithm set "on".

Mask sizeā€¦ According to the documentation "INT32". Something related to 32 bits maybe? Why the default is 32? I can't handle what "mode" stands for, there is no such option inside the tool options (screenshot).

Thank you so much for your dedication ofnuts Smile

Ortiz
Find all posts by this user
Quote this message in a reply
Jul 19, 2013, 08:47
Post: #9
RE: how do I pre-apply filters?
Firstly I recommend having the Error console open, because then you will see this error when you try and run your code:
Code:
Error while executing batch-oilify-mask:

Error: eval: unbound variable: INT32

As offnuts already said, you need to change your line:
Code:
(plug-in-oilify RUN-NONINTERACTIVE image drawable INT32 { RGB (0), INTENSITY (1) })
to :
Code:
(plug-in-oilify RUN-NONINTERACTIVE image drawable mask_size mode )

And because I like to make things easy for myself I always make a menu entry for batch scripts so I can try them out quicker:

Code:
(define (batch-oilify-mask pattern mask_size mode)
  (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-oilify RUN-NONINTERACTIVE image drawable INT32 { RGB (0), INTENSITY (1) })
            (plug-in-oilify RUN-NONINTERACTIVE image drawable mask_size mode)
            (gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
            (gimp-image-delete image)
      )
      (set! filelist (cdr filelist))
    )
  )
)

(script-fu-register "batch-oilify-mask"
            _"<Image>/contributed/Interactive Batch Oilify..."
            "Interactive front end to batch oilify"
            "I did this"
            "GPL License"
            "19/07/2013"
            "*"
                    SF-STRING   _"Pattern" "*.png"
            SF-ADJUSTMENT _"Mask Size" '(7 1 3872 1 10 0 1)
            SF-ADJUSTMENT _"Mode" '(1 1 3872 1 10 0 1)
)

I hope you're trying to run this on copies of your originals because it will replace anything it finds with an "oilified" version.

Kevin
Find all posts by this user
Quote this message in a reply
Jul 19, 2013, 23:22 (This post was last modified: Jul 21, 2013 23:34 by chicortiz.)
Post: #10
RE: how do I pre-apply filters?
(Jul 19, 2013 07:19)ofnuts Wrote:  My dedication won't replace a two-years university cursus in programming Smile

Im sorry but now, you are wrong.

I did it after all! And I found the right answer because of the keywords you gently shared with everyone. Smile

Look the right script is this one:

batch-oilify.scm

' Wrote:(define (batch-oilify-mask pattern mask_size mode)
(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-oilify RUN-NONINTERACTIVE image drawable mask_size mode)
(gimp-file-save RUN-NONINTERACTIVE
image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))

I copied the scm script inside two folders of GIMP, MacOsx version 2.8.4:

1)
/Applications/GIMP.app/Contents/Resources/share/gimp/2.0/scripts

2)
/Applications/GIMP.app/Contents/Resources/lib/gimp/2.0/plug-ins

I moved my folder filled with .png pictures to the "/" directory.

So the final command, using the script fu console is:

(batch-oilify-mask "/test/*.png" 7 1)

Thank you very much for your help. I hope to post an animation sample pretty soon demonstrating the effect Smile

###

Edit: Lol I posted the reply while paynekj was writing his post too! Thank you paynekj!

Many thanks to Yorik Van Havre too for testing this procedure in Linux, which led me to the right solution inside MacOSX.
Find all posts by this user
Quote this message in a reply
Jul 21, 2013, 22:23 (This post was last modified: Jul 21, 2013 23:35 by chicortiz.)
Post: #11
RE: how do I pre-apply filters?
As I promised, just a tiny sample illustrating what can be done. I over exaggerated the effect to make it more visible because as you know, the palette is more restrict on .gifs ; )

[Image: Edge3.gif]

Thank you very much Gimp community,

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


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How to apply Lighting Effects for entire image Graphicman2014 3 398 Aug 21, 2014 23:24
Last Post: Graphicman2014
  How to apply text to each individual layer? Corey88 2 932 Nov 18, 2011 10:27
Last Post: rich2005
  Convert for Smart Filters and other Photoshop stuff sja785 1 3,020 Aug 11, 2011 15:28
Last Post: sja785

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS