Feature request: Export cover data in base64 encoding



First, a short introduction :slight_smile:

One of the things I never liked about HTML files (and so - export into them), is that they need additional files in order to look good, e.g. displaying images requires having them somewhere on disk separately, and as soon as something is moved or renamed, the exported file must be updated.

Maybe I'm alone here, but I always wanted to have ONE file that contains all the information that was available at the moment it was created, so that I can copy/move/rename it or any directory where it is without even thinking about it. (Of course, there is nothing I can do with the links to music files if I export them, but I can live with that.)
I thought that the only way to acheive this is to put all scripts and style into the file and do not use any pictures, and thats the way I did all my exports until now, I only couldn't embed the covers.
But I was wrong :slight_smile:

As I recently found out, HTML supports so called data URLs, it means, that any image can be inlined into the HTML as text using the format

<img src="/uploads/default/original/1X/3a79e8b0b7d169b30216785521d7c6f4f895c421.gif" width="20" height="20" alt=":rolleyes:" title=":rolleyes:"/> 

This placeholder should output the base64 encoded data (with whitespace or not - doesn't matter) of the embedded cover, and (ideally) if not, take the cover file from disk (folder.jpg or whatever is specified) if it exists. Maybe there could be even several placeholders for front/back cover and the file on disk.

Alternatively, it could be implemented as a scripting function <b>$base64(placeholders)</b> that would output the base64 encoded data available through the placeholders inside, e.g. encode the cover data if a cover placeholder if used as an argument and interpret them as a file name to read else.
Something like:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$base64(%_cover_front%)
$base64(%album% - %year%.jpg)or like that    $base64(%_cover%)
$base64_file(%album% - %year%.jpg)or like this    $base64(%_cover%)
$base64_file($file(cover_front.jpg)) <img src="/uploads/default/original/1X/3a79e8b0b7d169b30216785521d7c6f4f895c421.gif" width="20" height="20" alt=":rolleyes:" title=":rolleyes:"/> 

Of course, there are some limitations of the data URLs but it is sufficient to create export configurations creating completely self-contained HTML files with embedded covers.
I also did some tests, and it works fine with all browsers I care about, even with a 1MB big png file, (a test HTML file with a small embedded image is attached).

Hope to see a positive reaction from you, Florian :slight_smile:

nickless :music:

inline_image.html (16.4 KB)


nickless, this is a rather smart proposal!

I was not aware of embedding base64 code into normal .html files, though I know this technique from .mht files.

Interesting fact is that the coded image can carry all the embedded extra image information like EXIF tagging without getting distorted (like your example image).

I support your request!

By the way: my standard Firefox displays the image, my IE7 displays only an image placeholder.
What's the difference?



Great, there are already two of us :slight_smile:

Well, the difference is that IE is cra doesn't support data URLs in versions < 8. As said on the wiki page I linked to, IE8 has also some size restrictions, as well as opera. I couldn't test IE browsers since I don't have windows, but ate least FF3, Opera 9.52 and Konqueror 3.5.10 could display an embedded 1280x1024 928K png image, which is all I want.

Attached the HTML preview file of my html_nickless_color_schemes_albumcover.mte with embedded cover :slight_smile:

Results_may_vary.htm (153 KB)


I think (I'm not sure) this function would be useful to embed pictures in .rtf files. I don't know whether rtf use the same method of embedded pictures.