Using JBIG2 compression when creating new PDF images.

Q:

We are looking for a jbig2 pdf compression tool for our application.

I downloaded your sdk and when I tried "addImageText" example, and we
replaced the tiff "grayscale.tif" with our own file, and comment out
all other codes for creating new pages. and ran. Toutuput pdf size
(single page only) is only 1/2 of the original tiff size, usually it
should be 1/3 to 1/4 of the original size.

How should I use your tool to get better jbig2 compression ration
please?
----

A:
The compression ratio would depend on the structure of input
monochrome image. If the TIFF file is not monochrome (e.g. it is
grayscale or RGB/CMYK) you will not see any filesize change because
JBIG2 compression only applies to 1BPP monochrome images. Also the
compression ratio will be higher for document pages with lots of text
symbols (for halftone images and generic areas the compression ratio
is not better than G4 Fax compression). You can also improve on
compression ratio if you enable 'lossy' JBIG2 compression. Please see
JBIG2 sample project for an example of how to specify JBIG lossy hint
when creating a new PDF image.

Q:

We are very interested in your PDFNet SDK because its conversion speed
is fast and codes needed are concise. However, we have tried your
suggestions, but we can’t achieve better JBIG2 compression ratio.

We slightly modified your c# example as following,

// Add a TIFF image to the output file
Obj JBIG2_hint = Obj.CreateArray();
JBIG2_hint.PushBack(Obj.CreateName(“JBIG2”));
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(input_path +
“grayscale.tif”);
Image img = Image.Create(doc, bmp, JBIG2_hint);
Element element = f.CreateImage(img, new Matrix2D(bmp.Width/5, 0, 0,
bmp.Height/5, 0, 0));
writer.WritePlacedElement(element);

A:

There is an error in your ‘encoder hint’. The code should be as
follows:

Obj JBIG2_hint = Obj.CreateArray();
JBIG2_hint.PushBack(Obj.CreateName(“JBIG2”));

System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(input_path +

“grayscale.tif”);
Image img = Image.Create(doc, bmp, JBIG2_hint);

There are also other ways to tweak JBIG2 compression in PDFNet but
this code should be a good starting point.