Random Renegade Bits
Whatever comes to mind
Browse: Home / 2010 / May / 31 / Embed Album Art into an MP3 with PHP
  • Old Projects and Content
    • Old Wallpapers
  • Zombinanza!

Embed Album Art into an MP3 with PHP

By epb on May 31, 2010

An odd quest perhaps: but adding album art to an MP3 (in ID3 tags) is readily doable with the KTaglib extension for PHP.  Once you have it, you can use a script like this to add artwork to an MP3:

$mp3 = new KTaglib_MPEG_File('2.mp3');
$idv2 = $mp3->getID3v2Tag(true);
$album = new KTaglib_ID3v2_AttachedPictureFrame();
$album->setType(KTaglib_ID3v2_AttachedPictureFrame::FrontCover);
$album->setPicture('testalbum.jpg');
$album->setMimeType('image/jpeg');
$idv2->addFrame($album);
$mp3->save();

Assuming no exceptions are thrown, this should allow you to set an image of your choosing as a FrontCover image  (of course replacing my example values with your own real values), consult the KTaglib documentation for more details and check “Predefined Constants” for the other image types.

Posted in php | Tagged metadata, mp3, php

« Previous Next »

Search

Archives

  • January 2012
  • October 2011
  • April 2011
  • February 2011
  • November 2010
  • October 2010
  • September 2010
  • July 2010
  • June 2010
  • May 2010
  • March 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • February 2009
  • September 2008
  • August 2008
  • December 2007
  • August 2007

Tags

actionscript android charity CherryPad cloud code computer problems danbooru encryption flash fuse game gd hard drive hopefully_that_made_sense ImageMagick images Internet linux marisa mcrypt metadata mounting mp3 music outside_tutorials perl php pipes problem python rambling rss screenshots search slightly random solved storage svg tablets touhou ubuntu utility vhd web

About

A random blog where I write about my programming projects, Linux, the occasional video game and anything else that comes to mind.

Copyright © 2012 Random Renegade Bits.

Powered by WordPress and Hybrid.