YOUR ACCOUNT

Login or Register to post new topics or replies
MachinesInMotion
Posts: 3
Filters: 21
Hey Guys!
I threw together a little wrapper program that that runs FF over files directly from the command line (no XML file needed). It's been working for me, and hugely simplifies the process of running FF over a large number of files.

Usage: ffbat filename filter preset
Examples:
ffbat File.png Eyecraft 0
Outputs a copy of File.png with the Eyecraft filter applied(File.png -> File_Filter.png, etc)

ffbat * GlowingText 0
Outputs a copy of every file in the directory with the GlowingText filter applied(File1.png -> File1_Filter.png, etc)

Download Here

Instructions: Extract the zip somewhere and add that location to your path. It should work on its own from there.

Alternatively, download the source and install PIL, then add to your path and run it with ffbat.py file filter preset

Notes:
1) This scans common installation directories to get to the actual executable. If you installed Filter Forge somewhere else (like on a drive that isn't C), you'll have to add your Filter Forge bin directory to your path as well.
2) You need to have the filter in the "My Filters" pane for this to work, so if you are using a library filter, make a copy in My Filters (open the filter editor on it) before running this script.

Python source (Requires PIL to compile):
Code

import glob, os, sys, shutil, subprocess
from PIL import Image
from _winreg import *

print "Usage: ffbat source filtername preset\n"

try:
    presetValue = int(sys.argv[3])
except:
    print "Error: invalid preset"

#Set up the xml files
xml = open("temp.xml", 'w')
xml.write("""<?xml version="1.0"?>
<Tasks>
   <GlobalSettings>
      <RenderingOptions>
         <UseMultithreading value="true"/>
         <Dither value="true"/>
         <Progressive value="true"/>
         <OptimizeBlurs value="true"/>
         <AntiAliasBitmapComponentSources value="false"/>
         <Jitter value="0"/>
         <TemporaryFilesLocation value=""/>
         <RAMUsageLim it value="60"/>
         <NormalMapFlipY value="false"/>
      </RenderingOptions>
      <BitmapFormatOptions>
         <DefaultFormat value="JPG"/>
         <BMP>
            <BitDepth value="32"/>
            <FlipRowOrder value="false"/>
         </BMP>
         <JPG>
            <Quality value="98"/>
            <FullPrecision value="true"/>
         </JPG>
         <TIF>
            <BitDepth value="8"/>
            <FloatFormat value="false"/>
            <IncludeTransparency value="true"/>
            <ImageCompression value="LZW"/>
         </TIF>
         <TGA>
            <BitDepth value="32"/>
            <IncludeTransparency value="true"/>
            <FlipRowOrder value="false"/>
         </TGA>
         <PNG>
            <BitDepth value="16"/>
            <IncludeTransparency value="true"/>
            <ImageCompression value="BEST"/>
         </PNG>
         <EXR>
            <BitDepth value="32"/>
            <IncludeTransparency value="true"/>
            <ImageCompression value="PIZ"/>
            <FlipRowOrder value="false"/>
         </EXR>
         <PFM/>
      </BitmapFormatOptions>
   </GlobalSettings>""")
for name in glob.glob(sys.argv[1]):
    img = Image.open(name)
    width, height = img.size
    xml.write("""
    <Task>
        <Image value="{0}" width="{1}" height="{2}"/>
        <Selection value=""/>
        <Result path="{3}" format="{4}"/>
        <Filter value="{5}"/>
        <Preset value="{6}"/>
    </Task>""".format(name, width, height, name[0:-4] + "_filter.png", "PNG", sys.argv[2]+".ffxml", sys.argv[3]))
xml.write("\n    </Tasks>")
xml.close();
copied = False
#Set up the ffxml
try:
    shutil.copyfile(os.getenv("AppData") + "/Filter Forge 3/My Filters/" + sys.argv[2] + ".ffxml", os.getcwd() + "/"+sys.argv[2] + ".ffxml")
    copied = True
except:
    pass
try:
    shutil.copyfile(os.getenv("AppData") + "/Filter Forge 2/My Filters/" + sys.argv[2] + ".ffxml", os.getcwd() + "/"+sys.argv[2] + ".ffxml")
    copied = True
except:
    pass
try:
    shutil.copyfile(os.getenv("AppData") + "/Filter Forge/My Filters/" + sys.argv[2] + ".ffxml", os.getcwd() + "/"+sys.argv[2] + ".ffxml")
    copied = True
except:
    pass

#Run filter forge at all reasonable locations.
filtered = False
for string in """FFXCmdRenderer-x86-SSE2.exe
"C:\Program Files (x86)\Filter Forge 3\Bin\FFXCmdRenderer-x86-SSE2.exe"
"C:\Program Files\Filter Forge 3\Bin\FFXCmdRenderer-x86-SSE2.exe"
"C:\Program Files (x86)\Filter Forge 2\Bin\FFXCmdRenderer-x86-SSE2.exe"
"C:\Program Files\Filter Forge 2\Bin\FFXCmdRenderer-x86-SSE2.exe"
"C:\Program Files (x86)\Filter Forge\Bin\FFXCmdRenderer-x86-SSE2.exe"
"C:\Program Files\Filter Forge\Bin\FFXCmdRenderer-x86-SSE2.exe"
""".split("\n"):
    try:
        subprocess.call(string + " temp.xml")
        break
    except:
        pass

