Page 1 of 2

Load, change and save image to the same file in Image Viewer

Posted: Tue Oct 21, 2008 10:33 am
by Alex
Image Viewer Demo was created to demonstrate the main features of VintaSoftImaging.NET SDK. Demo allows to open a few image files and work with them as with the single collection, therefore demo allows to save collection to a new file only.

If you work with the single image file only and want to load image(s) from file, change image(s) and save it(them) to the same file, you should do the following steps:
1. Load image from the source file
2. Change image
3. Save image to temporary file
4. Close the source file
5. Delete the source file
6. Rename temporary file

Re: Load, change and save image to the same file in Image Viewer

Posted: Sat Mar 20, 2010 12:26 am
by smithsw
How do you close the source file? I tried using the dispose method, but something still has the file locked and this throws an error when I try to delete the source file as directed below.

Thanks,

Shane

Re: Load, change and save image to the same file in Image Viewer

Posted: Sat Mar 20, 2010 10:56 am
by Alex
Hello Shane,
If you work with the single image file only and want to load image(s) from file, change image(s) and save it(them) to the same file, you should do the following steps...
Yes, you are right. Version 4.0 of library allows to load, change and save image to the same file, please wait only some days. :-)

Best regards, Alexander

Re: Load, change and save image to the same file in Image Viewer

Posted: Tue Mar 30, 2010 2:04 am
by smithsw
Unless I'm totally missing it, this still doesn't seem to work. I still get the error that the file is locked (The process cannot access the file 'C:\Temp\ImagingProjectsSystem\WORKING\WorkingFile.tif' because it is being used by another process.)

This is the code bit I pulled from the ImageViewer example project. I have tried it this way and by doing viewer.Images.SaveAsync(sFileName)... both give the same error.

Code: Select all

If viewer.FocusedImage.IsChanged = True Then
     viewer.FocusedImage.Save(filename)
End If

Any ideas?

Re: Load, change and save image to the same file in Image Viewer

Posted: Thu Apr 01, 2010 3:55 pm
by Alex
Hello,

Sorry for a delay. Current version of SDK allows to save image to the same file if:
  • file is single page file and image is changed
  • file is multipage file and all images of multipage file are changed
We will add ability to save changed page of multipage image file into the same file in next version of SDK.

Best regards, Alexander

Re: Load, change and save image to the same file in Image Viewer

Posted: Thu Apr 01, 2010 5:42 pm
by smithsw
Thanks Alex. So it sounds like the code bit " viewer.FocusedImage.Save(filename)" is the right way to go with saving. I'm assuming this saves the current page back into the multipage source file. This will be a good addition if that is the case. Some of our files are 200+ pages long, so only saving the pages that are changed will be a huge time saver.

Any idea on how long until the release of 4.1?

Re: Load, change and save image to the same file in Image Viewer

Posted: Thu Apr 29, 2010 7:25 pm
by Alex
Hello Shane,
Any idea on how long until the release of 4.1?
Version 4.1 will be available in 1-2 weeks.

Best regards, Alexander

Re: Load, change and save image to the same file in Image Vi

Posted: Fri Jun 13, 2014 1:32 am
by pvanderwest
I am getting the same error:

The process cannot access the file 'i:\images\1\440\1499487.tif' because it is being used by another process

I open a file, rotate it then try to save it:

Me.ImageViewer1.Image = New Vintasoft.Imaging.VintasoftImage(filename)

...

ImageViewer1.Image.Save(filename)

Re: Load, change and save image to the same file in Image Vi

Posted: Sat Jun 14, 2014 8:53 pm
by Alex
Hello,

Please read this article:
http://www.vintasoft.com/docs/vsimaging ... mages.html

The article contains the example which shows how to open TIFF file, rotate the second page of TIFF file and save changes in TIFF file.

Best regards, Alexander

Re: Load, change and save image to the same file in Image Viewer

Posted: Tue Sep 01, 2015 2:56 pm
by DanielLW
Hello,

i'm running into the same problem, using the image collection of an ImageViewer-control:

Code: Select all

            Vintasoft.Imaging.Codecs.Encoders.TiffEncoder teTest;

            this.imageViewer1.Images.Add(@"c:\test\test.tif", false);

            this.imageViewer1.Images[0].Rotate(90);


            teTest = new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder();

            teTest.SaveAndSwitchSource = true;

            this.imageViewer1.Images.SaveSync(@"c:\test\test.tif", teTest);
This code runs to the last statement, where it blocks the execution (dead lock?). When i set "SaveAndSwitchSource" to false, i get the In-Use-Exception. Changing the code to FileStream-usage as in the linked example results in the same blocking behaviour.

Is it possible to save changes in an ImageViewer-imagecollection, without the tempfile-workaround?

Using the code-example "Imaging Demo" this saving works somehow, but i'm not sure, why, as the saving process itself seems to be the same as above.

Thank you in advance for your help.

Best regards,
Daniel