Command Line Arguments For IrfanView using C# WinForm
-
I have tried to pass command line arguments to IrfanView to rotate a image, the code is below, the commented code works without a problem. The problem is the uncommented code, when the process is started, there are no errors but no changes are made to the image. I have tried the proper syntax code in VB.NET and it works as expected, any insight as to what's wrong? //args = file1 + " " + "/rotate_r " + "/convert=" + file2 + "/killmesoftly"; //args = " " + file1 + " " + "/rotate_r " + "/jpgq=100" + "/convert=" + file2 + "/killmesoftly"; args = " " + file1 + " " + "/jpg_rotate=(3,1,0,1,0,0,0,0)" + "/killmesoftly";
-
I have tried to pass command line arguments to IrfanView to rotate a image, the code is below, the commented code works without a problem. The problem is the uncommented code, when the process is started, there are no errors but no changes are made to the image. I have tried the proper syntax code in VB.NET and it works as expected, any insight as to what's wrong? //args = file1 + " " + "/rotate_r " + "/convert=" + file2 + "/killmesoftly"; //args = " " + file1 + " " + "/rotate_r " + "/jpgq=100" + "/convert=" + file2 + "/killmesoftly"; args = " " + file1 + " " + "/jpg_rotate=(3,1,0,1,0,0,0,0)" + "/killmesoftly";
I don't know why newbs always insist on breaking up what should be a single string into a bunch of string concatenations, making it harder to debug your code. You can do this all in one string:
args = $"{file1} /jpg_rotate=(3,1,0,1,0,0,0,0) /killmesoftly";
Take a closer look at your uncommented code:
args = " " + file1 + " " + "/jpg_rotate=(3,1,0,1,0,0,0,0)" + "/killmesoftly";
This will result in an arguments string that looks like this:
[file1] //jpg_rotate=(3,1,0,1,0,0,0,0)/killmesoftly
Notice there is no space before the
/killmosoftly
switch. That will probably generate an error for the Irfan command.Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
-
I have tried to pass command line arguments to IrfanView to rotate a image, the code is below, the commented code works without a problem. The problem is the uncommented code, when the process is started, there are no errors but no changes are made to the image. I have tried the proper syntax code in VB.NET and it works as expected, any insight as to what's wrong? //args = file1 + " " + "/rotate_r " + "/convert=" + file2 + "/killmesoftly"; //args = " " + file1 + " " + "/rotate_r " + "/jpgq=100" + "/convert=" + file2 + "/killmesoftly"; args = " " + file1 + " " + "/jpg_rotate=(3,1,0,1,0,0,0,0)" + "/killmesoftly";
Adding to Dave's wise words, your uncommented string doesn't specify an output file, so it may very well execute the process and discard the result.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
I don't know why newbs always insist on breaking up what should be a single string into a bunch of string concatenations, making it harder to debug your code. You can do this all in one string:
args = $"{file1} /jpg_rotate=(3,1,0,1,0,0,0,0) /killmesoftly";
Take a closer look at your uncommented code:
args = " " + file1 + " " + "/jpg_rotate=(3,1,0,1,0,0,0,0)" + "/killmesoftly";
This will result in an arguments string that looks like this:
[file1] //jpg_rotate=(3,1,0,1,0,0,0,0)/killmesoftly
Notice there is no space before the
/killmosoftly
switch. That will probably generate an error for the Irfan command.Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
Dave; Thank you for responding, unfortunately the image was not rotated. As I stated previously the string works in Excel VBA & VB.NET with the correct file location syntax. Thanks again for your help
-
Adding to Dave's wise words, your uncommented string doesn't specify an output file, so it may very well execute the process and discard the result.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
Peter; Thank you for responding. There is no switch for an output file, because the original file is overwritten.
-
Dave; Thank you for responding, unfortunately the image was not rotated. As I stated previously the string works in Excel VBA & VB.NET with the correct file location syntax. Thanks again for your help
I didn't say I knew anything about Irfan, only that your code is unnecessarily complicated, making it harder to debug.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak