Forum Discussion

Colin_McCrae's avatar
Colin_McCrae
Community Hero
9 years ago

Image Configuration properties?

I've been messing about with OCR to try and at least do something with a system we use which simply presents the user with a large Canvas. The Canvas is actual lots of buttons (all of which are fully configurable for size, colour and position). The system in question uses an XML file as a "map" to find it's way around the Canvas.

 

What I want to do is fairly basic. Put simply, I want to be able to check some of the buttons (so a "piece" of the Canvas) to see if it has been set up correctly.

 

With OCR, I've just about go this working. But I want to try saving images with different settings to see if I can make the OCR more reliable/consistent.

 

To that end, I want to see if saving things in monochrome or something helps.

 

You can do this. You can specify the confirmation used when images are saved. The details are here:

 

https://support.smartbear.com/viewarticle/82260/

 

But there is no example on that page. There is an example here:

 

https://support.smartbear.com/viewarticle/83003/

 

.... but it isn't a very good one. It only specifies the file type in the configuration.

 

I want to try saving as a GIF. And I want to force it into Black & White. Which is listed as possible. But I can't figure out the syntax/format for the config option?

 

I've tried (attached to creating a CreatePictureConfiguration object):

 

("GIF") .... which saves as a GIF. Fine.

 

But ....

 

("GIF", "Windows system (20 colors)") .... throws an error.

("GIF", ColorReduction = "Windows system (20 colors)") .... throws an error.

("GIF", "", "Windows system (20 colors)") .... throws an error.

 

And then I got bored of trying random combinations and posted here.

 

Anyone know how it's meant to be formatted?

 

(Note to SmartBear - improving the given example so it does more than simply specify the format would be helpful.)

  • Hi Colin,

     

    Here's how to specify the color reduction for GIF:

    // JScript
    function Test()
    {
      var img = Utils.Picture;
      img.LoadFromFile("C:\\MyImage.bmp");
    
      var gifConfig = img.CreatePictureConfiguration("GIF");
      gifConfig.ColorReduction = "Windows system (20 colors)";
    
      img.SaveToFile("C:\\MyImage.gif", gifConfig);
    }

    We'll look at getting some more examples in the docs. Thanks for the feedback!

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi Colin,

     

    Here's how to specify the color reduction for GIF:

    // JScript
    function Test()
    {
      var img = Utils.Picture;
      img.LoadFromFile("C:\\MyImage.bmp");
    
      var gifConfig = img.CreatePictureConfiguration("GIF");
      gifConfig.ColorReduction = "Windows system (20 colors)";
    
      img.SaveToFile("C:\\MyImage.gif", gifConfig);
    }

    We'll look at getting some more examples in the docs. Thanks for the feedback!

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      Thanks Helen.

       

      One of the dev guys here suggested after I posted it probably worked this way.

       

      So as much due to my lack of dev background. Although I do still think some better examples would help. The way I was reading it I thought I could pass those properties in as arguments. Obviously not!

       

      It seems to be helping with the OCR. I have it working pretty well. But due to the massive potential variance in size, position, and colour, it helps if I can simplify and standardize the image as far as possible before running the OCR over it. I'm having much better success once they are converted to monochrome/black and white. Although I'm still trying to flatten out a little more of the dithering/aliasing on the image font as it causes some letters to appear joined together, which the OCR completely fails to spot. Not surprisingly. Even if I can get it around 90% accurate, that would still be a win in terms of manual man hours spent testing these things.