program to process images automatically

suggest a way to improve Neat Image
oliver_pa
Posts: 11
Joined: Sun Jul 20, 2003 10:26 am

program to process images automatically

Post by oliver_pa »

Although I always like to fine-tune the neatimage settings when working on potentially good images, I'd also like to process the remaining hundreds of images automatically and configure neatimage manually only when the automatic version turned out worse than expected.
Judging by the amount of requests of such a feature and the replies by the neatimage staff it seems that though there's quite a demand we won't see it implemented soon. Which is why I considered it worthy to write such a program myself instead of waiting (or more precisely, instead of processing hundreds of images manually).

A word of warning though: The program has not been tested thoroughly, so it may include some nasty bugs. Especially since I've used this project to make my transition from C++ code to C# and the .NET framework. However, so far it has worked very well, in fact the only major problem I've found is a messagebox opened by neatimage whenever it has finished processing a file which amounts to a LOT of these messageboxes when batch processing dozens of files. The easiest way to get rid of them is to simply keep the esc key pressed until there's no more of them left.

So far I've done little to create a decent documentation, so for now the help page output of the program (accessible by the commandline arguments --help or /?) will have to do.

Code: Select all


  usage: nic.native [arguments]

  hardcoded arguments:
    --help                        help page
    /?                            help page
    --ahelp                       advanced help page
    -fcfg "filename"              configuration file, defaults to nic.xml

  arguments defined in the configuration file:
    -sf     source_filter         this filter is applied to each filename before 
                                  trying to find a matching configuration, e.g. 
                                  ".*\.jpg$"
    -fo     output_filename       overrides Output:output_filename
    -ds     source_directory      source directory for images, subdirectories 
                                  are not included
    -do     output_directory      output directory for processed images
    -dpro   profile_directory     overrides Input:profile_directory
    -dpre   preset_directory      overrides Input:preset_directory
    -fpro   profile_filename      overrides Config:profile_filename
    -fpre   preset_filename       overrides Config:preset_filename
    -ei     exif_inputfile        overrides Input:exif_inputfile
    -es     exif_source           overrides Input:exif_source, "db" or "int"
    -cs     camera_sharpening     overrides Input:camera_sharpening, sets 
                                  in-camera sharpening which is not recorded as 
                                  exif tag, "-2", "-1", "0", "+1", "+2"
    -d      Prog:delay            sets the delay after each file, in 
                                  milliseconds
    -pn     profile_num           "1" for Sony F717 profile by Jay Philippbar, 
                                  "2" for Sony F717 profile by Tom Matty and 
                                  Chiang Mai

    -t "[namespace:]attribute"="value"  defines an attribute


  arguments are case sensitiv
  prefix may be '-' or '/'




  configuration file format:
    top level element "NIC"

    element "CmdlArgs"
      attribute "tagdef", commandline argument for defining tag's
        e.g. to define a tag "proctag" with value "_NR"
        tagdef="-t"  ->  nic.native -t proctag=_NR
      child elements "Arg"
          attribute "tag", commandline argument
          attribute "attribute", target attribute
          attribute "desc", optional description text
            e.g. to add a switch for Prog:delay/>
            <Arg tag="-d" attribute="Prog:delay" desc="sets delay"/>

    element "Prog"
      attribute "delay", delay after each file in milliseconds
      attribute "commandline", path and executable filename
      attribute "commandline_arguments", arguments passed to program

    element "Input"
      attribute "exif_source", exif data read from textfile if "db"
        or by parsing image if "int"
      attribute "exif_inputfile", specifies textfile, applies only if
        "exif_source" set to "db"
      attribute "exif_inputfile_delimiter", specifies field delimiter, applies
        only if "exif_source" set to "db", format as regular expression
      attribute "source_filter", this filter is applied to each filename before
         trying to find a matching configuration, format as regular expression
         e.g. to process only jpeg files use ".*\.jpg$"

    element "Output"
      attribute "output_filename", name of processed file
        e.g. to specify "(source filename)(processed-tag)(file extension)
        "%File:FileName%%proctag%.%File:FileExtension%"
        this yields an output name of DSC05726_NR.JPG for source file
        DSC05726.JPG and proctag="_NR"
      attribute "log_message", program output for each processed file

    element "ConfigDef"
      attribute "name", configuration name
      attribute "filter", this filter must match for this configuration
        to be selected
        format:
        %TagName%,'regular_expression';...
        (.+?),(.+?);
        e.g. to filter by camera model and image width
        "%Exif:Model%,cybershot;%Exif:Image width%,2560;"


  the first-level elements may have 'Tag' child-elements to define tag's
  all tag's may be defined as attribute or 'Tag' element
  e.g. both of these two lines yield the same results
    <Output delay="200"/>
    <Output><Tag name="delay" default="200"/></Output>
  tag's expand to either their "default" or "format" attribute which may itself
  contain embedded tag's. tag's defined by "default" may be local (i.e. defined
  within the same namespace) or external (i.e. defined in another namespace).
  format:
  %LocalTagName% or %NamespaceName:TagName%
  (?:%([\w\s]+)%)|(?:%([\w\s]+):([\w\s]+)%)

  tag's defined by 'Tag' elements support conditional formating by
  specifying a "format" attribute instead of "default"
  format:
  %TagName%,'op''cmp'='val'
  ((?:%([\w\s]+)%)|(?:%([\w\s]+):([\w\s]+)%)),(.+)
  where the last sub-expression contains the conditional phrase
  format:
  ([=<>!]{1,2})(.+?)=(.*?)(?:\||$)
  op: comparison operators for equality "==" and inequality "==" are performed
  as string_type comparisons, the remaining ops less "<", greater ">", less than
  "<=" and greater than ">=" are compared as two floating point numbers.
  cmp: text that's compared to the expanded %TagName%
  val: value that's assigned to the tag if the expression matches

  cmp and val may be formated as fractions, e.g. 1/250
  format:
  (\d+(?:\.\d+)?)/(\d+(?:\.\d+)?)

  e.g. to format a tag shspeed depending on the shutter speed
  <Tag name="shspeed" format="%Exif:Shutter speed%,&1/25=30|&=1/25=25"/>


  first-level element names become namespace names: 'CmdlArgs', 'Prog',
  'Input', 'Output', (only first defined 'ConfigDef' is accessible)

  matching 'ConfigDef' is mapped as namespace 'Config'

  information about the currently processed file is mapped into 'File'
  currently available 'File' tag's: 'FileName', 'FileExtension' (including .),
  'FileSize' (in bytes), 'CreationDate', 'LastWriteTime'

  meta-information about the currently processed image is mapped into 'Exif'
  exif_source="int": not yet implemented
  exif_source="db": the available tag's depend on the contents of the file
  specified by exif_inputfile
  these files are best created by BreezeBrowser which is available as trial
  version at http://www.breezesys.com

  tag's defined by commandline are added to top-level namespace 'Cmdl', i.e.
  they override all tag's of same name defined in any other namespace


