Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, February 12, 2008 10:05:29 AM(UTC)
kchakraborti

Groups: Registered
Posts: 17


Hello,

I am trying to split a source TIFF containing X number of pages and merge back X-Y pages to create a target TIFF file. As expected, doing this with GDI+ takes quite a while (approx 1 second per split + merge operation) and is not upto my performance requirements. So I wish to investigate doing the same using RasterImage as follows:

using Leadtools;

using Leadtools.Codecs;

public bool mergeTiffPagesUsingLead(string[] sourceFiles, string targetFile)

{

bool response = false;

try

{

//Having lines of code do NOT make any difference

//RasterCodecs.CodecsPath = @"C:\Program Files\LEAD Technologies, Inc\LEADTOOLS14.5\Bin\Dotnet\v20";

//RasterCodecs rc = new RasterCodecs();

//rc.PreloadCodecs(1 , 0, "TIF");

//RasterSupport.Unlock(RasterSupportType.TifLzw, "NhY5543d");

//if (RasterSupport.IsLocked(RasterSupportType.TifLzw))

//{

// System.Exception ex = new Exception("Locked: TIFFLZW");

// throw ex;

//}

for (int i = 0; i < sourceFiles.Length; i++)

{

IRasterImage image = new RasterImage(System.Drawing.Image.FromFile(sourceFiles[i]));         // WORKS

rc.Save(image, targetFile, RasterImageFormat.Tif, 1, 1, 1, 1, CodecsSavePageMode.Append);   // THROWS EXCEPTION

}

}

catch (Exception ex)

{

throw ex;

}

return response;

}

The issue that I have is rc.Save() method is throwing "Feature not supported" exception. So my question is:

1. Is there an error in the way I am calling the methods?

2. If my way of calling the method is OK, is there a licensing limitation that I have with whatever we have bought?

We are using LeadTools V14.5. The sample TIFF is attached. The serial number related details I will be able to send in an email once requested.

Thanks,

Kaushik

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, February 12, 2008 10:07:09 AM(UTC)
kchakraborti

Groups: Registered
Posts: 17


Here comes the attachment...
File Attachment(s):
TIFFIN.zip (182kb) downloaded 97 time(s).
 
#3 Posted : Wednesday, February 13, 2008 1:47:18 AM(UTC)

Qasem Lubani  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)


The problem is probably related to passing the Append flag when there's no initial file to append to.


In all cases, your code is not
very efficient, and there could be a better way to do it. Instead of loading
using GDI, then converting to LEADTOOLS image, then saving as TIFF, you can
simply re-arrange the TIFF pages without decoding and re-coding them using the CompactFile method.

 
#4 Posted : Wednesday, February 13, 2008 3:36:14 AM(UTC)
kchakraborti

Groups: Registered
Posts: 17


This is really helpful, thanks for sharing this info. I got the CompactFile method to work but having hard time trying to figure out the appropriate parameters to be passed, since it is copying all pages now. Here is what I am using:

public bool mergeTiffPagesUsingLead(string sourceFile, string targetFile, int[] pageNumbers)

{

bool response = false;

try

{

RasterCodecs rc = new RasterCodecs();

for (int i = 0; i < pageNumbers.Length; i++)

{

rc.CompactFile(sourceFile, targetFile, pageNumbers[i], pageNumbers[i], false, 1, 0, false, 1, CodecsSavePageMode.Insert, false, false);

}

}

catch (Exception ex)

{

throw ex;

}

return response;

}

 

The way I am calling this method is mergeTiffPagesUsingLead("C:\\IN.TIFF", "C:\\OUT.TIFF", new int[3]{1,3,5})

I wish to copy pages 1, 3 and 5 from input to output file.

Your help is highly appreciated.

Thanks, Kaushik

 
#5 Posted : Wednesday, February 13, 2008 3:40:42 AM(UTC)
kchakraborti

Groups: Registered
Posts: 17


Never mind, I figured it out. Actually this method is 65 times faster than doing the same with GDI+.

LeadTools is the best!

Thanks a billion,

Kaushik

 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.110 seconds.