How do I reduce the file size of the image embedded using pdftron.PDF.Image.Create()?

Q: I embed a JPEG image using pdftron.PDF.Image.Create(document,
imageFilePath) but the resulting PDF is significantly larger than it
should be. Why is the file so large any is there anything I can do to
make PDF smaller?
--------------------
A: The problem is that despite the file extension the file is actually
a PNG (not a JPEG). The new versions of PDFNet correctly check file
data instead of the extension and pick Flate compression (to preserce
lossless compression). In case you would like to force JPEG you can
pass in the hint parameter in Image.Create() method. The file size
will be _much_ smaller :slight_smile: . For example:

pdftron.PDF.Image img = null;
using (ObjSet hint_set = new ObjSet()) {
Obj enc=hint_set.CreateArray(); // Initialize encoder 'hint'
parameter
enc.PushBackName("JPEG");
enc.PushBackName("Quality");
enc.PushBackNumber(60);
img = pdftron.PDF.Image.Create(doc, "1.jpg", enc);
}

or in C++:

ObjSet hint_set;
Obj enc=hint_set.CreateArray(); // Initialize encoder 'hint'
parameter
enc.PushBackName("JPEG");
enc.PushBackName("Quality");
enc.PushBackNumber(60);
PDF::Image img = PDF::Image::Create(doc, "1.jpg", enc);