id3 icon indicating copy to clipboard operation
id3 copied to clipboard

How to create a valid image url from ArrayBuffer

Open Zinggi opened this issue 10 years ago • 8 comments

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 avatar Apr 12 '14 14:04 Zinggi

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 avatar Apr 12 '14 16:04 Zinggi

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

Zinggi avatar Apr 16 '14 17:04 Zinggi

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 :)

43081j avatar Apr 17 '14 07:04 43081j

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

beamercola avatar Mar 06 '15 03:03 beamercola

I've the same issue..

sumitridhal avatar Jul 21 '17 13:07 sumitridhal

I'm having the same issue.

CovorSorin avatar Jan 25 '18 20:01 CovorSorin

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

aldorr avatar Sep 11 '19 21:09 aldorr

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

vowave avatar Sep 13 '19 16:09 vowave