convert to gray scale

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

convert to gray scale

Post by SuitedAces » Sat Feb 23, 2008 8:34 pm

I have been trying some routines that use ocr and have discovered that my results are only reliable when I have an image converted to grayscale.

So I have been searching the internet trying to find vb code for converting an image file to gray scale and have come up empty.

Does anyone have a solution ?

Thank you for your help.
Last edited by SuitedAces on Sun Feb 24, 2008 12:01 am, edited 2 times in total.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sat Feb 23, 2008 9:31 pm

Two image processing programs with command line modes that can be scripted with macroscheduler to do a greyscale conversion are ImageMagick and Irfanview. (Note that Irfanview likes the US spelling "gray".)

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Sat Feb 23, 2008 10:05 pm

I in fact have infraview and tried the command lines to convert a file to gray scale and ran into errors trying to get it to work from macro scheduler.

Would you provide an example for me please.
Last edited by SuitedAces on Sun Feb 24, 2008 12:01 am, edited 1 time in total.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sat Feb 23, 2008 10:46 pm

I just tried this and it works for me:

Code: Select all

RunProgram>C:\IrfanView\i_view32.exe c:\test\test.jpg /gray /convert=c:\test\graytest.jpg
Works with .bmp too.

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Sat Feb 23, 2008 11:59 pm

It does not work for me.
What it does in when I run it is it opens the infraview window with the gray scale image , instead of saving it to a file.

Obviously that wouldn't be part of a running code.
In code, it would need to convert a file to gray scale, and save it, so it could then be processed with ocr.

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Sun Feb 24, 2008 12:08 am

Correction I was missing a space where i placed the asterik.
It is savig but it is bringing up a window that asks about a transparent color which I need to get rid of.

RunProgram>C:\Program Files\IrfanView\i_view32.exe c:\ocr\o.gif /gray*/convert=c:\ocr\o6.gif

Did you have that happen ?

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Sun Feb 24, 2008 12:13 am

Ok it brings that window up with gif files but not with jpg files.

Thank you for your help, I appreciate it.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sun Feb 24, 2008 1:55 am

Glad it's working for you. I just tested with a .gif and the code I posted works fine for me with that too. The only time I got the irfanview window opening with the grayscale image was before I figured out I need to add the /convert=filename part on there to save it. Maybe you have an extra space in there? Maybe it's a version thing, I have 4.10.

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Sun Feb 24, 2008 4:16 am

Well I cannot explain that, I have two versions of infraview installed maybe I should uninstall the older version.
But I get a window asking about transparency when I use gifs.

It is curious that I do and you don't , but in the end it isn't an issue because it is not one of the default image types in macro scheduler.

I really appreciate you replying and I'm glad to have gotten it sorted out.
The ablity to resize the image through infraview has also come into use for me with ocr.

Between resizing and going to grayscale ocr has become far more reliable.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts