Reputation: 179
How change MP3 photo with php ?
I use id3_get
But in demos not found change photo
Upvotes: 1
Views: 3404
Reputation: 41
In my case I use composer.
composer require james-heinrich/getid3
index.php file
<?php
require __DIR__.'/vendor/autoload.php';
$getID3 = new getID3;
$tagwriter = new getid3_writetags;
$tagwriter->filename = './music.mp3';
$tagwriter->tagformats = array('id3v1','id3v2.3');
$tagwriter->overwrite_tags = true;
$tagwriter->remove_other_tags = true;
$tagwriter->tag_encoding = 'UTF-8';
$pictureFile = file_get_contents("logo.png");
$TagData = array(
'title' => array('My Title'),
'artist' => array('My Artist'),
'attached_picture' => array(
array (
'data' => $pictureFile,
'picturetypeid' => 3,
'mime' => 'image/png',
'description' => 'My Picture'
)
)
);
$tagwriter->tag_data = $TagData;
if ($tagwriter->WriteTags()){
return true;
}else{
throw new \Exception(implode(' : ', $tagwriter->errors));
}
?>
Upvotes: 2
Reputation: 118
Some previous SO answers:
How can I extract the album art from an MP3 ID3 tag?
setting album art of a mp3 with php
Get cover art from mp3 files through PHP and display it
Look at the last link, especially.
Upvotes: 3