使用便携式imagemagick转换程序 [英] Using portable imagemagick convert program

查看:229
本文介绍了使用便携式imagemagick转换程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我知道所有的文件路径,我如何传递图像文件路径到convert.exe?



ImageMagick没有安装,但只是在我的项目文件夹。我不认为我应该通过cmd提示符传递图像文件路径。



这是我当前的尝试。我没有得到任何错误 - 但是一个cmd提示迅速弹出,很快消失 - 我打印的屏幕,当它和它正在说一些关于userparams ...显然是与ImageMagick某种方式。



当我直接在命令提示符下运行相同的命令没有Unity (这是我用来运行下面的代码),我得到以下:

  Microsoft Windows XP [版本5.1 .2600] 
(C)版权所有1985-2001 Microsoft Corp.

F:\Documents and Settings \Administrator> F:\ImageMagickTest\ImageMagick\convert.e
xe F:\ImageMagickTest\PDFs\Appointment.pdf F:\ImageMagickTest\ConvertedPDFs\Appo
intment.png
不可恢复的错误:rangecheck in .setuserparams
操作数栈:
--nostringval-- --nostringval-- --nostringval--
START 0 2588256 1246519 1476808 192904 true 1139 5&
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<
END DEVS 0 2611856 1273266 1496904 199000 true 1138 5<
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>
读取gs_lev2.ps时:
%% [Error:invalidaccess; OffendingCommand:put] %%
START 322159 2736608 1402076 1496904 202880 true 1000 7<
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>
读取gs_lev2.ps时:
%% [Error:invalidaccess; OffendingCommand:put] %%

F:\Documents和Settings \Administrator>

无论如何,我不知道我做错了什么。下面是软件中导致相同问题的代码:

  string currDir = System.Environment.CurrentDirectory; 
string convertPath = currDir + @\ImageMagick\convert.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();

当我打印ProcessStartInfo实例的参数和文件路径时,我得到

  F:\ImageMagickTest\PDFs\Appointment.pdf 
F:\ImageMagickTest\ConvertedPDFs\Appointment.png

$

 



code> F:\ImageMagickTest\ImageMagick\convert.exe



发生了什么问题?

解决方案

我想出了问题的一部分 - 我不得不安装Ghostscript。这对我不起作用,因为我不能在主机上安装任何软件...但我想现在我知道是什么错了!感谢。



我的下一个问题基本上是我是否可以运行ghostscript,而不是安装在主机上...


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 Settings\Administrator>F:\ImageMagickTest\ImageMagick\convert.e
    xe F:\ImageMagickTest\PDFs\Appointment.pdf F:\ImageMagickTest\ConvertedPDFs\Appo
    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 Settings\Administrator>

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 + @"\ImageMagick\convert.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:\ImageMagickTest\PDFs\Appointment.pdf
F:\ImageMagickTest\ConvertedPDFs\Appointment.png

for the argument, and

F:\ImageMagickTest\ImageMagick\convert.exe

for the filepath.

What is going wrong?

解决方案

Ok, I've figured out part of the problem -- I had to have Ghostscript installed. This doesn't work for me, as I can't install any software on the host computer...but I guess now I know what was wrong! Thanks.

My next question is basically whether I can run ghostscript without installing it on a host computer...

这篇关于使用便携式imagemagick转换程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