version: 0.11, build date: Jul 21 2003
for suggestions and bug reports send a mail to jamez@xover.mud.at
by Oliver Pons-Adrover, 2003

You can download the program and a sample configuration file here.

The program does NOT delete, overwrite or modify any files but merely passes the parameters to neatimage! Maybe the neatimage staff could take a look at the source code and verify that this program should not do any damage to your data. I say 'should' because naturally I can't guarantee this and therefore take no responsibility for any malfunction.
As always when you work on critical data, use common sense and create a backup of the original files.

That's it for now..
Please post any question into this thread so that everyone can benefit from the answers.
Greeting from Vienna, Oliver Pons-Adrover.

edit: help screen updated
Last edited by oliver_pa on Mon Jul 21, 2003 1:43 pm, edited 1 time in total.
NITeam
Posts: 3173
Joined: Sat Feb 01, 2003 4:43 pm
Contact:

Post by NITeam »

Dear Oliver, thank you for your efforts! Looks like you have done a lot of work with this application.

However, I cannot start it - the following error pops up whenever I launch the program:
"The application failed to initialize properly (0xc0000135). Click on OK to terminate the application."

Any suggestions? Maybe the application has to reside in a specific place on the disk?

Thank you,
Vlad
oliver_pa
Posts: 11
Joined: Sun Jul 20, 2003 10:26 am

Post by oliver_pa »

NITeam wrote:"The application failed to initialize properly (0xc0000135). Click on OK to terminate the application."
A search on google for this phrase indicates that this problem is related to the .net framework which first of all needs to be installed, and should be version 1.1
Do you have the framework installed?
NITeam
Posts: 3173
Joined: Sat Feb 01, 2003 4:43 pm
Contact:

Post by NITeam »

Of course not. :shock:

I will probably download it later on to our test computer.

BTW, I am afraid the same problem will highly limit the number of potential users of the application.

Vlad
oliver_pa
Posts: 11
Joined: Sun Jul 20, 2003 10:26 am

Post by oliver_pa »