os.remove("temp.xml")
if copied:
    os.remove(sys.argv[2]+".ffxml")
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Great! Sounds also perfect for putting video or animation frames through a filter.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Hi MachinesInMotion,

I attempted to use this batch tool but it doesn't run and I cannot figure out why.

I have extracted the zip in the folder C:/admin/ffbat and have a bunch of jpeg images in the folder C:/admin/ffbat/images. I am trying to run a filter with the name AnimatedLensFlares, first preset. The filter is in My Filters.

As per the instructions I would gather the command should be:

ffbat\ffbat images\* AnimatedLensFlares 0

With that I get the result:

Code
Usage: ffbat source filtername preset

Filter Forge command line renderer, version 3.014.
© 2006-2012 Filter Forge Inc. All rights reserved.
Professional Edition
License Name: ThreeDee.


There are no error messages but nothing gets processed either.

Any ideas?
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Does this require that the images are .PNG files to work?
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Ok, I managed to get one specific file to render with the following command:

ffbat\ffbat ffbat\images\flare_MVI_8235_00000.png AnimatedLensFlares 0
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
And finally a number of files with this:

ffbat\ffbat ffbat\images\*.png AnimatedLensFlares 0

(It did not work without ".png")

I also suspect that this will only work if there are no spaces in file and folder names, correct?
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Works fine with jpegs as well if I put "*.jpg", so it must be related to folder options (whether you show or hide known file extensions).
  Details E-Mail
SpaceRay
SpaceRay

Posts: 12298
Filters: 35
Thanks for sharing it with the forum, and it looks good, but regretably I am bad using command line applications, and try to avoid it, and would like much better any GUI based one and that could work well and be updated to be used with FF 3.0 or FF 4.0 as the others available seen in this other thread here does not work right, at least the windows versions

Also your good Batch rendering wrapper is only for batch rendering one image or a folder with just one filter and one preset.

I have suggested before the following

Quote
WHAT WOULD BE GOOD TO BE ABLE TO DO AS BATCH PROCESSING IN FILTER FORGE

For example I have one single image and want to:

* be able to select a group of filters ( for example 20 filters) and apply all of them to this same image, also it would be needed to be able to choose which one of the filters preset will be applied, so the result will 20 images.

* be able to select a group of filters (for example 5) and a group of presets of these filters (for example 20 filters and choose 3 presets of each filter) and apply them all to this same image, so the result will be 100 images.

* be able to select a group of filters and a different amount of presets fr om each filter, perhaps 2 presets fr om filter 1, 4 presets fr om filter 2, 1 preset fr om filter 3, etc. and apply all of them to the same single image so you will have lots of different versions of the same image with different filters and presets.


For example I have 40 images in a folder and want to:

* be able to apply the same filter and same preset to all the 40 images. Result 40 images

* be able to apply a group of filters, with one preset each one, to all the 40 images. Result 40 images

* be able to select a group of filters (for example 5) and a group of 3 presets to each, and so you will get as result 600 images.

* Be able to select (as above already described) a group of filters and a group of presets and apply all of them to all the 40 images.
  Details E-Mail
earthbound
Posts: 97
Filters: 1
Quote
* be able to select a group of filters ( for example 20 filters) and apply all of them to this same image, also it would be needed to be able to choose which one of the filters preset will be applied, so the result will 20 images. . . .
* be able to apply the same filter and same preset to all the 40 images. Result 40 images


SpaceRay: Begging your pardon since the last post in this thread approaches three years ago, but while I don't know whether any existing tools accomplish those objectives, I know a tool I wrote and released does (the last I searched for something that can do those things, I didn't find it, so I coded my own).

I've searched the forums and found everything I could about external/batch tools (the last time I searched, well before coding my own solution, I only found two--there are many), and updated the main page of the wiki with them:

http://www.filterforge.com/wiki/index.php/Main_Page#PC

If you know anything I missed, please let me know, or better yet, update the wiki yourself smile:)

The tool I wrote that accomplishes those things, I announced here: https://www.filterforge.com/forum/read...&TID=13617

With some more work, my tool can do all of those things you want (which I didn't quote all of them).
You refer to the prophecy of the pastry that will bring balance to the Force. And you believe it's this...donut?
  Details E-Mail
earthbound
Posts: 97
Filters: 1
Oh, sheesh--after pouring through the forums and finding so many tools, I listed them all at the wiki *except for the one here, where I announce my wiki edits)*. smile:blush: Sorry about that! Updating wiki to include this here one smile:)
You refer to the prophecy of the pastry that will bring balance to the Force. And you believe it's this...donut?
  Details E-Mail
SpaceRay
SpaceRay

Posts: 12298
Filters: 35
Quote
earthbound wrote:
I listed them all at the wiki *except for the one here, where I announce my wiki edits)*.


thanks for including all the available tools in the FF wiki as seen here

The link from the first post is broken and not available

But in the FF Wiki I have seen that there is this link that I think is a new updated for this tool Download it from Github here

In the link page is not clear about version of FF is compatible.
Does it work with FF 9?

Thanks for any possible help
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,711 Registered Users
+18 new in 30 days!

153,531 Posts
+39 new in 30 days!

15,347 Topics
+72 new in year!

Create an Account

Online Users Last minute:

28 unregistered users.