43081j / id3

A JavaScript ID3 tags parser for Node & browsers.
MIT License
335 stars 63 forks source link

How to create a valid image url from ArrayBuffer #12

Open Zinggi opened 10 years ago

Zinggi commented 10 years ago

Thanks for you wonderful library, I've already tested this and this before, but yours is way faster.

I've got a question about how to use the returned image data. I'm currently doing it that way:

var arrayBufferView = new Uint8Array(tags.v2.image.data);
tags.v2.image.mime = tags.v2.image.mime || 'image/jpeg';
var blob = new Blob([arrayBufferView], {type: tags.v2.image.mime});
var urlCreator = window.URL || window.webkitURL;
var imageUrl = urlCreator.createObjectURL(blob);

This works sometimes, however most of the time it fails. Sometimes it just doesn't create a valid file URL, most of the time it creates only parts of the picture and rarely it works perfectly:

All of these mp3 covers are shown correctly in my windows explorer.
The ones that have a nice placeholder image don't have a tags.v2.image attribute. (which is alright, better have nothing then something wrong...)
The last one somehow created an invalid URL, the others show only a part of the image.
Interestingly the Beatles one doesn't show up in my explorer, but your library parses it correctly.

Am I doing this wrong?

Zinggi commented 10 years ago

That's very interesting. I haven't found a single file that works perfectly and also shows up in my explorer.

Same the other way around: All that work perfectly don't show up in my explorer at all.

This might indicate a windows (probably windows media player) only bug. My guess is that windows media player somehow screws with those tags to make it good for windows explorer, but your parser has problems with those files.

Zinggi commented 10 years ago

I'll be using this library for now, even though it's pretty slow. Thanks nevertheless.

43081j commented 10 years ago

Sorry about this, I am very short of time so didn't get chance to come on here yet. I'll check this and the other issues out tomorrow :)

beamercola commented 9 years ago

Still seeing this issue - is there a chance this will get fixed?

sumitridhal commented 7 years ago

I've the same issue..

CovorSorin commented 6 years ago

I'm having the same issue.

aldorr commented 4 years ago

Hi Zinggi, Was just implementing your library, and thought I was just messing up the ArrayBuffer conversion to base64 or blob. But then stumbled upon this post. Is there any chance of reviving this repository. I'm trying to make some sense of the problem, but haven't come up with anything yet. Thanks

vowave commented 4 years ago

To anyone else having this problem you can use the following gist to convert array buffer data to base64 image.