phoboslab / qoi

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

QOI Thumbnailer for KDE #174

Closed tobozo closed 2 years ago

tobozo commented 2 years ago

Hello and thanks for this awesome library!

Here's a plugin I made for KDE using your library as a submodule, it enables QOI thumbnails in Dolphin:

https://github.com/tobozo/kde-thumbnailer-qoi

image

image

VoxelCubes commented 2 years ago

I love the open source community. Thanks for this!

walksanatora commented 2 years ago

now to wait for how to do this in gnome and nemo file managers

tobozo commented 2 years ago

@walksanatora you're probably looking for this

walksanatora commented 2 years ago

Expect that

  1. I use gnome
  2. I use nemo as my file manager
tobozo commented 2 years ago

I don't expect anything but Nemo is a Nautilus based file manager (as is Caja) and they can use gdk-pixbuf-thumbnailer, which means they can also use a custom pixbuf loader.

Arch Linux has a pre-built package based on this other version.

https://askubuntu.com/questions/1368910/how-to-create-custom-thumbnailers-for-nautilus-nemo-and-caja

have fun!

walksanatora commented 2 years ago

gotta love

  1. living on the bleeding edge
  2. not being on arch
walksanatora commented 2 years ago

hmm meson that is a new build system i haven't seen before

walksanatora commented 2 years ago

I don't expect anything but Nemo is a Nautilus based file manager (as is Caja) and they can use gdk-pixbuf-thumbnailer, which means they can also use a custom pixbuf loader.

Arch Linux has a pre-built package based on this other version.

https://askubuntu.com/questions/1368910/how-to-create-custom-thumbnailers-for-nautilus-nemo-and-caja

have fun!

wait . . . the latest commit states "Remove thumbnailer"

walksanatora commented 2 years ago

okay . . . where do i put qoi.h (and all the other possibly needed files)

okay downloaded it and built and then ran meson install but now when i check gdk-pixbuf-query-loaders there is no file MIME containg qoi

yeah i just checked /usr/share/mime/packages and the qoi.xml is there but nemo still wont detect it it is still showing as application/octlet-stream instead of image/x-qoi

okay after running update-mime-database it now shows as image/x-qoi but there is still no thumbnails

I just quickly build qoiview just to make sure that it was properly formed and it works image the shotgun.png and the corresponding .qoi file image in the file explorer (thumbnails)

I just quickly tried added image/x-qoi to /usr/share/thumbnailers/gdk-pixbuf-thumbnailer.thumbnailer and updating the thumbnailers database and nothing

after running nemo with the --debug flag i see this (after rm -rfv'ing ~/.local/cache/thumbnails/*)

** (gdk-pixbuf-thumbnailer:38848): WARNING **: 10:52:55.213: Could not thumbnail 'file:///home/walksanator/Downloads/image/shotgun_PNG31.qoi': Couldn?t recognize the image file format for file ?/home/walksanator/Downloads/image/shotgun_PNG31.qoi?

(nemo:38837): CinnamonDesktop-WARNING **: 10:52:55.215: Unable to create loader for mime type image/x-qoi: Unrecognized image file format

(nemo:38837): CinnamonDesktop-WARNING **: 10:52:55.216: Error creating thumbnail for file:///home/walksanator/Downloads/image/shotgun_PNG31.qoi: Unrecognized image file format

any ideas what to do now?

another thing I have just tried. sudo gdk-pixbuf-query-loaders --update-cache libpixbufloader-qoi-0.1.so and it appears to work but when i run gdk-pixpub-query-loaders the image/x-qoi file is not in there but it is in the file at /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders.cache

okay . . . now i am just plain mad for some reason it is building x86_64 when my gdk-pixbuf is i386 . . . gonna need alot of help with this one

walksanatora commented 2 years ago

@tobozo kida need alot of help now. i have dug myself a bit too deep to back out now. but that said i am also stuck as i dont know where to go from here see my agony above tl;dr my gnome-pixbuf is x32 on a x64 system and i cant use x64 .so files in a x32 program. but pixbufloader-qoi is building x64

walksanatora commented 2 years ago

wait a minute why dont i just use qoiconv to convert the qoi image to png. then use ffmpeg or something to downscale the image

LETS GOOOOOOOO thumbnailer script (placed at /usr/local/bin/qoi-thumbnail)

#!/usr/bin/env bash
#name our variables so we can understand them
image_size="$1"
input_image="$2"
output_thumbnail="$3"
tmp="$(mktemp).png"

qoiconv "$input_image" "$tmp"
convert "$tmp" -resize "$image_size"x"$image_size" "$tmp"
mv "$tmp" "$output_thumbnail"

thumbnailer entry placed at /usr/share/qoi.thumbnailer

[Thumbnailer Entry]
TryExec=/usr/local/bin/qoi-thumbnail
Exec=/usr/local/bin/qoi-thumbnail %s %i %o
MimeType=image/x-qoi;

mime file (directly stolen from here) and placed at /usr/local/share/mime/packages/

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="image/x-qoi">
    <comment>Quite OK Image Format</comment>
    <glob pattern="*.qoi"/>
  </mime-type>
</mime-info>
walksanatora commented 2 years ago

screenshots image image

walksanatora commented 2 years ago

created a github repo https://github.com/walksanatora/qoi-thumbnailer-nemo

walksanatora commented 2 years ago

i just implemented modifying of /etc/magic so now qoi files can be picked up using file and now it returns image/x-qoi upon using file --mime-type