Community

[TIP] Scanstation - using external image processing program


This tip isn't from me but from Eugene (http://www.capturedocs.com/forums/lo...flexicapture10). I just translated for us English speaker because I felt it was a pretty good script. Thank you Eugene for your hard work!


Problem:
Editing images on the scan station before being sent to the server FlexiCapture10.


Functionality wise, Scan Station allows you to crop the image on the rectangle, invert the black and white image, clear the debris and remove the bias. In addition, blacking out areas before sending confidential information by using the redaction tool on the Scan Station


But what if you need to perform something more complex before sending it to the server?
In most cases, you can edit the image any way you like. If you have the time to edit the picture, then most likely you have the time to enter its contents directly into the system. However, in certain cases, this functionality can be useful.


The script is setup as follows:


1. Create a custom Button on the Scan Station Toolbar. Pressing this button will run the script below.
2. First part of script is to define which page is being selected when the button is pressed. If an image is selected, then continue with the script.
3. Next part of the script is to define what format we want to save the temporary image.
4. Then we define where we want to save this image and the file name.
5. Next part will run the commandline instruction from the image editor program to modify the temporary image. (Your image editor program should support command line)
6. Because the Scanstation does not allow scrip to run an external application and wait for a return, we made the script wait until the image is done processing. Basically every 2 seconds, it will check if the editor is done processing the image or not. If so, go on to next step.
7. After the image edit is done, the page selected will be replaced with the new image. We will then delete the temporary copy.


var page = Selection.Item ( 0);
if (page.IsPage)
{
// Create an object of control
var WshShell = new ActiveXObject ("wscript.shell");
try
{
// Save the settings of the temporary file
var savingOptions = this.NewImageSavingOptions ();
savingOptions.Format = "jpg";
savingOptions.ColorType = "FullColor";
savingOptions.ShouldOverwrite = true;
savingOptions.AddProperFileExt = false;


// Path to a photo editor application
var editorPath = "% Image editor full path%" + ""; // add a space at the end


// Path to a temporary file
var filePath = "C:\\temp_image_30F56EFB-8F7C-443F-A204-74C0E11B7408.jpg";


// Save the image
page.SaveAs (filePath, savingOptions);


// Start the application editor
var WshExec = WshShell.Exec (editorPath + filePath);
if (WshExec == null)
{
WshShell.Popup (" Launch failed" , 0, " ", 0 ) ;
return;
}


// Wait until the process is started
while (WshExec.Status == 0)
{
Wait ( 2000) ;
}
SetPageImage (page, filePath);
}
finally
{
if (WshShell != null) delete WshShell;
var FSO = new ActiveXObject ("Scripting.FileSystemObject");
if (FSO.FileExists (filePath))
{
FSO.DeleteFile (filePath);
}
delete FSO;
}
}



For a more reliable solutions it is probably best to give the proper temporary directory that the user has access to. Also it might be best to pull up a message for the operator, telling them that the current page will be replaced.


The idea is to perform bulk editing of images, if the graphic editor supports command line interface.

Was this article helpful?

0 out of 0 found this helpful

Comments

1 comment

  • Avatar
    Andrew Zyuzin
    I would like to add that Scannig station in FlexiCapture 11 is going to have new useful functionality for this scenario: the "Undo operation" that recovers image as it was before processing (for example, you use script to auto preprocess images after scanning - now you have the possibility to undo script action and recover source image). Its internal name is "Back to Source Image".
    0

Please sign in to leave a comment.