[File] [PATCH] of Magdir/images for Quite OK Image Format *.qoi

Horia Mihai David mihaidavid at posteo.net
Sun Jan 16 21:26:13 UTC 2022


Hi,

QOI (Quite OK Image Format) <https://qoiformat.org/> created by Dominic 
Szablewski is a losless image compression format similar to PNG, with a 
much simpler implementation, very fast decoding and comparable 
compression rates. It is finding its popularity among game developers.

Please find attached (qoi.patch) a patch to add detection support for 
qoi images in libmagic/file.

NOTE: The patch targets the tip of master on the github mirror (commit 
f8558a245ab82b58d64c1fbe8f6f310fd8b36259).

I CC the author of the QOI format. I added a comment with my name and 
contact method as required, if the original author steps in he can 
replace me.

According to the official spec 
(<https://qoiformat.org/qoi-specification.pdf>):

A QOI file consists of a 14-byte header, followed by any number of
data “chunks” and an 8-byte end marker.
qoi_header {
char magic[4]; // magic bytes "qoif"
uint32_t width; // image width in pixels (BE)
uint32_t height; // image height in pixels (BE)
uint8_t channels; // 3 = RGB, 4 = RGBA
uint8_t colorspace; // 0 = sRGB with linear alpha
// 1 = all channels linear
};


The provided patch detects qoi files and extracts height/width as well 
as channel and colorspace information. If unsupported channel or 
colorspace information is in the header, it is outputted as a bad 
header. I added MIME and file extension descriptions too.

qoi_test/0a.qoi:                     QOI image data, 800 x 600, sRGBA 
(linear alpha)
qoi_test/0b.qoi:                     QOI image data, 800 x 600, RGBA 
(all channels linear)
qoi_test/0c.qoi:                     QOI image data, 800 x 600, RGB (all 
channels linear)
qoi_test/0d.qoi:                     QOI image data, 800 x 600, sRGB 
(linear alpha)
qoi_test/bad_channels.qoi:           QOI image data, 800 x 600, bad header
qoi_test/bad_chansandcolorspace.qoi: QOI image data, 800 x 600, bad header
qoi_test/bad_colorspace.qoi:         QOI image data, 800 x 600, bad header

user at pc:~/file/file/src$ MAGIC=../magic/Magdir/ ./file --mime qoi_test/*.qoi
qoi_test/0a.qoi:                     image/x-qoi; charset=binary
qoi_test/0b.qoi:                     image/x-qoi; charset=binary
qoi_test/0c.qoi:                     image/x-qoi; charset=binary
qoi_test/0d.qoi:                     image/x-qoi; charset=binary
qoi_test/bad_channels.qoi:           image/x-qoi; charset=binary
qoi_test/bad_chansandcolorspace.qoi: image/x-qoi; charset=binary
qoi_test/bad_colorspace.qoi:         image/x-qoi; charset=binary
user at pc:~/file/file/src$ MAGIC=../magic/Magdir/ ./file --extension 
qoi_test/*.qoi
qoi_test/0a.qoi:                     qoi
qoi_test/0b.qoi:                     qoi
qoi_test/0c.qoi:                     qoi
qoi_test/0d.qoi:                     qoi
qoi_test/bad_channels.qoi:           qoi
qoi_test/bad_chansandcolorspace.qoi: qoi
qoi_test/bad_colorspace.qoi:         qoi


I attach the aforementioned test files, each as its own attachment to 
this email. The files contain *only* the 14 byte headers, with the rest 
of the data stripped out to reduce file size.


Best Regards,

- Horia Mihai David <mihaidavid at posteo.net>



-------------- next part --------------
A non-text attachment was scrubbed...
Name: qoi.patch
Type: text/x-patch
Size: 1449 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220116/44ff90ec/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0a.qoi
Type: application/octet-stream
Size: 14 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220116/44ff90ec/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0b.qoi
Type: application/octet-stream
Size: 14 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220116/44ff90ec/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0c.qoi
Type: application/octet-stream
Size: 14 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220116/44ff90ec/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0d.qoi
Type: application/octet-stream
Size: 14 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220116/44ff90ec/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bad_channels.qoi
Type: application/octet-stream
Size: 14 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220116/44ff90ec/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bad_chansandcolorspace.qoi
Type: application/octet-stream
Size: 14 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220116/44ff90ec/attachment-0005.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bad_colorspace.qoi
Type: application/octet-stream
Size: 14 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220116/44ff90ec/attachment-0006.obj>


More information about the File mailing list