English 中文(简体)
传承形象 VB 文本
原标题:Calling ImageMagick COM from VBScript

我成功地利用了以下指挥线,以制作带有一些简单文字的新的全球投资论坛形象。

convert -size 100x100 -font arial label:blah output.gif

我愿利用VB文本的COM接口取得同样的结果,但未能成功地通过同样的参数。 我的守则......

Dim img
Set img = CreateObject("ImageMagickObject.MagickImage.1")

Dim fnm(6)
fnm(0) = "-size"
fnm(1) = "100x100"
fnm(2) = "-font"
fnm(3) = "arial"
fnm(4) = "-label"
fnm(5) = "blah"
fnm(6) = "C:	empexample.gif"

retval = img.convert(fnm)

wscript.echo("retval " & retval)

我执行以下守则:

cscript example.vbs

而我获得的产出是这样,没有建立全球投资论坛档案。

Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Version: ImageMagick 6.7.4-3 2011-12-24 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

Usage: cscript.exe [options ...] file [ [options ...] file ...] [options ...] file

I m 视窗7使用图像Magick-6.7.4-Q16

是否有任何人知道我做了什么错误?

[Edit]

In response to Ekkehard s answer I have also tried not using an array. This code will create an output image, but the label is not applied. I also have to pass in a white image as an input as it will not work without one.

msgs = img.convert("C:	emplank.gif", "-size", "100x100", "-font", "arial", "label:", "blah", "C:	empexample.gif")
最佳回答

最后,我曾试图通过<代码>label在使用COM+时开展工作。 FCCC/SBI/2008/INF.1。 Ekkehard使用Array是正确的,而是使用下文所示的个人论点。

msgs = img.convert( "c:	emplank.gif", "-font", "arial", "-pointsize", "36", "-gravity", "center", "-fill", "blue", "-draw", "text 0,0  blah ", "c:	empexample.gif")
问题回答

括号内为<代码>。 缩略语 你们找到了两条样本(Array Road.vbs,《简单的试验》。 第二项最重要的信息是:

  The argument list is exactly the same as the utility programs
  as a list of strings. In fact you should just be able to
  copy and past - do simple editing and it will work. See the
  other samples for more elaborate command sequences and the
  documentation for the utility programs for more details.
 
msgs = img.Convert("logo:","-format","%m,%h,%w","info:")

因此,在一阵列中穿过所有碎片与试图确定财产一样错。 I 旧

  Dim sSrcFSpec : sSrcFSpec = "..datalogo.jpg"
  Dim sDstFSpec : sDstFSpec = "..datalogo.png"
  If goFS.FileExists(sDstFSpec) Then goFS.DeleteFile sDstFSpec
  CreateObject("ImageMagickObject.MagickImage.1").convert "-verbose", sSrcFSpec, sDstFSpec
  If Not goFS.FileExists(sDstFSpec) Then WScript.Echo "Failure!"

产出:

..datalogo.jpg JPEG 123x118 123x118+0+0 8-bit DirectClass 16.2KB 0.000u 0:00.006
..datalogo.jpg=>..datalogo.png JPEG 123x118 123x118+0+0 8-bit DirectClass 0.030u 0:00.
083

这证明,如果你通过合理的论据,你会取得结果。 我曾尝试过与你试验守则类似的东西。

convert -verbose -size 100x100 -font arial -label blah ..dataexample.gif

并且:

convert.exe: missing an image filename `..dataexample.gif  @ error/convert.c/ConvertImag
eCommand/3016.

我完全不知道图像Magick的情况,只能假设这种动力能够掌握现有的投入文件。

在你核实了指挥线的参数时,你会进行特委会测试。

COM接口将暴露出控制物体的一系列财产和方法。 你们会通过一系列的价值观而立即这样做。 在大多数情况下,你将单独确定每个财产。 也许可以看一看(例如,我不知道这些物品是否属实):

Dim img
Set img = CreateObject("ImageMagickObject.MagickImage.1")

img.sizeX = 100
img.sizeY = 100
img.font = "Arial"
img.label = "blah"
retval = img.convert("C:	empexample.gif")

WScript.echo("retval " & retval)

可使用目标浏览器或类型的图书馆浏览器来审查COM物体的特性和方法。 http://www.tlviewer.org/tlviewer/“rel=“nofollow”





相关问题
What approach should I use to test a VBScript?

I ve been asked to help out with a project which has made extensive use of VBScript to process a whole bunch of text files and generate certain outputs - sanitized files, SQL entries etc.. The script ...

Unable to call c# code from vbscript - ActiveX error

I am trying to call a method I have written in C# from VBScript. I have followed just about all of the instructions I can find on the web and am still having problems. Specifically I am getting Error:...

How to set delay in vbscript

How to set delay in vbscript? WScript.Sleep(100) does not work on Windows XP, Vista.

Using Classes in a Dictionary in Classic ASP

I usually do C# but have inherited a classic ASP project. I have defined a class: Class clsPayment Public Name End Class Set objPayment = New clsPayment objPayment.Name = "...

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

Problem casting field when querying spreadsheet

I am trying to query an .xls spreadsheet with VBScript, but I have run into an issue when trying to cast a field. I connect to the spreadsheet like this. Set objConnection = CreateObject("ADODB....

热门标签