Twain Scanning adding pages to multipage TIFF

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
sulfaroj
Posts: 9
Joined: Tue Jun 19, 2012 5:50 am

Twain Scanning adding pages to multipage TIFF

Post by sulfaroj » Mon Jul 09, 2012 5:37 am

Hi,

I am trying to open a current multipage TIFF and add pages to it via Twain acquisition. I am able to add the pages to the file, however as I scan I want to see all the pages in the file as thumbnails. At the moment the pages are loaded into the thumbnail viewer, however if there are more than 23 pages the thumbnails stop loading when scanning starts and as each page is added the thumbnail box appears for the page but no images appear until scanning completes. Anybody have similar issues?

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Twain Scanning adding pages to multipage TIFF

Post by Loïc » Mon Jul 09, 2012 11:35 am

Hello there,

I do not understand at all your process. Could you clarify with snippets please?

Than said, if your goal is to scan to TIFF while displaying thumbnail list of acquired page in real time, it should be easy to accomplish:

1- Create multipage tiff from the first acquired GdPicture Image
2- Add other image to your multipage tiff during your batch scanning
3- When scan is done load the tiff in the thumbnailEx by using the LoadFromGdPictureImage() method
4- At this step you can acquire other page by repeating step2 and then calling LoadNewThumbnails() when you are done.

Kind regards,

Loïc

sulfaroj
Posts: 9
Joined: Tue Jun 19, 2012 5:50 am

Re: Twain Scanning adding pages to multipage TIFF

Post by sulfaroj » Thu Jul 12, 2012 1:49 am

I am opening an existing Multipage Tiff to add additional scanned images. I would like to load all the images in the existing Multipage TIFF and then add the new pages that are scanned. I would like to see the thumbnails added as they scan to the existing thumbnails.


oGdPictureImaging.TiffOpenMultiPageForWrite(true);
AddImageID = oGdPictureImaging.TiffCreateMultiPageFromFile(CurrentFile); //Open an existing file with say 6 pages.

//Start Scanning loop and get ImageID
oGdPictureImaging.TiffAppendPageFromGdPictureImage(AddImageID, ImageID); //Page 7+

ThumbnailEx1.LoadNewThumbnails();

//Exit Scanning Loop

oGdPictureImaging.TiffSaveMultiPageToFile(AddImageID, CurrentFile, TiffCompression.TiffCompressionAUTO);

I also want to save the results to the CurrentFile and when I do this I only get a 1 page image unless I save it to a new filename. How do I get it to update the current file without using temp files?

sulfaroj
Posts: 9
Joined: Tue Jun 19, 2012 5:50 am

Re: Twain Scanning adding pages to multipage TIFF

Post by sulfaroj » Fri Jul 13, 2012 3:25 am

Further to my issues, it seems that functions that were ok in V8.5 are giving me different results. As mentioned earlier I was using

oGdPictureImaging.TiffOpenMultiPageForWrite(true);
imageid = oGdPictureImaging.TiffCreateMultiPageFromFile(CurrentFile);

and

oGdPictureImaging.TiffSaveMultiPageToFile(imageid, CurrentFile, TiffCompression.TiffCompressionAUTO);

to write my changes. Now when I do this I only get the first page.

For example this was previously working:

private void ThumbnailEx1_ItemMoved(int srcIdx, int dstIdx)
{
int imageid = 0;
int CurrentPage = 0;
CurrentPage = GdViewer1.CurrentPage;
oGdPictureImaging.TiffOpenMultiPageForWrite(true);
imageid = oGdPictureImaging.TiffCreateMultiPageFromFile(CurrentFile);


oGdPictureImaging.TiffMovePage(imageid, srcIdx + 1, dstIdx + 1);
GdViewer1.DisplayFromGdPictureImage(imageid);
oGdPictureImaging.TiffSaveMultiPageToFile(imageid, CurrentFile, TiffCompression.TiffCompressionAUTO);
oGdPictureImaging.TiffSelectPage(imageid, dstIdx+1);
GdViewer1.DisplayPage(dstIdx + 1);

}

The results now on a multipage eg 10 pages are a file with 2 pages. If I save the same file to a temp file, the image is correct. In 8.5 there was no issue with this. Is anyone expeiencing this?

rattunnel
Posts: 2
Joined: Tue Jul 17, 2012 5:37 am

Re: Twain Scanning adding pages to multipage TIFF

Post by rattunnel » Tue Jul 17, 2012 10:51 pm

Im having same issue. Doesnt like the Save Function. doesnt save additional pages. Didnt have a problem previously either.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Twain Scanning adding pages to multipage TIFF

Post by Loïc » Tue Jul 17, 2012 11:32 pm

Hello,

You can not overwrite a file opened by the library. If you want to do that you have to save to another destination, for example mytif.tmp, close the loaded file, remove it, and rename the mytif.tmp to mytif.tif.
I know the mentioned way was working in V8, in certain conditions, but this was not the goal of the TiffOpenMultiPageForWrite() method.

Another workaround, which I do not suggest for large tiff handling, is to load the file content into a memoryStream and then open the document from this memorystream.

Kind regards,

Loïc

rshih
Posts: 3
Joined: Thu Sep 27, 2012 8:38 pm

Re: Twain Scanning adding pages to multipage TIFF

Post by rshih » Thu Sep 27, 2012 8:50 pm

I would also like to scan and add pages to an existing multipage tiff. Here is my issue:

When you scan and create the original file, I use "TiffSaveAsMultiPageFile", and the follow with "TiffAddToMultiPageFile" for each image you want to add. This seems to save each page to disk each time it is called-- and it works fast.

Now I want to open and add more pages to this multipage tiff, and save each added page in real time, just like above. If I open the multipage tiff, start scanning, and use "TiffAppendPageFromGdPictureImage", i think it requires for me to use "TiffSaveMultiPageToFile" after each scanned page...which ends up slowing down the process.

I would like to be able to a method like "TiffAddToMultiPageFile" (fast) to an existing file

Is there a better way?

Regards,
Richard

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: Twain Scanning adding pages to multipage TIFF

Post by SamiKharma » Sun Sep 30, 2012 11:01 am

Hi,

>> i think it requires for me to use "TiffSaveMultiPageToFile" after each scanned page

This is NOT true. Just keep on adding scanned pages using TiffAppendPageFromGdPictureImage , then just call TiffSaveMultiPageToFile once at the end.

Best,
Sami

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest