mpatric / mp3agic

A java library for reading mp3 files and reading / manipulating the ID3 tags (ID3v1 and ID3v2.2 through ID3v2.4).
MIT License
1.2k stars 310 forks source link

OSX / Itunes compatibility of images? #80

Open MartinHH opened 9 years ago

MartinHH commented 9 years ago

This might rather be an issue of Apple not complying to standards than an issue of mp3agic, but maybe someone can help here.

I do the following steps:

  1. create an mp3 with 1 second of silence in Audacity
  2. create a white 600x600 pixels jpg in GIMP (like this one: white_600x600.jpg)
  3. open the mp3 in Itunes and add that image as album art
  4. run this code:
Mp3File sourceFile = new Mp3File("/path/to/file/1second_of_silence.mp3");

byte[] imageData = sourceFile.getId3v2Tag().getAlbumImage();
String mimeType = sourceFile.getId3v2Tag().getAlbumImageMimeType();

ID3v2 testTarget = new ID3v24Tag();
testTarget.setAlbumImage(imageData, mimeType);

sourceFile.setId3v2Tag(testTarget);
sourceFile.save("/path/to/file/1second_of_silence_copy.mp3");

After doing that, the white image will not show up as album art for the new (_copy) file within Itunes or OSX finder, however it will show in other media player software. Any ideas what I could do to make it work in Itunes?

tokazio commented 9 years ago

I think your problem is in the save part. I've assigned image to mp3 with itunes (osx) and i can show it in itunes or load it with mp3agic. Then sourceFile/imageData/mimetype should be correct. Have you seen the retag example ?

MartinHH commented 9 years ago

Hadn't seen the retag example before, thanks. After a bit of experimenting, I found out that I don't get the problem when I call testTarget.setPadding(true) for the new file's tag.

That doesn't really explain why my example does not work (testFile.getId3v2Tag().getPadding() returns false for the original file) - but it's good enough for me...