AmitGorvadiya / leptonica

Automatically exported from code.google.com/p/leptonica
0 stars 0 forks source link

Zero resolution info for jpeg #62

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I use this code:
    inputImage = pixRead("P1140724.JPG");
    pixGetResolution(inputImage, &xres, &yres);
    printf("Resolution: %ix%i.\n", xres, yres);
and I got output:
Resolution: 0x0.

Expected result:
Resolution: 180x180.

Imagick (identify -verbose P1140724.JPG | grep Resolution) gives this 
information:
 Resolution: 180x180
Also IrfanView give this info about resolution.

The same code work ok if I read png file.

What version of the product are you using? On what operating system?
leptonica 1.68 on linux (opensuse 12.1 64bit) windows XP SP3 (32bit).

Original issue reported on code.google.com by zde...@gmail.com on 4 Jun 2012 at 7:17

Attachments:

GoogleCodeExporter commented 9 years ago
The jpeg cinfo.density_unit field for this image is 0, which means that the 
resolution is not defined.  No idea how identify arrives at 180 ppi.  Is there 
any reason to believe the resolution should be 180 ppi?

For pixels/inch (ppi), that field must be 1.
For this image, the values in cinfo.X_density and cinfo.Y_density are both 1.

gimp interprets undefined density as 1 pixel/pt = 72 ppi.  Pretty arbitrary.
leptonica uses 0.

Original comment by dan.bloo...@gmail.com on 4 Jun 2012 at 9:16

GoogleCodeExporter commented 9 years ago
I can not guarantee that image has 180 DPI (well this is information I am 
looking for). 

But IrfanView show nothing if there is no DPI info and in this case it shows 
180. So I tried to test it with Imagick and it "proves" that DPI is 180 ;-).

I got another idea today - if exif info do not store resolution and it looks 
like this could be case: I tried it in http://regex.info/exif.cgi and it shows 
this information:
    Resolution  180 pixels/inch
    X Resolution    72
    Y Resolution    72

Original comment by zde...@gmail.com on 12 Jun 2012 at 2:28

GoogleCodeExporter commented 9 years ago
I removed exif info and Imagick, IrfanView and XnView shows image has 180 DPI...
So there should be other way how to get info about resolution...
If it helps image was created by camera...

Original comment by zde...@gmail.com on 18 Jun 2012 at 8:39

GoogleCodeExporter commented 9 years ago
On Windows 7, using ACDSee to view the sample jpeg shows EXIF metadata has X 
Resolution & Y Resolution set to 180/1 and Resolution Unit is inches. IrfanView 
shows same thing.

After cleaning all exif metadata using exiftool [1] via the following command:

  exiftool -all= P1140724.JPG

ACDSee & Irfanview both don't show any value for X & Y Resolution. So, IMO, the 
exif metadata *is* how this is determined for jpeg files.

IMO, especially for OCR purposes, people should *not* use jpeg and instead use 
lossless TIFF or PNG and make sure the resolution is set correctly.

[1] http://www.sno.phy.queensu.ca/~phil/exiftool/

Original comment by tomp2...@gmail.com on 26 Jun 2012 at 10:40

GoogleCodeExporter commented 9 years ago
Thanks, Tom.  Not looking forward to parsing exif in jpeg.
Seems like low priority.

Original comment by dan.bloo...@gmail.com on 27 Jun 2012 at 3:49

GoogleCodeExporter commented 9 years ago
1.70 is out.  You can get it at leptonica.org/download.html

It still doesn't parse exif fields in jepg for hidden resolution  ;-)

Original comment by dan.bloo...@gmail.com on 24 Jan 2014 at 6:49