test/data: add thumbhash (*.th) files

This commit is contained in:
Nigel Tao committed 2024-09-03 10:02:30 +10:00
1 parent 1723532443
commit aa28bb076c
13 files changed
+100

No files matched your search

+1
View File
@@ -167,6 +167,7 @@ wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix_data,
{+0x514F4920, "\x03\x71\x6F\x69\x66"}, // QOI
{+0x5A4C4942, "\x01\x78\x9C"}, // ZLIB
{+0x504E4720, "\x03\x89\x50\x4E\x47"}, // PNG
{+0x54482020, "\x02\xC3\xBE\xFE"}, // TH
{+0x585A2020, "\x04\xFD\x37\x7A\x58\x5A"}, // XZ
{+0x4A504547, "\x01\xFF\xD8"}, // JPEG
};
+1
View File
@@ -78,6 +78,7 @@ var FourCCs = [...][2]string{
{"TAR ", "Tape Archive"},
{"TEXT", "Text"},
{"TGA ", "Truevision Advanced Raster Graphics Adapter"},
{"TH ", "Thumbhash"},
{"TIFF", "Tagged Image File Format"},
{"TOML", "Tom's Obvious Minimal Language"},
{"WAVE", "Waveform"},
+4
View File
@@ -916,6 +916,9 @@ typedef struct wuffs_base__transform__output__struct {
// Truevision Advanced Raster Graphics Adapter.
#define WUFFS_BASE__FOURCC__TGA 0x54474120
// Thumbhash.
#define WUFFS_BASE__FOURCC__TH 0x54482020
// Tagged Image File Format.
#define WUFFS_BASE__FOURCC__TIFF 0x54494646
@@ -22391,6 +22394,7 @@ wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix_data,
{+0x514F4920, "\x03\x71\x6F\x69\x66"}, // QOI
{+0x5A4C4942, "\x01\x78\x9C"}, // ZLIB
{+0x504E4720, "\x03\x89\x50\x4E\x47"}, // PNG
{+0x54482020, "\x02\xC3\xBE\xFE"}, // TH
{+0x585A2020, "\x04\xFD\x37\x7A\x58\x5A"}, // XZ
{+0x4A504547, "\x01\xFF\xD8"}, // JPEG
};
@@ -0,0 +1 @@
テセ�ユg㍼wW⑨㊦裸Xx枢
@@ -0,0 +1 @@
þþØŠƒ'Æxô&‚ØtÍßñ¨i¸7‡ˆwpg
@@ -0,0 +1 @@
ĂľţŮ÷€w�‡‡x‰‡†�`ť•ň
@@ -0,0 +1 @@
þ%xwxxHwxp=
@@ -0,0 +1 @@
þþÜ÷␍5„…yxww¥wH‡f†`Wv
@@ -0,0 +1 @@
þþ„ˆxx�ˆx|x—xy3tD
@@ -0,0 +1 @@
Ăľţ!-†z�wʇ�uxW‡‡‡p�7
@@ -0,0 +1,2 @@
ĂľţV
␍€ęVou‡zwh™‡úxOä
@@ -0,0 +1 @@
þþ`š†= ;°Yl–¨Eiô„ù¨'XvˆpvG
+84
View File
@@ -0,0 +1,84 @@
// Copyright 2024 The Wuffs Authors.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//
// SPDX-License-Identifier: Apache-2.0 OR MIT
//go:build ignore
// +build ignore
package main
// make.go writes the https://evanw.github.io/thumbhash/ examples to individual
// files, prepending a 3-byte magic string so that /usr/bin/file or similar
// programs can identify the data as thumbhash-formatted data.
//
// That 3-byte magic string is "\xC3\xBE\xFE", which is arbitrary and not part
// of the original thumbhash description or implementation. But "\xC3\xBE" is
// the UTF-8 encoding of 'þ' (U+00FE LATIN SMALL LETTER THORN) and "\xFE" is
// invalid UTF-8 but is the ISO-8859-1 encoding of 'þ'. The Old English letter
// 'þ' is pronounced like the "th" that starts "thumbhash".
//
// The filenames are the base64.RawURLEncoding of the data (similar to but
// slightly different from the base64.RawStdEncoding used on that web page)
// plus a ".th" extension.
//
// Usage: go run make.go
import (
"encoding/base64"
"os"
)
func main() {
if err := main1(); err != nil {
os.Stderr.WriteString(err.Error() + "\n")
os.Exit(1)
}
}
func main1() error {
for _, d := range data {
filename := convertBase64StdToBase64URL(d) + ".th"
in, err := base64.RawStdEncoding.DecodeString(d)
if err != nil {
return err
}
out := append([]byte(magic), in...)
if err := os.WriteFile(filename, out, 0666); err != nil {
return err
}
}
return nil
}
func convertBase64StdToBase64URL(s string) string {
b := []byte(s)
for i, c := range b {
if c == '+' {
b[i] = '-'
} else if c == '/' {
b[i] = '_'
}
}
return string(b)
}
const magic = "\xC3\xBE\xFE"
var data = []string{
"1QcSHQRnh493V4dIh4eXh1h4kJUI",
"3PcNNYSFeXh/d3eld0iHZoZgVwh2",
"3OcRJYB4d3h/iIeHeEh3eIhw+j3A",
"HBkSHYSIeHiPiHh8eJd4eTN0EEQG",
"VggKDYAW6lZvdYd6d2iZh/p4GE/k",
"2fcZFIB3iId/h3iJh4aIYJ2V8g",
"IQgSLYZ6iHePh4h1eFeHh4dwgwg3",
"YJqGPQw7sFlslqhFafSE+Q6oJ1h2iHB2Rw",
"2IqDBQQnxnj0JoLYdM3f8ahpuDeHiHdwZw",
}