@@ -431,8 +431,7 @@ bool TessPDFRenderer::BeginDocumentHandler() {
431
431
return true ;
432
432
}
433
433
434
- bool TessPDFRenderer::imageToPDFObj (TessBaseAPI* api,
435
- Pix *pix,
434
+ bool TessPDFRenderer::imageToPDFObj (Pix *pix,
436
435
char *filename,
437
436
long int objnum,
438
437
char **pdf_object,
@@ -449,32 +448,25 @@ bool TessPDFRenderer::imageToPDFObj(TessBaseAPI* api,
449
448
return false ;
450
449
451
450
L_COMP_DATA *cid = NULL ;
452
- int kJpegQuality ;
453
- int encoding_type;
454
- api->GetIntVariable (" tessedit_pdf_jpg_quality" , &kJpegQuality );
455
- api->GetIntVariable (" tessedit_pdf_compression" , &encoding_type);
456
- if (encoding_type > 0 && encoding_type < 4 ) {
457
- if (pixGenerateCIData (pix, encoding_type, kJpegQuality , 0 , &cid) != 0 )
458
- return false ;
451
+ const int kJpegQuality = 85 ;
452
+ l_generateCIDataForPdf (filename, pix, kJpegQuality , &cid);
453
+ // TODO(jbreiden) Leptonica 1.71 doesn't correctly handle certain
454
+ // types of PNG files, especially if there are 2 samples per pixel.
455
+ // We can get rid of this logic after Leptonica 1.72 is released and
456
+ // has propagated everywhere. Bug discussion as follows.
457
+ // https://code.google.com/p/tesseract-ocr/issues/detail?id=1300
458
+ int format, sad;
459
+ findFileFormat (filename, &format);
460
+ if (pixGetSpp (pix) == 4 && format == IFF_PNG) {
461
+ pixSetSpp (pix, 3 );
462
+ sad = pixGenerateCIData (pix, L_FLATE_ENCODE, 0 , 0 , &cid);
459
463
} else {
460
- // TODO(jbreiden) Leptonica 1.71 doesn't correctly handle certain
461
- // types of PNG files, especially if there are 2 samples per pixel.
462
- // We can get rid of this logic after Leptonica 1.72 is released and
463
- // has propagated everywhere. Bug discussion as follows.
464
- // https://code.google.com/p/tesseract-ocr/issues/detail?id=1300
465
- int format, sad;
466
- findFileFormat (filename, &format);
467
- if (pixGetSpp (pix) == 4 && format == IFF_PNG) {
468
- pixSetSpp (pix, 3 );
469
- sad = pixGenerateCIData (pix, L_FLATE_ENCODE, 0 , 0 , &cid);
470
- } else {
471
- sad = l_generateCIDataForPdf (filename, pix, kJpegQuality , &cid);
472
- }
464
+ sad = l_generateCIDataForPdf (filename, pix, kJpegQuality , &cid);
465
+ }
473
466
474
- if (sad || !cid) {
475
- l_CIDataDestroy (&cid);
476
- return false ;
477
- }
467
+ if (sad || !cid) {
468
+ l_CIDataDestroy (&cid);
469
+ return false ;
478
470
}
479
471
480
472
const char *group4 = " " ;
@@ -665,7 +657,7 @@ bool TessPDFRenderer::AddImageHandler(TessBaseAPI* api) {
665
657
AppendPDFObjectDIY (objsize);
666
658
667
659
char *pdf_object;
668
- if (!imageToPDFObj (api, pix, filename, obj_, &pdf_object, &objsize)) {
660
+ if (!imageToPDFObj (pix, filename, obj_, &pdf_object, &objsize)) {
669
661
return false ;
670
662
}
671
663
AppendData (pdf_object, objsize);
0 commit comments