phoboslab / qoi

The “Quite OK Image Format” for fast, lossless image compression
MIT License
6.83k stars 328 forks source link

qoiz mime type #300

Open tansy opened 2 months ago

tansy commented 2 months ago

qoiz mime type

Me think that, alongside image/qoi mime type you should register image/qoiz type, defined as gzippped qoi format. This adds simple, portable, available to every web server, fast and effective, entropy compression to format. It (qoi+gz) often beats png, even with photographic images, still being many times faster than png, both with compressing and decompression.

There are quite a few tests done on this, even recently here, also I tried to implement it in qoibench, to show it in more palatable way, but get zlib error when otimize a code (-O3). Like with IMGP5493_seamless_2.png for example. If interested it's here.

BenBE commented 2 months ago

As gzip is not the only possible format for compression (bzip2, gzip, zstd, … come to mind), wouldn't it be simpler to just use image/qoi+gzip, image/qoi+bzip2, and image/qoi+zstd, etc.?

rayrobdod commented 2 months ago

When providing a compressed file to a web browser, conventionally you don't define a new mime type for "the same thing but with compression", you'd provide a Content-Encoding header describing the compression. So, in this case, you wouldn't have a Content-Type: image/qoiz, instead you'd still use Content-Type: image/qoi but also have a Content-Encoding: gzip header.

tansy commented 2 months ago

As gzip is not the only possible format for compression (bzip2, gzip, zstd, … come to mind), wouldn't it be simpler to just use image/qoi+gzip, image/qoi+bzip2, and image/qoi+zstd, etc.?

How do you want to distinguish between image/qoi, named `pic.qoi' and image/qoi+gz named `pic.qoi'? SVG specifies `.svgz' but, because of many years of neglect it's mostly ignored. And I'm not saying to create whole bunch of new extensions qoixyz for qoi.xyz compressed files, but one, that makes sense and can be commonly used and regognised.

rayrobdod commented 2 months ago

You distinguish the plain file from the compressed file by naming the compressed file pic.qoi.gz. .svgz is ignored because you can just as easily name the file .svg.gz. .tgz is ignored because you can just as easily name the file .tar.gz. Just like those, a hypothetical .qoiz would be ignored because you can just as easily name the file .qoi.gz.

tansy commented 2 months ago

.svgz is ignored

It's not. Not by Firefox, nor Opera, nor Konqueror.

You distinguish the plain file from the compressed file by naming the compressed file pic.qoi.gz.

I had to check it, but with browsers mentioned above, it was true.

So, at least, when it comes to content encoding and not chrome browsers, it's true.

zzo38 commented 1 month ago

I think that it is a problem with MIME. The plus codes can be used (and I think that this is the best solution, if you are still using MIME types), but it is just a "added on" feature to MIME, and doesn't quite work in the ideal way for this purpose, but it is probably nevertheless, the thing to do in this case; you should use image/qoi+gzip.

File name suffixes such as .qoi.gz or whatever, are not MIME types, so that is a separate issue. Yes, that should be the suffix, and it would be easier for users to understand than .qoiz, but MIME types are a different identification than file names.

(I think ULFI (Unordered Labels File Identification) is better, which is why I made Scorpion protocol/file-format uses ULFI. So, you can use e.g. image:gzip<qoi> or gzip<image:qoi> for this case.)

(UTI (Uniform Type Identifier) is even worse, since parameters and add-ons are not possible; it can only specify class inheritance.)