0

I'm using the following code to copy the exif data from one file to another using exiftool.

When directly run from command line,the tool is quick.But when the command is executed from a winform app,it takes much greater time.What is going wrong here? Please advice. Is there any alternative way to achieve this?

foreach(string cpath in filelist)
{
    string path = "-overwrite_original -TagsFromFile " + "\"" + file + "\"" +" "+ "\"" + outdir + "\\" + Path.GetFileNameWithoutExtension(file) + ext + "\"";
                        runCmd(path);
}

  public void runCmd(string command)
    {

        ProcessStartInfo cmdsi = new ProcessStartInfo("exiftool.exe");
        cmdsi.WindowStyle = ProcessWindowStyle.Hidden;
        cmdsi.Arguments = command;
        Process cmd = Process.Start(cmdsi);
        cmd.WaitForExit();    
    }
6
  • And how big is filelist? Is it slow from the first file or becomes slower over time? How slow (1 second, 10)?
    – Evk
    Apr 24, 2018 at 9:24
  • @Evk The result is the same irrespective of the list size.I have tried with a single file.The file is high resolution 6000×4000 pixels.Directly the process completes in 1 second ,from winforms it takes ~3 seconds
    – techno
    Apr 24, 2018 at 9:28
  • If you are running this on multiple files, one problem is covered by Common Mistake #3. The startup time for exiftool is the biggest time cost, so running exiftool separately for each file will dramatically increase the overall run time. Consolidating the file list into a single command or saving the list to a temp file and using the -@ option will decrease the run time.
    – StarGeek
    Apr 24, 2018 at 15:03
  • @StarGeek Thanks for your input,the startup time seems to be the culprit.I can write the list to a file,but how can i pass the output argument? Can you please add an example...
    – techno
    Apr 24, 2018 at 15:46
  • Continuing on your exiftool forum thread, as that is better suited to posting examples than commenting here.
    – StarGeek
    Apr 24, 2018 at 16:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.