image: jp2 pow2 reduction fails for some images

Bug #535450 reported by mangtronix
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Internet Archive BookReader
Fix Released
High
mangtronix

Bug Description

JP2 pow2 reduction will fail if insufficient levels are available.

Revision history for this message
mangtronix (mang) wrote :

E.g. http://ia331403.us.archive.org:80/BookReader/BookReaderImages.php?zip=/1/items/cu31924004007625/cu31924004007625_jp2.zip&file=cu31924004007625_jp2/cu31924004007625_0016.jp2&scale=16&rotate=0

$ unzip -p '/1/items/cu31924004007625/cu31924004007625_jp2.zip' 'cu31924004007625_jp2/cu31924004007625_0016.jp2' | /petabox/sw/bin/kdu_expand -no_seek -quiet -reduce 4 -rotate 0 -i /dev/stdin -o /tmp/stdout.bmp | bmptopnm | pnmtojpeg -quality 75 > hmm.jpg
Kakadu Core Error:
Attempting to access a non-existent resolution level within some
tile-component. Problem almost certainly caused by trying to discard more
resolution levels than the number of DWT levels used to compress a
tile-component.
bmptopnm: Windows BMP, 106x163x8
bmptopnm: -: couldn't read row 162
pnmtojpeg: EOF / read error reading magic number

Changed in bookreader:
assignee: nobody → mangtronix (mang)
importance: Undecided → High
status: New → Confirmed
Revision history for this message
mangtronix (mang) wrote :

The number of DWT levels is present in the jp2 codestream.

For example it can be read using the openjpeg command line tool:

http://www.openjpeg.org/index.php?menu=doc

Index file *.Idx : -x index_name.Idx
This option offers the possibility to create an index file.

Number of decompositions (=(number of resolutions - 1)):
NumDWT

Kakadu can also get this information. Not sure if it surfaces in one of their command line tools.

It may be more efficient to catch the case where the requested level is not available instead of reading the codestream first.

Revision history for this message
mangtronix (mang) wrote :

Can pull it out with kdu_expand:

$ kdu_expand -i cu31924004007625_0016.jp2 -record record.txt | grep levels record.txt
Clevels=3

summary: - jp2 pow2 reduction fails for some images
+ image: jp2 pow2 reduction fails for some images
mangtronix (mang)
Changed in bookreader:
milestone: none → r22
Revision history for this message
mangtronix (mang) wrote :

I have code implemented that detects image processing failure and retries at less aggressive reduction level.

mangtronix (mang)
Changed in bookreader:
assignee: mangtronix (mang) → Winnie (winnie-archive)
assignee: Winnie (winnie-archive) → mangtronix (mang)
mangtronix (mang)
Changed in bookreader:
milestone: r22 → r23
mangtronix (mang)
Changed in bookreader:
status: Confirmed → Triaged
Revision history for this message
mangtronix (mang) wrote :

The thumbnail images should always display (they may take some time to load) even if zoomed out and they will be displayed very small.

Changed in bookreader:
assignee: mangtronix (mang) → Winnie (winnie-archive)
Winnie (winnie-archive)
Changed in bookreader:
assignee: Winnie (winnie-archive) → mangtronix (mang)
mangtronix (mang)
Changed in bookreader:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.