ImageMagick with VBScript & format option in Convert

ImageMagickObject is a Windows COM+ interface to ImageMagick. COM+, Visual Basic, and Delphi users should post to this discussion group.
Post Reply
vagpap

ImageMagick with VBScript & format option in Convert

Post by vagpap »

Hi all.

I am trying a script for determining the color percentage of black and white pixels of an image. After searching, I have found the following syntax that works:

Code: Select all

convert filename.tif -colors 2 -format %c histogram:info: >> c:\output.txt
and returns the pixel count of black & white pixels.

When trying to call the same function through vbscript, I get the txt file which has color data for each pixel instead of the total number of pixels for each color. The syntax I am using is the following:

Code: Select all

Set imageMagick = CreateObject("ImageMagickObject.MagickImage.1")
tmp = imageMagick.Convert("c:/filename.tif","-colors",2,"-format","%c histogram:info:","c:/output.txt")
I know i am doing something wrong, but... can you point me the wrong part?

Thanks
spieler
Posts: 47
Joined: 2004-10-08T09:03:16-07:00
Location: Iowa

Re: ImageMagick with VBScript & format option in Convert

Post by spieler »

There's no reason to still be using output.txt. Remove it and the output will be in tmp.

Code: Select all

Set imageMagick = CreateObject("ImageMagickObject.MagickImage.1")
tmp = imageMagick.Convert("c:/filename.tif","-colors",2,"-format","%c histogram:info:")
lenourien

Re: ImageMagick with VBScript & format option in Convert

Post by lenourien »

I am not sure but I think the 2 (being a constant not a variable) should also be between " "
Hope it helps
vagpap

Re: ImageMagick with VBScript & format option in Convert

Post by vagpap »

When removing the output.txt parameter, the tmp variable is blank (tmp = "").

No change in the behaviour when putting 2 between quotes. Still output.txt contains the color data for each pixel in the image.
:?

Thanks although for your answers
spieler
Posts: 47
Joined: 2004-10-08T09:03:16-07:00
Location: Iowa

Re: ImageMagick with VBScript & format option in Convert

Post by spieler »

Sorry, i didn't pay enough attention the first time. I looked at the example script ArrayTest.vbs that comes when the ImageMagickObject is installed. Try this:

Code: Select all

tmp = imageMagick.Convert("c:/filename.tif", "-colors", "2", "-format", "%c", "histogram:info:c:/output.txt")
[/quote]
vagpap

Re: ImageMagick with VBScript & format option in Convert

Post by vagpap »

That did the trick!

Thank you very much!
Post Reply