Skip to content

Commit c375f4f

Browse files
committed
keep API compatibility with #1265
1 parent 7be5f74 commit c375f4f

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

src/api/capi.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ TESS_API TessResultRenderer* TESS_CALL TessHOcrRendererCreate2(const char* outpu
6767
}
6868

6969
TESS_API TessResultRenderer* TESS_CALL TessPDFRendererCreate(const char* outputbase, const char* datadir,
70-
BOOL textonly, int jpg_quality)
70+
BOOL textonly)
7171
{
72-
return new TessPDFRenderer(outputbase, datadir, textonly, jpg_quality);
72+
return new TessPDFRenderer(outputbase, datadir, textonly);
7373
}
7474

7575
TESS_API TessResultRenderer* TESS_CALL TessUnlvRendererCreate(const char* outputbase)

src/api/capi.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ TESS_API TessResultRenderer* TESS_CALL TessTextRendererCreate(const char* output
127127
TESS_API TessResultRenderer* TESS_CALL TessHOcrRendererCreate(const char* outputbase);
128128
TESS_API TessResultRenderer* TESS_CALL TessHOcrRendererCreate2(const char* outputbase, BOOL font_info);
129129
TESS_API TessResultRenderer* TESS_CALL TessPDFRendererCreate(const char* outputbase, const char* datadir,
130-
BOOL textonly, int jpg_quality);
130+
BOOL textonly);
131131
TESS_API TessResultRenderer* TESS_CALL TessUnlvRendererCreate(const char* outputbase);
132132
TESS_API TessResultRenderer* TESS_CALL TessBoxTextRendererCreate(const char* outputbase);
133133

src/api/pdfrenderer.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,12 @@ static const int kMaxBytesPerCodepoint = 20;
179179
/**********************************************************************
180180
* PDF Renderer interface implementation
181181
**********************************************************************/
182-
183182
TessPDFRenderer::TessPDFRenderer(const char *outputbase, const char *datadir,
184-
bool textonly, int jpg_quality)
183+
bool textonly)
185184
: TessResultRenderer(outputbase, "pdf"),
186185
datadir_(datadir) {
187186
obj_ = 0;
188187
textonly_ = textonly;
189-
jpg_quality_ = jpg_quality;
190188
offsets_.push_back(0);
191189
}
192190

@@ -700,7 +698,8 @@ bool TessPDFRenderer::imageToPDFObj(Pix *pix,
700698
const char* filename,
701699
long int objnum,
702700
char **pdf_object,
703-
long int *pdf_object_size, int jpg_quality) {
701+
long int* pdf_object_size,
702+
const int jpg_quality) {
704703
size_t n;
705704
char b0[kBasicBufSize];
706705
char b1[kBasicBufSize];
@@ -713,13 +712,12 @@ bool TessPDFRenderer::imageToPDFObj(Pix *pix,
713712
return false;
714713

715714
L_Compressed_Data *cid = nullptr;
716-
const int kJpegQuality = jpg_quality;
717715

718716
int format, sad;
719717
if (pixGetInputFormat(pix) == IFF_PNG)
720718
sad = pixGenerateCIData(pix, L_FLATE_ENCODE, 0, 0, &cid);
721719
if (!cid) {
722-
sad = l_generateCIDataForPdf(filename, pix, kJpegQuality, &cid);
720+
sad = l_generateCIDataForPdf(filename, pix, jpg_quality, &cid);
723721
}
724722

725723
if (sad || !cid) {
@@ -910,7 +908,10 @@ bool TessPDFRenderer::AddImageHandler(TessBaseAPI* api) {
910908

911909
if (!textonly_) {
912910
char *pdf_object = nullptr;
913-
if (!imageToPDFObj(pix, filename, obj_, &pdf_object, &objsize, jpg_quality_)) {
911+
int jpg_quality;
912+
api->GetIntVariable("jpg_quality", &jpg_quality);
913+
if (!imageToPDFObj(pix, filename, obj_, &pdf_object, &objsize,
914+
jpg_quality)) {
914915
return false;
915916
}
916917
AppendData(pdf_object, objsize);

src/api/renderer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class TESS_API TessPDFRenderer : public TessResultRenderer {
187187
public:
188188
// datadir is the location of the TESSDATA. We need it because
189189
// we load a custom PDF font from this location.
190-
TessPDFRenderer(const char* outputbase, const char* datadir, bool textonly = false, int jpg_quality = 85);
190+
TessPDFRenderer(const char* outputbase, const char* datadir, bool textonly = false);
191191

192192
protected:
193193
virtual bool BeginDocumentHandler();
@@ -214,7 +214,7 @@ class TESS_API TessPDFRenderer : public TessResultRenderer {
214214
char* GetPDFTextObjects(TessBaseAPI* api, double width, double height);
215215
// Turn an image into a PDF object. Only transcode if we have to.
216216
static bool imageToPDFObj(Pix* pix, const char* filename, long int objnum,
217-
char** pdf_object, long int* pdf_object_size, int jpg_quality);
217+
char** pdf_object, long int* pdf_object_size, const int jpg_quality);
218218
};
219219

220220

src/api/tesseractmain.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,8 @@ static void PreloadRenderers(
418418
#endif // WIN32
419419
bool textonly;
420420
api->GetBoolVariable("textonly_pdf", &textonly);
421-
int jpg_quality;
422-
api->GetIntVariable("jpg_quality", &jpg_quality);
423421
renderers->push_back(new tesseract::TessPDFRenderer(
424-
outputbase, api->GetDatapath(), textonly, jpg_quality));
422+
outputbase, api->GetDatapath(), textonly));
425423
}
426424

427425
api->GetBoolVariable("tessedit_write_unlv", &b);

0 commit comments

Comments
 (0)