| 1 | #!/bin/sh |
| 2 | # Regenerate the decoder fixtures. Needs ImageMagick 7, cjxl, avifenc, heif-enc and exiftool. |
| 3 | # Every image is the same 16×12 picture: red, green, blue and white quadrants (top-left, |
| 4 | # top-right, bottom-left, bottom-right), so tests can check orientation by sampling corners. |
| 5 | set -eu |
| 6 | cd "$(dirname "$0")" |
| 7 | tmp=$(mktemp -d) |
| 8 | trap 'rm -rf "$tmp"' EXIT |
| 9 | |
| 10 | magick -size 8x6 xc:red xc:lime +append "$tmp/top.png" |
| 11 | magick -size 8x6 xc:blue xc:white +append "$tmp/bottom.png" |
| 12 | magick "$tmp/top.png" "$tmp/bottom.png" -append -strip PNG24:"$tmp/base.png" |
| 13 | |
| 14 | cp "$tmp/base.png" quadrants.png |
| 15 | magick "$tmp/base.png" -quality 95 quadrants.jpg |
| 16 | magick "$tmp/base.png" quadrants.bmp |
| 17 | magick "$tmp/base.png" quadrants.tga |
| 18 | magick "$tmp/base.png" quadrants.qoi |
| 19 | magick "$tmp/base.png" quadrants.ppm |
| 20 | magick "$tmp/base.png" -define webp:lossless=true quadrants.webp |
| 21 | cjxl -q 100 "$tmp/base.png" quadrants.jxl >/dev/null 2>&1 |
| 22 | avifenc -q 100 -y 444 "$tmp/base.png" quadrants.avif >/dev/null |
| 23 | heif-enc -q 100 -p chroma=444 "$tmp/base.png" -o quadrants.heic >/dev/null |
| 24 | # Float data: linear light, values within 0..1, so it is only sRGB-encoded. |
| 25 | magick "$tmp/base.png" -colorspace RGB -define quantum:format=floating-point quadrants.exr |
| 26 | |
| 27 | # EXIF orientations 1–8: pixels stored so that applying the tag gives the base picture. |
| 28 | i=1 |
| 29 | for op in "" "-flop" "-rotate 180" "-flip" "-transpose" "-rotate -90" "-transverse" "-rotate 90"; do |
| 30 | # shellcheck disable=SC2086 |
| 31 | magick "$tmp/base.png" $op -quality 95 "orient-$i.jpg" |
| 32 | exiftool -q -overwrite_original -n -Orientation=$i "orient-$i.jpg" |
| 33 | i=$((i + 1)) |
| 34 | done |
| 35 | |
| 36 | # Animations: three frames, red, lime, blue, 50/100/150 ms (APNG goes through ffmpeg, which |
| 37 | # keeps only the first delay). |
| 38 | magick -size 16x12 -delay 5 xc:red -delay 10 xc:lime -delay 15 xc:blue -loop 0 anim.gif |
| 39 | magick -size 16x12 -delay 5 xc:red -delay 10 xc:lime -delay 15 xc:blue -loop 0 \ |
| 40 | -define webp:lossless=true anim.webp |
| 41 | magick -size 16x12 -delay 5 xc:red -delay 10 xc:lime -delay 15 xc:blue -loop 0 APNG:anim.png |
| 42 | cjxl anim.gif anim.jxl >/dev/null 2>&1 |
| 43 | |
| 44 | # Three pages. |
| 45 | magick -size 16x12 xc:red xc:lime xc:blue pages.tif |
| 46 | |
| 47 | cat > drawing.svg <<'EOF' |
| 48 | <svg xmlns="http://www.w3.org/2000/svg" width="16" height="12"> |
| 49 | <rect width="8" height="6" fill="red"/> |
| 50 | <rect x="8" width="8" height="6" fill="lime"/> |
| 51 | <rect y="6" width="8" height="6" fill="blue"/> |
| 52 | <rect x="8" y="6" width="8" height="6" fill="white"/> |
| 53 | </svg> |
| 54 | EOF |
| 55 | gzip -9 -n -c drawing.svg > drawing.svgz |