0

I can hold a multitude of music files in a folder, on the server. They range among formats : mp3, mp4, wma, ra, mid and ogg. I would like to get the album art embedded (if any) from a newly uploaded and store it in a folder, using pure PHP. Is this possible? If yes how?

NOTE : This is actually a learning scenario, rather than implementation. I know about a few ready-made php scripts to get the meta tags, but want to know it thoroughly.

Anyone kind enough please explain.

BlackPanther
  • 1,732
  • 1
  • 14
  • 19

2 Answers2

1

I think, id3_get_tag is your friend. php.net documentation for id3_get_tag

Read your musicfile with this function, check your returned associative array, which key the value for the album art contains. It should be a bytestream. Save this bytestream in a file like jpg or anythig else, the bytestream could you possibly say, what type of image your cover is.

It's only theory, if you try my answer, please let me know, if it works.

Andree Kröger
  • 84
  • 1
  • 1
  • 5
0

Your question is very general which makes it difficult to answer. Since you claim you're interested in learning then take a look at the ID3 and KTagLib modules for PHP. They are the starting point for querying and manipulating metadata in music files.

There are also several already answered, related questions that may be of help to you.

You can see even more by searching for '[php] id3', and '[php] id3 tags' here on Stack Overflow.

Community
  • 1
  • 1
A. R. Younce
  • 1,913
  • 17
  • 22
  • Can you help me get started? Like, if I have an mp3 file as 'localhost/path/to/song.mp3'. What should I do to get the author's name? (I'm completely new to ID3) – BlackPanther Dec 05 '14 at 20:39
  • We're not here to write the code for you. Give it a shot and then if it doesn't work post a new question including the code from your attempt. – A. R. Younce Dec 05 '14 at 20:40
  • You do realize that there could be other ways to help rather than writing the code, do you? I didn't ask for code. I just needed a starting point. It's like learning Chinese. You say, try yourself, any doubts ask me. And the question comes 'How do you ask for Chinese book in Chinese?' and it goes on. – BlackPanther Dec 05 '14 at 20:50
  • My answer or a Google search about this provides many starting points. I could only assume you wanted a code example since you had already been pointed in the right direction. – A. R. Younce Dec 05 '14 at 20:53