We are demoing this product and wanted to process bulk image files in a process that doesn't require user intervention. This process simply needs to add annotations to each image (and every page in the image) and then merge the annotations with the image.
Question: Is it required to use the "AnnotationViewer" class to perform this? Or is there another "Faster" way to do this that doesn't require a viewer as no user inferace will be needed. Here is the current (pseudo) logic that requires the "AnnotationView":
// create image collection AND load multipage TIFF file into collection
ImageCollection images = new ImageCollection();
images.Add("multipage.tif");
// create annotation controller which will manage annotations of image collection AND
// link image collection and annotation controller
AnnotationController annotations = new AnnotationController(images);
// for each image in image collection
for (int i = 0; i < images.Count; i++)
{
// create the Stamp annotation
StampAnnotation stamp = new StampAnnotation();
stamp.Text = "Approved";
stamp.StampColor = Color.Blue;
stamp.Rotation = -30;
stamp.Location = new PointF(images[i].Width / 2, images[i].Height / 2);
stamp.Size = new SizeF(images[i].Width / 3 * 2, images[i].Height / 5);
annotations[i].Add(stamp);
// merge image with annotation
annotations.MergeImageWithAnnotations(i);
}
Hi Alex,
I have a smilar requirements where I want to traverse a folder and merge the (existing)annotations with the images in the background (no user interventions).
I tried your sample code but it doesnt seem to save the images.
annotations.MergeImageWithAnnotations(i); save the image file as well?
annotations.MergeImageWithAnnotations() does not save the image. It just merges each image from the Images collection with a set of annotations.
For saving image after you should execute save image method. Please refer to "Programming > Save image > Save image collection" section in the SDK documentation here: http://www.vintasoft.com/docs/vsimaging-dotnet/
Thanks Yuri for a quick response, however I have few more questions.
It looks like there is no single method call for saving the whole image collection in one go. Do I need to keep track of all the image file names and call the Save(filename) method? If I try this, I am getting exception 'This file is being used by another process', no matter if I set SaveAndSwitchStore to true or false. Please see my code sample below
using (ImageCollection images = new ImageCollection())
{
foreach (var file in files)
{
images.Add(file);
}
var cont = new AnnotationController(images);
images.SetSaveAnnotations(true);
images.SaveAndSwitchSource = false;
var encoder = new TiffEncoder();
// for each image in image collection
for (int i = 0; i < images.Count; i++)
{
cont.MergeImageWithAnnotations(i);
}
//save the images
foreach (var file in files)
{
images.SaveAsync(file);
//images.SaveSync(file);
}
// images.ClearAndDisposeItems();
}