Krolyxon
Commit 8b10288

Branches

Tags

Refs →

remagetestsfixturesmake.sh

55 lines · 2.4 KB · Bourne Again Shell (bash)

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.
5set -eu
6cd "$(dirname "$0")"
7tmp=$(mktemp -d)
8trap 'rm -rf "$tmp"' EXIT
9
10magick -size 8x6 xc:red xc:lime +append "$tmp/top.png"
11magick -size 8x6 xc:blue xc:white +append "$tmp/bottom.png"
12magick "$tmp/top.png" "$tmp/bottom.png" -append -strip PNG24:"$tmp/base.png"
13
14cp "$tmp/base.png" quadrants.png
15magick "$tmp/base.png" -quality 95 quadrants.jpg
16magick "$tmp/base.png" quadrants.bmp
17magick "$tmp/base.png" quadrants.tga
18magick "$tmp/base.png" quadrants.qoi
19magick "$tmp/base.png" quadrants.ppm
20magick "$tmp/base.png" -define webp:lossless=true quadrants.webp
21cjxl -q 100 "$tmp/base.png" quadrants.jxl >/dev/null 2>&1
22avifenc -q 100 -y 444 "$tmp/base.png" quadrants.avif >/dev/null
23heif-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.
25magick "$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.
28i=1
29for 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))
34done
35
36# Animations: three frames, red, lime, blue, 50/100/150 ms (APNG goes through ffmpeg, which
37# keeps only the first delay).
38magick -size 16x12 -delay 5 xc:red -delay 10 xc:lime -delay 15 xc:blue -loop 0 anim.gif
39magick -size 16x12 -delay 5 xc:red -delay 10 xc:lime -delay 15 xc:blue -loop 0 \
40 -define webp:lossless=true anim.webp
41magick -size 16x12 -delay 5 xc:red -delay 10 xc:lime -delay 15 xc:blue -loop 0 APNG:anim.png
42cjxl anim.gif anim.jxl >/dev/null 2>&1
43
44# Three pages.
45magick -size 16x12 xc:red xc:lime xc:blue pages.tif
46
47cat > 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>
54EOF
55gzip -9 -n -c drawing.svg > drawing.svgz