Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[KDE] Which thumbnail belongs to a file?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Cocker68
Apprentice
Apprentice


Joined: 16 Jan 2003
Posts: 227
Location: Germany

PostPosted: Tue Jun 20, 2006 11:17 pm    Post subject: [KDE] Which thumbnail belongs to a file? Reply with quote

[KDE] Which thumbnail belongs to a file?

I checked out this description regarding thumbnails in KDE and wrote a little bash-script, which returns the name of the thumbnail belonging to a given file:

Code:
#!/bin/bash
#@@CCK 20060621-01:07
#
# returns the name of the corresponding thumbnail
#

function abspath() {
    P="$1"
    if [ -z "$P" ]; then
        P="."
    fi
    if [ -f "$P" ]; then
        echo "$(cd $(dirname $P) && pwd)/$(basename $P)"
    elif [ -d "$P" ]; then
        echo "$(cd $P && pwd)/"
    fi
}

function uri() {
    F="$1"
    if [ -n "$F" ]; then
        echo "file://$(abspath $F)"
    fi
}

function md5() {
    S="$1"
    if [ -n "$S" ]; then
        echo -n "$S" | md5sum | awk '{print $1;}'
    fi
}

while [ -n "$1" ]; do
    FILE="$1"
    URI="$(uri $FILE)"
    MD5="$(md5 $URI)"
    THUMB="$HOME/.thumbnails/normal/$MD5.png"
    echo "$THUMB"
    shift
done


Usage:

Give the original files as arguments. Relative and absolute paths are both accepted:

Code:
cocker@tucan:~$ get_thumbnail.sh ./pics/funny.jpeg /home/pub/fotos/sunset.jpeg
/home/cocker/.thumbnails/normal/fb02014394ab251c0242011066fab3b9.png
/home/cocker/.thumbnails/normal/624fe99ebb32feee9f103d234ac19116.png


Annoyance:

The original file has to exist - otherwise the result is nonsense.

- Cocker :wq
Back to top
View user's profile Send private message
killfire
l33t
l33t


Joined: 04 Oct 2003
Posts: 618

PostPosted: Sat Jun 24, 2006 4:16 am    Post subject: Reply with quote

interesting- is this exclusively KDE, or could potentially gnome or something like gthumb also create thumbnails by the same method. I'm not on my linux machine so cannot check it out...
_________________
my website, built in HAppS: http://dbpatterson.com
an art (oil painting) website I built a pure python backend for: http://www.lydiajohnston.com
Back to top
View user's profile Send private message
Cocker68
Apprentice
Apprentice


Joined: 16 Jan 2003
Posts: 227
Location: Germany

PostPosted: Mon Jun 26, 2006 12:12 pm    Post subject: Reply with quote

I think this is KDE-specific, but my Gnome-experience is too low to be certain...

- Cocker :wq
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum