MagickSetImageProperty question

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.
Post Reply
Dabidi

MagickSetImageProperty question

Post by Dabidi »

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?!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickSetImageProperty question

Post by magick »

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

Re: MagickSetImageProperty question

Post by Dabidi »

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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickSetImageProperty question

Post by magick »

Try libexif. Is there a PHP wrapper for it?
Dabidi

Re: MagickSetImageProperty question

Post by Dabidi »

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 :P

Sorry of my englisch :D i never learn it in school
Dabidi

Re: MagickSetImageProperty question

Post by Dabidi »

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? :P Greetz from Poland - The drunken country hehe
Dabidi

Re: MagickSetImageProperty question

Post by Dabidi »

Srcipt work but Adobe indesign refused my exif metadata.

Now i try this:
http://www.adobe.com/devnet/xmp/
Post Reply