jwilk / didjvu

DjVu encoder with foreground/background separation
https://jwilk.net/software/didjvu
GNU General Public License v2.0
10 stars 8 forks source link

lossless bundle --pages-per-dict 2 of twice the same picture doesn't make a meaningful shared dictionary without --lossy option #20

Closed rmast closed 9 months ago

rmast commented 3 years ago

./didjvu bundle test.tif test.tif -o jaarverslagraar10k.djvu --fg-slices 100 -d 600 --bg-slices 0 --pages-per-dict 2

with test.tif the same picture of my previous issues renamed:

djvudump jaarverslagraar10k.djvu
  FORM:DJVM [61329] 
    DIRM [52]         Document directory (bundled, 3 files 2 pages)
    FORM:DJVI [13] {test.iff} [I]
      Djbz [1]          JB2 shared dictionary
    FORM:DJVU [30613] {test.djvu} [P1]
      INFO [10]         DjVu 4364x6896, v24, 600 dpi, gamma=2.2
      INCL [8]          Indirection chunk --> {test.iff}
      Sjbz [18099]      JB2 bilevel data
      FG44 [12199]      IW4 data #1, 100 slices, v1.2 (color), 728x1150
      BG44 [251]        IW4 data #1, 97 slices, v1.2 (b&w), 364x575
    FORM:DJVU [30613] {test.1.djvu} [P2]
      INFO [10]         DjVu 4364x6896, v24, 600 dpi, gamma=2.2
      INCL [8]          Indirection chunk --> {test.iff}
      Sjbz [18099]      JB2 bilevel data
      FG44 [12199]      IW4 data #1, 100 slices, v1.2 (color), 728x1150
      BG44 [251]        IW4 data #1, 97 slices, v1.2 (b&w), 364x575

while using --lossy in the same statement ./didjvu bundle test.tif test.tif -o jaarverslagraar10j.djvu --fg-slices 100 -d 600 --bg-slices 0 --lossy --pages-per-dict 2

Does create a relevant djbz, but the pages have different remaining JB2 bilevel data, so there must be something wrong:

djvudump jaarverslagraar10j.djvu
  FORM:DJVM [38327] 
    DIRM [54]         Document directory (bundled, 3 files 2 pages)
    FORM:DJVI [8209] {test.iff} [I]
      Djbz [8197]       JB2 shared dictionary
    FORM:DJVU [14995] {test.djvu} [P1]
      INFO [10]         DjVu 4364x6896, v24, 600 dpi, gamma=2.2
      INCL [8]          Indirection chunk --> {test.iff}
      Sjbz [2482]       JB2 bilevel data
      FG44 [12199]      IW4 data #1, 100 slices, v1.2 (color), 728x1150
      BG44 [251]        IW4 data #1, 97 slices, v1.2 (b&w), 364x575
    FORM:DJVU [15031] {test.1.djvu} [P2]
      INFO [10]         DjVu 4364x6896, v24, 600 dpi, gamma=2.2
      INCL [8]          Indirection chunk --> {test.iff}
      Sjbz [2517]       JB2 bilevel data
      FG44 [12199]      IW4 data #1, 100 slices, v1.2 (color), 728x1150
      BG44 [251]        IW4 data #1, 97 slices, v1.2 (b&w), 364x575
jwilk commented 3 years ago

It's a known issue (see #10); I've just never got around to debugging this… In general, -p is poorly tested and probably very buggy. :-/

jwilk commented 3 years ago

I guess passing --aggression 0 to minidjvu breaks stuff? Maybe it's a matter of skipping that option if the losslevel is 0.

jwilk commented 3 years ago

I guess passing --aggression 0 to minidjvu breaks stuff? Maybe it's a matter of skipping that option if the losslevel is 0.

I've just commited that as a33e740c1c143ffb46e58ea647014240297ff295.

Further testing is welcome.

jwilk commented 9 months ago

Should be fixed in 0.9.1.