ubuntuusers.de

Wie werden die Dateinamen für die Thumbnails erzeugt?

Status: Gelöst | Ubuntu-Version: Ubuntu 7.10 (Gutsy Gibbon)
Antworten |

Chocwise

Avatar von Chocwise

Anmeldungsdatum:
23. Mai 2007

Beiträge: 147

Wie werden die Dateinamen für die in ~/.thumbnails angelegten Thumbnails erstellt? 😉
Sieht für mich nach einer MD5 Checksum aus, aber ein Vergleich zwischen Dateiname eines Thumbnails und der durch "md5sum ./datei.avi" ausgegebenen Checksumme, ist negativ. Also der Dateiname und Checksum sind ungleich. :/
6aae73bb2ef942d1993a15d3962afc49 != f11cf69f25f4173b6ca5c712b4194a21
Und ja, ich hab auch den Binärmodus von md5sum ausprobiert.
Die Info wäre interessant für mich, weil ich mir ein Script schreiben möchte, welches mir ermöglicht per Rechtsklickmenü auf eine Datei ihre Checksum, einige Dateiinfo's und ihr Thumbnail in eine MySQL-DB zu schreiben.

Marc_BlackJack_Rintsch Team-Icon

Ehemalige
Avatar von Marc_BlackJack_Rintsch

Anmeldungsdatum:
16. Juni 2006

Beiträge: 4694

Wohnort: Berlin

Hm, normalerweise findet man dazu etwas unter: http://triq.net/~jens/thumbnail-spec/index.html

Da bekomme ich aber leider gerade ein forbidden. ☹

thumbnail spec 0.7 hat geschrieben:

The thumbnail filename is determined by a hashfunction. This proposal utilizes MD5 as hash mechanism in the following way.

1. You need the absolute canonical URI for the original file, as stated in URI RFC 2396. In particular this defines to use three '/' for local 'file:' resources (see example below).

2. Calculate the MD5 hash for this URI. Not for the file it points to! This results in a 128bit hash, which is representable by a hexadecimal number in a 32 character long string.
3. To get the final filename for the thumbnail just append a '.png' to the hash string. According to the dimension of the thumbnail you must store the result either in ~/.thumbnails/normal or ~/.thumbnails/large.

An example will illustrate this:
Example 1. Saving a thumbnail

Consider we have a file ~/photos/me.png. We want to create a thumbnail with a size of 128x128 pixel for it, which means it will be stored in the ~/.thumbnails/normal directory. The absolute canonical URI for the file in this example is file:///home/jens/photos/me.png.

The MD5 hash for the uri as a hex string is c6ee772d9e49320e97ec29a7eb5b1697. Following the steps above this results in the following final thumbnail path:

/home/jens/.thumbnails/normal/c6ee772d9e49320e97ec29a7eb5b1697.png

Ist auch sinnvoll nicht den Dateiinhalt zu nehmen, sonst müsste man ja ständig die md5-Prüfsumme von den Dateien bilden um die passenden Vorschaubildchen herauszusuchen. Und das vielleicht auch für Dateien, die gar nicht auf dem lokalen Rechner liegen und deshalb jedesmal über's Netz geholt werden müssten.

Chocwise

(Themenstarter)
Avatar von Chocwise

Anmeldungsdatum:
23. Mai 2007

Beiträge: 147

Hey. Super Sache. Ich hab ehrlichgesagt nicht wirklich damit gerechnet, dass mir zu der Frage jemand helfen könnte. Aber ich hab offensichtlich nicht mit dir gerechnet, Marc. 😉
Ich danke dir sehr herzlich. Dann mach ich mich mal ans Basteln. 😀

Antworten |