How do I pass image filepaths to convert.exe, given I know all the file paths?
ImageMagick is NOT installed, but just in my project folder. I don't think I'm supposed to pass the image filepaths through a cmd prompt.
Here is my current attempt. I get no errors from it -- but a cmd prompt pops up quickly and disappears quickly -- I've printed the screen when it's up and it's saying something about userparams... which apparently has to do with ImageMagick somehow.
When I run the same command directly in a command prompt without Unity (which is what I'm using to run the code below), I get the following:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
F:Documents and SettingsAdministrator>F:ImageMagickTestImageMagickconvert.e
xe F:ImageMagickTestPDFsAppointment.pdf F:ImageMagickTestConvertedPDFsAppo
intment.png
Unrecoverable error: rangecheck in .setuserparams
Operand stack:
--nostringval-- --nostringval-- --nostringval--
START 0 2588256 1246519 1476808 192904 true 1139 5 <3>
END PROCS 0 2588256 1257818 1476808 194288 true 1138 5 <3>
gs_std_e.ps 0 2608352 1263873 1496904 199000 true 1138 5 <6>
gs_il1_e.ps 0 2608352 1266056 1496904 199000 true 1138 5 <9>
END FONTDIR/ENCS 0 2608352 1266234 1496904 199000 true 1138 5 <15>
END DEVS 0 2611856 1273266 1496904 199000 true 1138 5 <15>
END STATD 0 2611856 1280422 1496904 200624 true 1138 5 <39>
END GS_FONTS 0 2641800 1309596 1496904 200624 true 1139 5 <45>
END BASIC COLOR 15 2661896 1319485 1496904 200624 true 1137 5 <48>
END LEVEL 1 COLOR 15 2661896 1321213 1496904 200624 true 1137 5 <51>
END IMAGE 15 2661896 1324515 1496904 200624 true 1137 5 <54>
gs_btokn.ps 15 2661896 1327957 1496904 200624 true 996 4 <57>
gs_dps1.ps 15 2661896 1329302 1496904 200624 true 996 4 <57>
gs_dps2.ps 15 2661896 1331309 1496904 200624 true 996 4 <57>
gs_type1.ps 15 2681992 1336187 1496904 200624 true 996 4 <57>
While reading gs_lev2.ps:
%%[ Error: invalidaccess; OffendingCommand: put ]%%
START 322159 2736608 1402076 1496904 202880 true 1000 7 <92>
END PROCS 322159 2756704 1416711 1496904 204264 true 998 7 <92>
gs_std_e.ps 322159 2756704 1419438 1496904 205648 true 998 7 <95>
gs_il1_e.ps 322159 2756704 1421621 1496904 205648 true 998 7 <98>
END FONTDIR/ENCS 322159 2756704 1421799 1496904 205648 true 998 7 <104>
END DEVS 322159 2760208 1428831 1496904 205648 true 998 7 <104>
END STATD 322159 2780304 1439315 1496904 207272 true 998 7 <128>
END GS_FONTS 322159 2800400 1466811 1496904 207272 true 998 7 <134>
END BASIC COLOR 322159 2820496 1476700 1496904 207272 true 996 7 <137>
END LEVEL 1 COLOR 322159 2820496 1478428 1496904 207272 true 996 7 <140>
END IMAGE 322159 2820496 1481730 1496904 207272 true 996 7 <143>
gs_btokn.ps 322159 2820496 1485172 1496904 207272 true 996 7 <146>
gs_dps1.ps 322159 2820496 1486517 1496904 207272 true 996 7 <146>
gs_dps2.ps 322159 2820496 1488524 1496904 207272 true 996 7 <146>
gs_type1.ps 322159 2820496 1490098 1496904 207272 true 996 7 <146>
While reading gs_lev2.ps:
%%[ Error: invalidaccess; OffendingCommand: put ]%%
F:Documents and SettingsAdministrator>
Anyway, as stated, I'm not sure what I'm doing wrong. Here is the code in the software that's causing the same problem:
string currDir = System.Environment.CurrentDirectory;
string convertPath = currDir + @"ImageMagickconvert.exe";
string convertedDir = currDir + @"ConvertedPDFs";
string pdfFolder = currDir + @"PDFs";
string fileName = "Appointment";
//System.IO.Directory.CreateDirectory(currDir + @"" + convertedDirName);
string argumentForImageMagick;
argumentForImageMagick = pdfFolder + fileName + ".pdf" + " " + convertedDir + fileName + ".png";
ProcessStartInfo info = new ProcessStartInfo {Arguments = argumentForImageMagick , FileName = convertPath};
System.Diagnostics.Process.Start(info).WaitForExit();
When I print the argument and filepath for the ProcessStartInfo instance, I get
F:ImageMagickTestPDFsAppointment.pdf
F:ImageMagickTestConvertedPDFsAppointment.png
for the argument, and
F:ImageMagickTestImageMagickconvert.exe
for the filepath.
What is going wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…