Pavi
Pavi

Reputation: 1739

How to get the album artwork from a music file using PHP?

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.

Upvotes: 0

Views: 2886

Answers (2)

Andree Kröger
Andree Kröger

Reputation: 104

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.

Upvotes: 1

A. R. Younce
A. R. Younce

Reputation: 1923

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.

Upvotes: 0

Related Questions