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

Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.

Moderator: Alex

Alex
Site Admin
Posts: 2303
Joined: Thu Jul 10, 2008 2:21 pm

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

Post 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
smithsw
Posts: 11
Joined: Fri Mar 19, 2010 9:21 pm

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

Post 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
Alex
Site Admin
Posts: 2303
Joined: Thu Jul 10, 2008 2:21 pm

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

Post 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
smithsw
Posts: 11
Joined: Fri Mar 19, 2010 9:21 pm

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

Post 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?
Alex
Site Admin
Posts: 2303
Joined: Thu Jul 10, 2008 2:21 pm

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

Post 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
smithsw
Posts: 11
Joined: Fri Mar 19, 2010 9:21 pm

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

Post 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?
Alex
Site Admin
Posts: 2303
Joined: Thu Jul 10, 2008 2:21 pm

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

Post 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
pvanderwest
Posts: 8
Joined: Wed Apr 02, 2014 3:08 am

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

Post 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)
Alex
Site Admin
Posts: 2303
Joined: Thu Jul 10, 2008 2:21 pm

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

Post 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
DanielLW
Posts: 22
Joined: Tue Sep 01, 2015 2:42 pm

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

Post 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
Post Reply