hi,
When a user uploads a MP3,
I am trying to extract a image and its information like. artist, album
by artist, etc
I want to show the image of the song …similar like image shown when a
song is played in itunes .
Is it possible ?
how can i do it ?
Thanks in advance
Rajesh Rathod
Hi,
Of course it’s possible. Even if there were no libraries, you could
still extract the bits “by hand”.
But you don’t have to. Simply install one of the ID3 libraries like
taglib-ruby:
http://robinst.github.com/taglib-ruby/
You can then extract the cover picture:
require ‘taglib’
cover = TagLib::MPEG::File.open(“C:/music/test.mp3”) do |mp3|
mp3.id3v2_tag.frame_list(‘APIC’).first.picture
end
File.open(‘C:/music/cover.jpg’, ‘wb’) {|f| f << cover}