You are viewing limited content. For full access, please sign in.

Question

Question

JPEG Compression

asked on January 20, 2016

We have a problem with data size in our repository. One thing I've noticed is that our color images are ranging between 7-10MB per page.

I put in place the [OPTIONS]DefaultColorFormatSNBD per my VAR and this article: https://support.laserfiche.com/kb/1012570

However, 7-10MB per page seems pretty excessive.

 

2 Questions:

1) Is 7-10MB the average per page in color for other users?

2) What other options do I have? I have already sent multiple instructions to scan in grayscale instead, saving about 66% of the space the same color document takes.

 

All of our users scan through Laserfiche Scanning using the TWAIN driver.

0 0

Replies

replied on January 21, 2016

Hi Dave,

I had a similar problem. Turned out LF was stroring the docs as TIFF-LZH. At any rate, if the images are TIFF-LZH or TIFF-JPG, you could use the Laserfiche SDK to convert all of the TIFF-LZH to to TIFF-JPG format and that would allow you to set a custom level of compression and greatly reduce your storage (and bandwidth) requirements or colour images.

I could help you out with some software but your VAR could probably assist here, too.

-Ben

1 0
replied on January 21, 2016

Thanks Ben. We don't have the SDK currently. So did you use the SDK to program something to convert them or does the SDK come with that utility?

0 0
replied on January 21, 2016

You're welcome Dave.

I used the SDK to program something. The kit doesn't contain any utilities as such.

-Ben

0 0
replied on June 30, 2016

Hi Ben,

 

Would you please direct me to the proper SDK functions to convert TIFF-LZH to TIFF-JPG format with custom level of compression?

 

I appreciate your help.

0 0
replied on July 5, 2016

Hi Abdellah,

 

The functions are in the Laserfiche.Imaging.LfiImageConverter and the Laserfiche.Imaging.LfiBitmapDecoder classes.

To set the level of compression, use the .Quality property of an object created from the Laserfiche.Imaging.LfiImageConverter class.

I've been away for a bit, so wasn't able to reply for a while. Hope that helps!

 

 

 

1 0
replied on July 12, 2016 Show version history

Thank you Ben for your help, 

 

The code is working with good compression results but I noticed that the  results of Photodocs way is better than SDK's (at least half size less than SDK way) while we use same compression values (Jpeg codec with same quality) 

 

For example:

On document with 307.5 MB & 80 pages using compression quality = 40:

  • With SDK: Result = 60 MB
  • With Photodocs: Result = 30 MB

 

Do you have any idea about what is missing in the code to have matching results or close results at least?

0 0
replied on July 12, 2016

That's unexpected.

 

Are you changing the TIFF type from TIFF-LZH (Laserfiche default) to TIFF-JPEG?

oImgConv.Quality = m_intLossyQualityFactor
oImgConv.ConvertFile(oSourceMemoryStream, 0, oDestMemoryStream, m_intDestContainer, m_intDestCodec)

-Ben

0 0
replied on July 12, 2016 Show version history

Abdellah,

Also, are you compressing each page?

For Each oLFPage As LFPage In oLFPgs
    oLFImg = oLFPage.Image
    'RaiseEvent ProcessingPages(oLFPage.PageNum.ToString, oLFPgs.Count.ToString, 1, oLFPgs.Count, oLFPage.PageNum)
    If oLFImg.BitsPerPixel > 1 Then 'is this colour? I don't convert B&W pages

 

0 0
replied on July 13, 2016 Show version history

Yes I'm compressing each page from Laserfiche default TIFF-LZW to TIFF-JPEG.

string myDocument = txtDocPath.Text;
int jpegQuality = int.Parse(txtQuality.Text);

LFApplication app = new LFApplication();
LFConnection conn = new LFConnection();
LFServer serv;
LFDatabase db;

serv = app.GetServerByName("localhost");
db = serv.GetDatabaseByName("Demo");
conn.UserName = "Admin";
conn.Password = "";

conn.Create(db);

Laserfiche.Imaging.LfiImageConverter imgConv = new Laserfiche.Imaging.LfiImageConverter();

LFDocument doc = (LFDocument)db.GetEntryByPath(myDocument);
LFDocumentPages DocPages = (LFDocumentPages)doc.Pages;

int imgSize;
LFImage lfImg;

foreach (LFPage mylfPage in doc.Pages)
{
	lfImg = mylfPage.Image;
	imgSize = (int)lfImg.FileInfo.Size;
	if(lfImg.BitsPerPixel > 1)
	{		
		LFImageReadStream msR = (LFImageReadStream)lfImg.ReadStream;
		byte[] oByt0 = new byte[msR.DataLength];
		object oByt = (object)oByt0;
		
		msR.Open();
		msR.ReadToBuffer(ref oByt);
		MemoryStream msSource = new MemoryStream();
		msSource.Write((byte[])oByt, 0, imgSize);
		msSource.Seek(0, 0);
		
		MemoryStream msDest = new MemoryStream();
		msDest.Seek(0, 0);
		imgConv.Quality = jpegQuality;
		imgConv.ConvertFile(msSource, 0, msDest, Laserfiche.Imaging.LfiContainerFormat.Tiff, Laserfiche.Imaging.LfiBitmapCodec.Jpeg);
		
		LFImageWriteStream msW = (LFImageWriteStream)lfImg.WriteStream;
		msW.Open(msDest.Capacity);
		msDest.Seek(0, 0);
		msW.Write(msDest.GetBuffer());
		msW.Close();
		msW.Update();
	}
}

 

 

1 0
replied on July 24, 2016

Could you upload sample images?

0 0
replied on May 29, 2017

Hello Ben and Abdellah,

I am also trying to figure out how to compress the TIFF image files for a client. I don't really know how to use the SDK scripts though. I tried copying and pasting from Abdellah's post, but there must be more to it?

Thanks in advance for any assistance you can offer

 

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.