peircej / jbrout

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

Wrong choice of preview for a DNG pic #183

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Import a DNG pic (see attachment) into an album
2.
3.

What is the expected output? What do you see instead?
The thumbnail of the images are not visible in the album, the album loading 
stops at the DNG pic, and an exception is raised saying the data is not JPEG 
and starts with 0x4949. 

What version of the product are you using? On what operating system?
SVN version (R328) on Ubuntu 10.10 and pyexiv2 0.3 (from the launchpad)

Please provide any additional information below.

Apparently, with the new pyexiv2, a list of previews is loaded. pyexiv.py (in 
Exiv2Metadata.getThumbnailData()) returns the list (?), and the calling code 
uses the element 1. But what if the element 1 is not a jpeg (as in the exemple 
picture) ? 

It would seem better the check the format (using mime) of the different 
previews, and only send the one we are interested in. 

Original issue reported on code.google.com by chartier...@gmail.com on 25 May 2011 at 11:46

GoogleCodeExporter commented 9 years ago
I extracted the 3 previews available in the image (using pyexiv2 from python 
command line). I believe jbrout is trying to display p1 and not p0 

$ file p?
p0: JPEG image data, JFIF standard 1.01
p1: TIFF image data, little-endian
p2: TIFF image data, little-endian
$ identify p?
p0 JPEG 160x120 160x120+0+0 8-bit DirectClass 3.44KB 0.000u 0:00.000
p1[1] TIFF 160x120 160x120+0+0 8-bit DirectClass 57.8KB 0.000u 0:00.000
p2[2] TIFF 4672x3104 4672x3104+0+0 8-bit DirectClass 1.093MB 0.010u 0:00.010
identify: Improper JPEG sampling factors 2,1
Apparently should be 2,2.. `JPEGPreDecode' @ warning/tiff.c/TIFFWarnings/704.
identify: Decompressor will try reading with sampling 2,1.. `JPEGPreDecode' @ 
warning/tiff.c/TIFFWarnings/704.
$
$ for i in p? ; do echo "=== $i ===" ; od -xc $i | head ; done
=== p0 ===
0000000    d8ff    e0ff    1000    464a    4649    0100    0001    0100
        377 330 377 340  \0 020   J   F   I   F  \0 001 001  \0  \0 001
0000020    0100    0000    dbff    4300    0800    0606    0607    0805
         \0 001  \0  \0 377 333  \0   C  \0  \b 006 006  \a 006 005  \b
0000040    0707    0907    0809    0c0a    0d14    0b0c    0c0b    1219
         \a  \a  \a  \t  \t  \b  \n  \f 024  \r  \f  \v  \v  \f 031 022
0000060    0f13    1d14    1f1a    1d1e    1c1a    201c    2e24    2027
        023 017 024 035 032 037 036 035 032 034 034       $   .   '   
0000100    2c22    1c23    281c    2937    302c    3431    3434    271f
          "   ,   # 034 034   (   7   )   ,   0   1   4   4   4 037   '
=== p1 ===
0000000    4949    002a    0008    0000    000c    0100    0004    0001
          I   I   *  \0  \b  \0  \0  \0  \f  \0  \0 001 004  \0 001  \0
0000020    0000    00a0    0000    0101    0004    0001    0000    0078
         \0  \0 240  \0  \0  \0 001 001 004  \0 001  \0  \0  \0   x  \0
0000040    0000    0102    0003    0003    0000    009e    0000    0103
         \0  \0 002 001 003  \0 003  \0  \0  \0 236  \0  \0  \0 003 001
0000060    0003    0001    0000    0001    0000    0106    0003    0001
        003  \0 001  \0  \0  \0 001  \0  \0  \0 006 001 003  \0 001  \0
0000100    0000    0002    0000    0111    0004    0001    0000    00b4
         \0  \0 002  \0  \0  \0 021 001 004  \0 001  \0  \0  \0 264  \0
=== p2 ===
0000000    4949    002a    0008    0000    000c    0100    0004    0001
          I   I   *  \0  \b  \0  \0  \0  \f  \0  \0 001 004  \0 001  \0
0000020    0000    1240    0000    0101    0004    0001    0000    0c20
         \0  \0   @ 022  \0  \0 001 001 004  \0 001  \0  \0  \0      \f
0000040    0000    0102    0003    0003    0000    009e    0000    0103
         \0  \0 002 001 003  \0 003  \0  \0  \0 236  \0  \0  \0 003 001
0000060    0003    0001    0000    0007    0000    0106    0003    0001
        003  \0 001  \0  \0  \0  \a  \0  \0  \0 006 001 003  \0 001  \0
0000100    0000    0006    0000    0111    0004    0001    0000    00b4
         \0  \0 006  \0  \0  \0 021 001 004  \0 001  \0  \0  \0 264  \0

Original comment by chartier...@gmail.com on 25 May 2011 at 11:47

GoogleCodeExporter commented 9 years ago
My idea would be to wrap getThumbnailData in another function (to preserve 
compatibility with old exiv2) which would walk the different previews, looking 
for one with mime type "image/jpeg", and sending only that one instead of the 
whole list. 

Then we'd replace all calls of getThumbnailData by... (huh... getBestThumbnail 
?) without the [1]. 

Original comment by chartier...@gmail.com on 25 May 2011 at 11:51

GoogleCodeExporter commented 9 years ago

Original comment by chartier...@gmail.com on 27 May 2011 at 5:09

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r332.

Original comment by r...@wallace.gen.nz on 5 Jul 2011 at 10:12

GoogleCodeExporter commented 9 years ago
Agreed, it works on the faulty DNG. But can we be sure that the JPEG thumbnail 
is always the first in the list ? 

Original comment by chartier...@gmail.com on 12 Jul 2011 at 5:36