Page 1 of 1

ImageMagick with VBScript & format option in Convert

Posted: 2009-09-03T01:11:29-07:00
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

Re: ImageMagick with VBScript & format option in Convert

Posted: 2009-09-03T11:18:17-07:00
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:")

Re: ImageMagick with VBScript & format option in Convert

Posted: 2009-09-04T01:27:04-07:00
by lenourien
I am not sure but I think the 2 (being a constant not a variable) should also be between " "
Hope it helps

Re: ImageMagick with VBScript & format option in Convert

Posted: 2009-09-11T05:51:53-07:00
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

Re: ImageMagick with VBScript & format option in Convert

Posted: 2009-09-11T12:31:19-07:00
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]

Re: ImageMagick with VBScript & format option in Convert

Posted: 2009-09-14T00:00:06-07:00
by vagpap
That did the trick!

Thank you very much!