Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not recognise file with transparent background #369

Closed
nmondal opened this issue Jul 18, 2016 · 2 comments
Closed

Does not recognise file with transparent background #369

nmondal opened this issue Jul 18, 2016 · 2 comments
Assignees

Comments

@nmondal
Copy link

nmondal commented Jul 18, 2016

Hi,
I just found out it can not read from a file having transparent background!
join
join

See yourself!
When I use the png with transparent background, it fails.
Using the same JPG file, it runs beautifully.

@jbreiden
Copy link
Contributor

jbreiden commented Jul 18, 2016

If you think that's exciting, check out the PDF output. Looks like we have at least one bug on our hands. Thanks for reporting this.

foo.pdf

bug

@jbreiden jbreiden self-assigned this Jul 18, 2016
@jbreiden
Copy link
Contributor

This will take care of the PDF portion (so that we blend with white instead of just stripping the entire alpha channel). The recognition part is probably a discussion with Ray. Reading the source code, it is not clear to me why we don't recognize. Alpha looks like it is treated like any other color channel as opposed to something special.

--- tesseract/api/pdfrenderer.cpp   2016-07-06 13:19:57.000000000 -0700
+++ tesseract/api/pdfrenderer.cpp   2016-07-20 16:23:13.000000000 -0700
@@ -690,8 +690,9 @@
   int format, sad;
   findFileFormat(filename, &format);
   if (pixGetSpp(pix) == 4 && format == IFF_PNG) {
-    pixSetSpp(pix, 3);
-    sad = pixGenerateCIData(pix, L_FLATE_ENCODE, 0, 0, &cid);
+    Pix *p1 = pixAlphaBlendUniform(pix, 0xffffff00);
+    sad = pixGenerateCIData(p1, L_FLATE_ENCODE, 0, 0, &cid);
+    pixDestroy(&p1);
   } else {
     sad = l_generateCIDataForPdf(filename, pix, kJpegQuality, &cid);
   }

@zdenop zdenop closed this as completed in 5610738 Aug 5, 2016
zvezdochiot pushed a commit to ImageProcessing-ElectronicPublications/tesseract that referenced this issue Mar 28, 2021
zvezdochiot pushed a commit to ImageProcessing-ElectronicPublications/tesseract that referenced this issue Mar 28, 2021
zvezdochiot pushed a commit to ImageProcessing-ElectronicPublications/tesseract that referenced this issue Mar 28, 2021
zvezdochiot pushed a commit to ImageProcessing-ElectronicPublications/tesseract that referenced this issue Mar 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants