test images for WEBP and AVIF

This commit is contained in:
Jörg Breitbart
2026-08-22 10:52:45 +02:00
parent 90fad0f277
commit a783fc1817
20 changed files with 44 additions and 13 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

+22 -13
View File
@@ -39,7 +39,6 @@ export class IIPHandler implements IOscHandler, IResetHandler {
private _header: IHeaderFields = DEFAULT_HEADER; private _header: IHeaderFields = DEFAULT_HEADER;
private _dec: Base64Decoder; private _dec: Base64Decoder;
private _qoiDec: QoiDecoder; private _qoiDec: QoiDecoder;
private _metrics = UNSUPPORTED_TYPE;
private _isMultipart = false; private _isMultipart = false;
private _abortMulti = false; private _abortMulti = false;
@@ -63,7 +62,6 @@ export class IIPHandler implements IOscHandler, IResetHandler {
public start(): void { public start(): void {
this._aborted = false; this._aborted = false;
this._metrics = UNSUPPORTED_TYPE;
this._hp.reset(); this._hp.reset();
} }
@@ -120,14 +118,14 @@ export class IIPHandler implements IOscHandler, IResetHandler {
if (seqType === SequenceType.REPORTCELLSIZE) { if (seqType === SequenceType.REPORTCELLSIZE) {
// OSC 1337 ; ReportCellSize=[height];[width];[scale] ST // OSC 1337 ; ReportCellSize=[height];[width];[scale] ST
let width = CELL_SIZE_DEFAULT.width; let w = CELL_SIZE_DEFAULT.width;
let height = CELL_SIZE_DEFAULT.height; let h = CELL_SIZE_DEFAULT.height;
if (this._renderer.dimensions) { if (this._renderer.dimensions) {
width = this._renderer.dimensions.css.canvas.width / this._coreTerminal.cols; w = this._renderer.dimensions.css.canvas.width / this._coreTerminal.cols;
height = this._renderer.dimensions.css.canvas.height / this._coreTerminal.rows; h = this._renderer.dimensions.css.canvas.height / this._coreTerminal.rows;
} }
const scale = this._coreTerminal._core._coreBrowserService?.dpr ?? 1; const scale = this._coreTerminal._core._coreBrowserService?.dpr ?? 1;
const report = `\x1b]1337;ReportCellSize=${height.toFixed(3)};${width.toFixed(3)};${scale.toFixed(3)}\x1b\\`; const report = `\x1b]1337;ReportCellSize=${h.toFixed(3)};${w.toFixed(3)};${scale.toFixed(3)}\x1b\\`;
this._coreTerminal.input(report, false); this._coreTerminal.input(report, false);
return true; return true;
} }
@@ -154,17 +152,24 @@ export class IIPHandler implements IOscHandler, IResetHandler {
// early exit condition chain // early exit condition chain
let cond: number | boolean; let cond: number | boolean;
let metrics = UNSUPPORTED_TYPE;
if (cond = success) { if (cond = success) {
if (cond = !this._dec.end()) { if (cond = !this._dec.end()) {
this._metrics = imageType(this._dec.data8); metrics = imageType(this._dec.data8);
if (cond = this._metrics.mime !== 'unsupported') { if (cond = metrics.mime !== 'unsupported') {
w = this._metrics.width; w = metrics.width;
h = this._metrics.height; h = metrics.height;
if (cond = w && h && w * h < this._opts.pixelLimit) { if (cond = w && h && w * h < this._opts.pixelLimit) {
[w, h] = this._resize(w, h).map(Math.floor); [w, h] = this._resize(w, h).map(Math.floor);
cond = w && h && w * h < this._opts.pixelLimit; cond = w && h && w * h < this._opts.pixelLimit;
} else {
console.warn(`IIP: image dimension issue ${metrics.width}x${metrics.height}`);
} }
} else {
console.warn('IIP: unsupported image type');
} }
} else {
console.warn('IIP: error during BASE64 decoding');
} }
} }
if (!cond) { if (!cond) {
@@ -173,7 +178,7 @@ export class IIPHandler implements IOscHandler, IResetHandler {
} }
let blob: Blob | ImageData; let blob: Blob | ImageData;
if (this._metrics.mime === 'image/qoi') { if (metrics.mime === 'image/qoi') {
const data = this._qoiDec.decode(this._dec.data8); const data = this._qoiDec.decode(this._dec.data8);
blob = new ImageData( blob = new ImageData(
new Uint8ClampedArray(data.buffer, data.byteOffset, data.byteLength), new Uint8ClampedArray(data.buffer, data.byteOffset, data.byteLength),
@@ -190,13 +195,17 @@ export class IIPHandler implements IOscHandler, IResetHandler {
return true; return true;
} }
} else { } else {
blob = new Blob([this._dec.data8], { type: this._metrics.mime }); blob = new Blob([this._dec.data8], { type: metrics.mime });
} }
this._dec.release(); this._dec.release();
return createImageBitmap(blob, { resizeWidth: w, resizeHeight: h }) return createImageBitmap(blob, { resizeWidth: w, resizeHeight: h })
.then(bm => { .then(bm => {
this._storage.addImage(bm); this._storage.addImage(bm);
return true; return true;
})
.catch(e => {
console.warn(`IIP: decoding error ${metrics.mime} ${metrics.width}x${metrics.height}`, e);
return true;
}); });
} }
+22
View File
@@ -32,6 +32,28 @@ const TEST_IMAGES: [string, IMetrics][] = [
['agfa-makernotes.jpg', { mime: 'image/jpeg', width: 8, height: 8 }], ['agfa-makernotes.jpg', { mime: 'image/jpeg', width: 8, height: 8 }],
['sony-alpha-6000.jpg', { mime: 'image/jpeg', width: 6000, height: 4000 }], ['sony-alpha-6000.jpg', { mime: 'image/jpeg', width: 6000, height: 4000 }],
['dice.qoi', { mime: 'image/qoi', width: 800, height: 600 }], ['dice.qoi', { mime: 'image/qoi', width: 800, height: 600 }],
// VP8
['1.webp', { mime: 'image/webp', width: 550, height: 368 }],
['2.webp', { mime: 'image/webp', width: 550, height: 404 }],
['3.webp', { mime: 'image/webp', width: 1280, height: 720 }],
['4.webp', { mime: 'image/webp', width: 1024, height: 772 }],
['5.webp', { mime: 'image/webp', width: 1024, height: 752 }],
// VP8X
['1_webp_a.webp', { mime: 'image/webp', width: 400, height: 301 }],
['2_webp_a.webp', { mime: 'image/webp', width: 386, height: 395 }],
['3_webp_a.webp', { mime: 'image/webp', width: 800, height: 600 }],
['4_webp_a.webp', { mime: 'image/webp', width: 421, height: 163 }],
['5_webp_a.webp', { mime: 'image/webp', width: 300, height: 300 }],
// VP8L
['1_webp_ll.webp', { mime: 'image/webp', width: 400, height: 301 }],
['2_webp_ll.webp', { mime: 'image/webp', width: 386, height: 395 }],
['3_webp_ll.webp', { mime: 'image/webp', width: 800, height: 600 }],
['4_webp_ll.webp', { mime: 'image/webp', width: 421, height: 163 }],
['5_webp_ll.webp', { mime: 'image/webp', width: 300, height: 300 }],
// some AVIF test images
['fox.profile2.12bpc.yuv444.odd-width.odd-height.avif', { mime: 'image/avif', width: 1203, height: 799 }],
['hato.profile0.8bpc.yuv420.avif', { mime: 'image/avif', width: 3082, height: 2048 }],
['kimono.crop.avif', { mime: 'image/avif', width: 722, height: 1024 }],
]; ];