Giter VIP home page Giter VIP logo

Comments (12)

zdenop avatar zdenop commented on July 17, 2024

Can you share also tiff file?

from leptonica.

Sicos1977 avatar Sicos1977 commented on July 17, 2024

You can use any of these tiff files, they all have the same problem --> https://github.com/Sicos1977/TesseractOCR/tree/master/TesseractOCR.Tests/Data/Conversion

from leptonica.

zdenop avatar zdenop commented on July 17, 2024

C code works for me without a problem:

#include <leptonica/allheaders.h>

int main(int argc, char **argv) {
  char *filein;
  PIX *pixs;
  l_ok ret;
  l_int32  LeptMsgSeverity = 1;

  if (argc != 2)
     return fprintf(stderr," Syntax:  %s filein", argv[0]);

  filein = argv[1];

  if ((pixs = pixRead(filein)) == NULL) {
    ERROR_INT("pix not made", __func__, 1);
  } else {
    fprintf(stderr, "Leptonica loaded: %s\n", filein);
  }
 
  ret = pixWrite("pixs.png", pixs, IFF_PNG);
  if (ret > 0)
    ERROR_INT("ret of pixWrite: ", __func__, ret);
  pixDestroy(&pixs);
  return ret;
}

compiled with (MSVC 2019, Windows 10 64bit; libtiff 4.4.0):

cl test_tiff.c -I..\include ..\lib\leptonica-1.83.0.lib

e.g. test_tiff.exe photo_palette_4bpp.tif creates the correct png output...
Seems like a problem with wrapping leptonica in C# .NET...

from leptonica.

Sicos1977 avatar Sicos1977 commented on July 17, 2024

Weird because 1.82 works without any problems. Is there a way to see if the tif library is compiled into the output file?

from leptonica.

zdenop avatar zdenop commented on July 17, 2024

Well, you should see an error message (in the console/terminal) if you try to open unsupported image format.
Also, check the output of leptonica function getImagelibVersions.

You can also try to open an image with a format that does not need external lib (pbn, ppn, bmp) and save it as tiff...

from leptonica.

vsolominov avatar vsolominov commented on July 17, 2024

Images are saved in tiff format correctly.
Versions of built-in libraries in leptonica-1.83.0:

  • libgif 5.2.1
  • libjpeg 6b (libjpeg-turbo 2.0.6)
  • libpng 1.6.37
  • libtiff 4.3.0
  • zlib 1.2.11

I think this is due to the fact that the image format (e. g. photo_rgb_32bpp.tif file) is not tiff but bitmap:

image

Looking at the commit d4ab740f6c0d40fe12ddc15c9ceba1f614711665 Leptonica does not support 32 bpp images.

from leptonica.

Sicos1977 avatar Sicos1977 commented on July 17, 2024

I checked one of the files with a hex editor and that seems like a tiff to me... as far as I know the first few bytes of a tiff image are always II

image

49 49 2A 00 (little-endian) II*␀ 0 tiftiff Tagged Image File Format (TIFF)[10]
49 49 2A 00 (little-endian) II*␀ 0 tif tiff [Tagged Image File Format](https://en.wikipedia.org/wiki/Tagged_Image_File_Format) (TIFF)[[10]](https://en.wikipedia.org/wiki/List_of_file_signatures#cite_note-10)

from leptonica.

vsolominov avatar vsolominov commented on July 17, 2024

Yes, this is true for all files except what I wrote above (photo_rgb_32bpp.tif)

from leptonica.

zdenop avatar zdenop commented on July 17, 2024

When I run >test_tiff.exe photo_rgb_32bpp.tif I see this message:

Error in pixReadMemBmp: 32 bpp rgba input data is not supported
Error in pixReadStream: bmp: no pix returned
Error in pixRead: pix not read
Error in main: pix not made
Error in pixWrite: pix not defined

from leptonica.

Sicos1977 avatar Sicos1977 commented on July 17, 2024

The only thing I find weird is that all files seem to work when using version 1.82. I have to dive deeper into this to see if I did something wrong but that will be next week because I'm busy with another project at the moment.

from leptonica.

zdenop avatar zdenop commented on July 17, 2024
  1. As already mentioned by vsolominov photo_rgb_32bpp.tif is BMP file with wrong extensions. The same message you can get with IrfanView
  2. leptonica 1.82 reads it - but when you run my tests code, the output in PNG does not have correct colors
  3. leptonica 1.83 refuse to load it - reason is explain in this commit d4ab740

from leptonica.

Sicos1977 avatar Sicos1977 commented on July 17, 2024
  1. As already mentioned by vsolominov photo_rgb_32bpp.tif is BMP file with wrong extensions. The same message you can get with IrfanView
  2. leptonica 1.82 reads it - but when you run my tests code, the output in PNG does not have correct colors
  3. leptonica 1.83 refuse to load it - reason is explain in this commit d4ab740

Okay, thinks missed that one.

from leptonica.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.