mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-07 20:31:04 +03:00
Tests/LibGfx: Add a jbig2 file using basic symbol and text segments
I created this file using `jbig2` (see below for details), but as far as I can tell `jbig2` does not produce spec-compliant files: 1. It always writes to 0s for the run lengths that specify how many symbols to export at the end of a symbol segment 2. It doesn't write any referred-to segments for text segments. I think it's supposed to write a referred-to segment that mentions the symbol segment the text segment refers to (?) I locally tweaked `jbig2` to fix these two defects (*), so the image added in this commit is correct as best I can tell. It opens fine using `image` and `jbig2`'s decode mode, and via `Meta/jbig2_to_pdf.py` in Firefox and Chrome. Without my tweaks, the image decodes fine with `jbig2`, but not with any of the other three. The image (in a pdf) does _not_ decode in Preview.app, either with or without my local `jbig2` tweaks. *: See the PR adding this image for my local diff. I created the test image file by running this shell script with `jbig2` tweaked as described above: #!/bin/bash set -eu I=Build/lagom/bin/image S=Tests/LibGfx/test-inputs/bmp/bitmap.bmp $I "$S" --crop 232,70,120,250 -o mouth.bmp $I "$S" --crop 135,100,100,100 -o nose.bmp $I "$S" --crop 50,108,30,30 -o top_eye.bmp $I "$S" --crop 60,265,30,30 -o bottom_eye.bmp # I then manually converted those to 1bpp using Photoshop # (Image->Mode->Grayscale, then Image->Mode->Bitmap..., # File->Save As..., bmp) since `jbig2` gets confused by non-1bpp # bmp files and `image` can't write 1bpp files :/ # # (I tried `convert ${in} -monochrome ${in}-1bpp.bmp` via # https://cancerberosgx.github.io/magic/playground/index.html # first, but that produced bmp files that neither Preview.app nor # `jbig2` could handle.) # # -HeightClass: Number of height classes # -WidthClass: Maximum number of symbols in one height class # -Simple means no refinement; the number after is the symbol's ID # The 3 numbers afer `-ID` are id, y, x. The `-ID` are sorted by x. # -RefCorner 1 means "top left". # # `jbig2` writes symbol and text segments as specified in the ini # file, and then only stores the bits of the input image that aren't # already set through symbol and text segments. cat << EOF > jbig2-symbol.ini -sym -Seg 1 -sym -file -numClass -HeightClass 3 -WidthClass 2 -sym -file -numSymbol 4 -sym -file -Height 250 -sym -file -Width 120 -Simple 0 mouth-1bpp.bmp -sym -file -EndOfHeightClass -sym -file -Height 100 -sym -file -Width 100 -Simple 1 nose-1bpp.bmp -sym -file -EndOfHeightClass -sym -file -Height 30 -sym -file -Width 30 -Simple 2 top_eye-1bpp.bmp -sym -file -Width 30 -Simple 3 bottom_eye-1bpp.bmp -sym -file -EndOfHeightClass -sym -Param -Huff_DH 0 -sym -Param -Huff_DW 0 -txt -Seg 2 -txt -Param -numInst 4 -ID 2 108 50 -ID 3 265 60 -ID 1 100 135 -ID 0 70 232 -txt -Param -RefCorner 1 -txt -Param -Xlocation 0 -txt -Param -Ylocation 0 -txt -Param -W 399 -txt -Param -H 400 EOF J=$HOME/Downloads/T-REC-T.88-201808-I\!\!SOFT-ZST-E/Software J=$J/JBIG2_SampleSoftware-A20180829/source/jbig2 $J -i "${S%.bmp}" -f bmp -o symbol -F jb2 -ini jbig2-symbol.ini
This commit is contained in:
parent
bb5ad12e43
commit
3a50cadddf
Notes:
sideshowbarker
2024-07-16 21:42:29 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/3a50cadddf Pull-request: https://github.com/SerenityOS/serenity/pull/23659
BIN
Tests/LibGfx/test-inputs/jbig2/bitmap-symbol.jbig2
Normal file
BIN
Tests/LibGfx/test-inputs/jbig2/bitmap-symbol.jbig2
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user