ladybird/Tests/LibGfx/test-inputs
Nico Weber 3a50cadddf 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
2024-03-23 08:18:15 -04:00
..
bmp LibGfx/BMP: Clear alpha in palette entries 2024-03-05 21:27:41 +00:00
dds LibGfx/DDSLoader: Allow image dimensions that are not divisible by 4 2023-10-06 22:18:27 +02:00
icc LibGfx/TIFF: Add support for the ICCProfile tag 2023-12-02 10:36:02 +01:00
ico LibGfx/ICO: Do not try to decode a mask if we already reached EOF 2024-01-07 12:32:02 -05:00
ilbm LibGfx/ILBMLoader: Properly display images with a bitplane mask 2024-01-18 13:59:17 +01:00
jbig2 Tests/LibGfx: Add a jbig2 file using basic symbol and text segments 2024-03-23 08:18:15 -04:00
jpg LibGfx+Tests: Improve calculation of restart interval 2024-01-30 14:50:43 +01:00
jxl LibGfx/JPEGXL: Fix property 8 2023-08-01 05:35:01 +02:00
png Tests: Add a png in Display P3 that shows up as solid color in sRGB 2024-01-12 16:20:46 -07:00
pnm Tests: Add a pam cmyk test file 2024-01-26 07:36:53 +01:00
tga Tests: Move tga test images into tga/ subfolder 2023-06-19 06:42:00 -04:00
tiff LibGfx/TIFF: Add support for Group4Fax encoded images 2024-02-21 13:49:43 +01:00
tvg LibGfx/TinyVG: Fix decoding green channel of graphics RGB565 colors 2024-03-12 21:53:23 +00:00
webp Tests: Add test for webp with color index transform and alpha_used=false 2023-06-20 11:35:03 +02:00
woff LibGfx/WOFF: Ensure header totalSfntSize matches expected value 2023-10-24 07:29:09 +02:00
woff2 LibGfx/WOFF2: Ensure numTables is within expected range 2023-10-26 08:39:26 +02:00
download-animation.gif LibGfx: Move TestImageDecoder over to input file approach in 8cfabbcd93 2023-02-01 08:56:56 -05:00
loop_forever.avif LibGfx: Add initial ISO BMFF parsing and a utility to print file info 2023-07-27 12:02:37 +01:00
TestFont.font LibGfx: Move TestFontHandling over to input file approach in 8cfabbcd93 2023-02-01 08:56:56 -05:00