Yep, that's the bummer about .NET :(
However before beginning with the .NET version I had a native win32 version halfway complete - I might finish it if the framework proves to be problematic.
NITeam
Posts: 3173
Joined: Sat Feb 01, 2003 4:43 pm
Contact:

Post by NITeam »

I would highly recommend to recompile (if this is directly possible) the application using standard win32 compiler. I will install the framework but this will not help other people who may want to use the application. I estimate that more than 95% of NI users don't have .net installed.

Anyway, thank you very much and please keep up the great work!
Vlad
ecathell
Posts: 5
Joined: Sun Jul 20, 2003 3:31 pm

.net will limit users? <cough>

Post by ecathell »

erm, maybe if the majority of your users are MAC based, but i believe with 1.1 the framework has a mac version now (I could be wrong, ima PC die hard)

any of the normal windows users from windows 98 and above can install the framework from windows update.

In all actuallaity...coding in the .net framework makes using it on multiple PC's EASIER...most of the time its a simple copy and paste install so long as there are no custom plugins(crystal reports as an example) that need to be installed as well...

I would be more interested to find out where you see this difficulty...
NITeam
Posts: 3173
Joined: Sat Feb 01, 2003 4:43 pm
Contact:

Post by NITeam »

How large is the download? What are the immediate benefits of installing the framework?

- Two questions every potential user of the application will ask himself/herself when confronted with a .net-only application.

Vlad
oliver_pa
Posts: 11
Joined: Sun Jul 20, 2003 10:26 am

Post by oliver_pa »

NITeam wrote:How large is the download? What are the immediate benefits of installing the framework?
1) 23698 KB
2) The user hardly benefits, but as a developer it's quite a bit easier to develop. Even though I hate to admit (you know, evil Microsoft 'n stuff..) that the .NET framework is actually rather sweet to work with, my first venture into C# and .NET took two days and roughly 1200 lines of code resulting in a surprisingly well working application (well, for me at least..).
Then again, C# code looks plain boring, so .NET has it's downsides :cry:
ecathell
Posts: 5
Joined: Sun Jul 20, 2003 3:31 pm

Post by ecathell »

eventually it wont matter, if you use microsoft products you will need the framework. <shrug>
NITeam wrote:How large is the download? What are the immediate benefits of installing the framework?

- Two questions every potential user of the application will ask himself/herself when confronted with a .net-only application.

Vlad
NITeam
Posts: 3173
Joined: Sat Feb 01, 2003 4:43 pm
Contact:

Post by NITeam »

Yes, it is most likely. But at the moment the market is not ready yet. - Even WinXP doesn't include the framework by default.

Regarding the developer's benefits, there may be some but in case of NI, using C# would make filtration approximately five times slower. We would write NI in Java long time ago if it was faster. :-)

Vlad
oliver_pa
Posts: 11
Joined: Sun Jul 20, 2003 10:26 am

new versions available

Post by oliver_pa »

A new version is available as .NET executable and native win32 executable here.


PS: I still don't understand why neatimage open that messagebox after completing a file...
Any hints would be more than welcome :wink:

Messagebox text: "Neat Image cannot be closed while a task is being processed. Do you want to stop processing?" Yes/No
NITeam
Posts: 3173
Joined: Sat Feb 01, 2003 4:43 pm
Contact:

Post by NITeam »

Thank you for the new version!

Message box.. It should not appear. Do you run NI on Win9x?

Vlad
oliver_pa
Posts: 11
Joined: Sun Jul 20, 2003 10:26 am

Post by oliver_pa »

NITeam wrote: Message box.. It should not appear. Do you run NI on Win9x?
No, Windows XP. At first I suspected it might be the escape key that is sent to neatimage after it has started it first instance (otherwise it would stay in 'edit' mode instead of 'batch' mode). However, that key is sent only once, as KeyDown message
PostMessage(hwndNI, WM_KEYDOWN, (WPARAM)VK_ESCAPE, MapVirtualKey((UINT)VK_ESCAPE, 0));
in the native version and by the System.Windows.Forms class in the .NET version
SendKeys.SendWait("{ESC}");

Both result in a messagebox..

BTW, I should add, that some of the reg. expressions and the way they're handled differ among the two programs - this will be corrected though. So far I've found the Config.filter tests of the .NET version to be faulty at times.
NITeam
Posts: 3173
Joined: Sat Feb 01, 2003 4:43 pm
Contact:

Post by NITeam »

I believe you don't need to send any keypress messages at all. NI works fine when simply invoked from the command (or from a batch file) line with parameres, right? There is no need to tell it to close, NI does this automatically.

Vlad
Post Reply