parallax/jsPDF · error · Error
Unknown graphic control label: 0x" + buf[p - 1].toString(16)
Error message
Unknown graphic control label: 0x" + buf[p - 1].toString(16)
What it means
Thrown by GifReader when an extension introducer (0x21) is followed by a label byte that is not one of the handled ones (0xFF application, 0xF9 graphics control, 0xFE comment, or 0x01 plain text). It indicates an unknown or unsupported extension label in the GIF stream; the byte value is included in the message.
Source
Thrown at src/libs/omggif.js:532
if ((pf1 & 1) === 0) transparent_index = null;
disposal = (pf1 >> 2) & 0x7;
p++; // Skip terminator.
break;
case 0xfe: // Comment Extension.
while (true) {
// Seek through subblocks.
var block_size = buf[p++];
// Bad block size (ex: undefined from an out of bounds read).
if (!(block_size >= 0)) throw Error("Invalid block size");
if (block_size === 0) break; // 0 size is terminator
// console.log(buf.slice(p, p+block_size).toString('ascii'));
p += block_size;
}
break;
default:
throw new Error(
"Unknown graphic control label: 0x" + buf[p - 1].toString(16)
);
}
break;
case 0x2c: // Image Descriptor.
var x = buf[p++] | (buf[p++] << 8);
var y = buf[p++] | (buf[p++] << 8);
var w = buf[p++] | (buf[p++] << 8);
var h = buf[p++] | (buf[p++] << 8);
var pf2 = buf[p++];
var local_palette_flag = pf2 >> 7;
var interlace_flag = (pf2 >> 6) & 1;
var num_local_colors_pow2 = pf2 & 0x7;
var num_local_colors = 1 << (num_local_colors_pow2 + 1);
var palette_offset = global_palette_offset;
var palette_size = global_palette_size;
var has_local_palette = false;View on GitHub (pinned to a3930ce03a)
Solutions
- Re-encode the GIF with a mainstream encoder to strip unknown extensions.
- Upgrade omggif in case newer versions handle the label.
- Catch the error and fall back to a sanitized/re-encoded copy.
Example fix
// before
var reader = new GifReader(buffer);
// after
try {
var reader = new GifReader(buffer);
} catch (e) {
if (/Unknown graphic control label/.test(e.message)) {
reader = new GifReader(reencodedBuffer);
} else throw e;
} Defensive patterns
Strategy: try-catch
Try / catch
try { var reader = new GifReader(buffer); } catch (e) { if (/Unknown graphic control label/.test(e.message)) { reader = new GifReader(reencodedBuffer); } else throw e; } Prevention
- Re-encode GIFs with non-standard extensions
- Keep omggif up to date for broader extension support
When it happens
Trigger: Decoding a GIF that uses a non-standard extension label; corruption altering a label byte; an encoder emitting an extension omggif does not handle (e.g. certain plain-text 0x01 variants may still hit default depending on coverage).
Common situations: GIFs produced by niche/proprietary encoders adding custom metadata extensions; bit-flip corruption of the label byte; partial support mismatch across omggif versions.
Related errors
- Invalid graphics extension block.
- Invalid GIF 87a/89a header.
- Width/Height invalid.
- Invalid code/color length, must be power of 2 and 2 .. 256.
- Background index out of range.
AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13).
Data as JSON: /api/errors/6ab0fd615ee121ef.
Report an issue: GitHub.