private void initialize() throws IOException {

        this.signature = readString(6);

        if (!this.signature.equals("GIF87a") && !this.signature.equals("GIF89a")) {
            throw new IOException("Invalid file marker " + this.signature);
        }

        canvasWidth = readUShort(2, false);

        canvasHeight = readUShort(2, false);

        int flag = readUShort(1, false);
        if ((flag & 128) == 0) {
            globalPaletteSize = 0;
        } else {
            globalPaletteSize = 3 * 2 << (flag & 7);
        }

        skip(globalPaletteSize + 2);

        skipBlocks();
    }