Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pictures cannot display in windows file browser. #83

Closed
RogerChen2005 opened this issue Aug 7, 2023 · 4 comments
Closed

Pictures cannot display in windows file browser. #83

RogerChen2005 opened this issue Aug 7, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@RogerChen2005
Copy link

When attaching pictures to .mp3 files, the cover cannot display in windows file browser.

let cover = {
           data: taglib.ByteVector.fromByteArray(data),
           mimeType: 'image/jpeg',
           type: taglib.PictureType.FrontCover,
 }
let dest = taglib.File.createFromPath(save_path);
dest.tag.pictures = [cover];
dest.save();
dest.dispose();

The result I get:
{7E01F5C4-7825-4e3a-BBAC-44DC493A78BE}
However, Foobar2000 can read the picture:
{49347EBB-C0A0-43ae-85B3-6D7940FF73D8}

@benrr101
Copy link
Owner

benrr101 commented Aug 8, 2023

Hmmm... I played around with it for a bit this evening and so far haven't been able to directly reproduce your issue. I do however notice neither windows nor Foobar2000 seem to recognize ID3v2 tags placed at the end of the file with node-taglib-sharp. It's worth noting as well that Foobar2000 seems to cache tags when a file is added to a playlist. I wasn't able to get the scenario you had where Windows doesn't show the picture but Foobar2000 does, but this might be because Foobar2000 needed to reload the tags.

node-taglib-sharp by default creates new ID3v2 tags at the beginning of the file, but if a file already has ID3v2 tag at the end of the file, it will write any changes (via dest.tag) to that tag. As a workaround, you could try removing and re-adding the tag so that it is added at the end of the file.

const file = taglib.File.createFromPath("pathtofile");
const cover = taglib.Picture.fromPath("pathtopicture");

const oldId3v2 = file.getTag(taglib.TagTypes.Id3v2, false);
file.removeTags(0xFFFFFFFF);

const newId3v2 = file.getTag(taglib.TagTypes.Id3v2, true);
oldId3v2.copyTo(newId3v2, true);

// make changes via file.tag

file.save();
file.dispose();

Inspecting the file I tested with, I see the image is being added to the tag and node-taglib-sharp can see it. However, the fact neither foobar2000, vlc, nor windows can see the tag means something is wrong.

@benrr101 benrr101 added the bug Something isn't working label Aug 8, 2023
@RogerChen2005
Copy link
Author

Thanks for your help, I accidentally got two samples today, one cover displays properly and the other doesn't.
2
Compared the content of two files, I notice that the tag type of two samples are different, and 'id3v2.3' can display properly,
1
Thus, I suppose that explorer.exe can't read newer tag type.
Thanks again for your help, have a nice day.

@RogerChen2005
Copy link
Author

taglib.Id3v2Settings.forceDefaultVersion=true;
taglib.Id3v2Settings.defaultVersion=3;

After forcing the version of id3v2, The problem has been solved.
{C12CC650-7036-4023-9A4F-25549B81B8AA}

@benrr101
Copy link
Owner

Hi @RogerChen2005 yes, ID3v2.4 still isn't supported in nearly as many places as ID3v2.3 is. Glad you found a workaround. The investigation for your issue also uncovered a related issue with ID3v2 tags at the end of a file. I'll track that in a separate issue, but thanks for helping bring it to my attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants