Manipuler les méta-données de vos fichiers avec PHP5 XMP Toolkit
L’extension PHP5 XMP Toolkit , qui vient de sortir permet de manipuler les méta-données des fichiers de type jpeg, tiff, png, tiff, mais aussi les wav, mp3, avi, mpeg4, pdf, ai, eps etc. L’extension inclut la librairie Adobe XMP Toolkit SDK . Le projet est sous licence GPL v3 et est compatible FreeBSD, macOS et debian 32 et 64 bit.
L’extension présente essentiellement deux classes XMPFiles et XMPMeta.
Voici un exemple d’utilisation de cette extension :
OpenFile('Image1.jpg');
$xmpfiles->GetXMP( $xmpmeta );
echo "Photoshop original source : ".$xmpmeta->GetProperty(SXMPMeta::kXMP_NS_Photoshop, "Source" )."\n";
$xmpmeta->SetProperty(SXMPMeta::kXMP_NS_Photoshop, "Source", "XMP PHP Toolkit by Mathias VITALIS", 0);
echo "Photoshop modified source : ".$xmpmeta->GetProperty(SXMPMeta::kXMP_NS_Photoshop, "Source" )."\n";
//sort the data model of the XMP object into a canonical order
$xmpmeta->Sort();
//Serialize and show the full xmp header
$buffer = $xmpmeta->SerializeToBuffer(0,0);
print_r($buffer);
//Can we put the modified XMP to the file ?
if ($xmpfiles->CanPutXMP( $xmpmeta)){
// We put the modified XMP object to the file
echo "\nPutting XMP to the file...\n";
$xmpfiles->PutXMP($xmpmeta);
}
echo "Close the file.\n";
$xmpfiles->CloseFile();
- Repository SVN : https://xmpphptoolkit.svn.sourceforge.net/svnroot/xmpphptoolkit
- Page officielle du projet : http://xmpphptoolkit.sourceforge.net/