MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Dabidi
Post
by Dabidi » 2008-01-07T08:08:27-07:00
phpinfo() say this:
ImageMagick version: 6.3.7 01/07/08 Q16
MagickWand Extension Version: 1.0.5
Code: Select all
<?
function read_jpg_desc($img_dir)
{
$mgck_wnd = NewMagickWand();
MagickReadImage($mgck_wnd, $img_dir);
$value=MagickGetImageProperty($mgck_wnd, "ImageDescription");
return $value;
}
function write_jpg_desc($img_dir, $desc)
{
$mgck_wnd = NewMagickWand();
MagickReadImage($mgck_wnd, $img_dir);
$result=MagickSetImageProperty($mgck_wnd, "ImageDescription", $desc);
MagickWriteImage($mgck_wnd, $img_dir);
return $result;
}
echo(read_jpg_desc("test.jpg")); // return null
write_jpg_desc("test.jpg", "Dabidi is cool"); // return true;
echo(read_jpg_desc("test.jpg")); // return null <--- !!!!!!
?>
This code dosent work. Metadada in test.jpg file is not changed. WHY?!
magick
Site Admin
Posts: 11064 Joined: 2003-05-31T11:32:55-07:00
Post
by magick » 2008-01-07T08:38:20-07:00
MagickWand For PHP treats the EXIF profile as a blob other than updating the image resolution field. You will need some other method to set fields in your EXIF profile.
Dabidi
Post
by Dabidi » 2008-01-07T08:49:36-07:00
i try to find some library to edit exif but all of this librares broken'up my jpg files ... imagemagic is my last chance
Thanx
magick
Site Admin
Posts: 11064 Joined: 2003-05-31T11:32:55-07:00
Post
by magick » 2008-01-07T08:56:40-07:00
Try libexif. Is there a PHP wrapper for it?
Dabidi
Post
by Dabidi » 2008-01-07T09:57:12-07:00
tomorrow i try to find and instal libexif.
I need edit exif (using www interface) for Adobe indesign to speedup workflow of DTP. Wehen graphicman turn the foto to the indesign workspace, description automatically put in near foto.
Now i using imagemagick+imagewand to change DPI resolution and it works excelent so i think the edit exif bee workable too.
I not use PHP wrapper ... and i dont known exactly what it is
Sorry of my englisch
i never learn it in school
Dabidi
Post
by Dabidi » 2008-01-08T06:07:04-07:00
once again i try use the PEL
http://pel.sourceforge.net/
This script work correctly
Code: Select all
<?
function write_jpg_desc($input, $description)
{
$output=$input;
require_once('pel/PelJpeg.php');
$data = new PelDataWindow(file_get_contents($input));
$jpeg = $file = new PelJpeg();
$jpeg->load($data);
$exif = $jpeg->getExif();
if(!$exif)
{
$exif = new PelExif();
$jpeg->setExif($exif);
$tiff = new PelTiff();
$exif->setTiff($tiff);
}
else
{
$tiff = $exif->getTiff();
}
$ifd0 = $tiff->getIfd();
if(!$ifd0)
{
$ifd0 = new PelIfd(PelIfd::IFD0);
$tiff->setIfd($ifd0);
}
$desc = $ifd0->getEntry(PelTag::IMAGE_DESCRIPTION);
if(!$desc)
{
$desc = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, $description);
$ifd0->addEntry($desc);
}
else
{
$desc->setValue($description);
}
if(file_put_contents($output, $file->getBytes())) return true;
else return false;
}
function read_jpg_desc($file)
{
$metadata=exif_read_data($file);
if($metadata[ImageDescription])
return $metadata[ImageDescription];
else
return false;
}
echo(read_jpg_desc("test.jpg")); // return null
write_jpg_desc("test.jpg", "Dabidi is cool"); // return true;
echo(read_jpg_desc("test.jpg")); // return Dabidi is cool
?>
Thanx magick for fast reply
P.S. You like beer?
Greetz from Poland - The drunken country hehe