Image_Iptc
Image_Iptc copied to clipboard
German Umlaute are destroyd in Keywords
First, thanks for that amazing piece of work, it's great. I only have the Problem, that German Umlaute like ö, ä and ü gets destroyed in Keywords. If think it's because the writing process is not in utf8
Can you please tell me how to fix that??? Thanks a lot!
Hello friend,
I'll try to simulate this problem and will return soon with a solution.
Hug!
I've read a bit, and I think it's because of the ASCII-Transformation. Because this doesn't know the Umlaute... After the old IPTC-Standard this is right, but in the new one, called XMP-Standard, Umlaute are ok...
Maybe this helps. Thanks a lot for the fast answer!
I did some tests and could not reproduce this error, call me on gtalk to talk better; bruno.agutoli(at)gmail.com
agutoli(at)agutoli:Image_Iptc$ php readIptc.php Array ( [0] => keyword1 [1] => This is a test with special characters ö, ä, ü )
Do I see right, that you tested the reading process? I have the error when writing iptc data to a file!
I debugged some functions from iptc.php an realised following: Function iptcMakeTag() returns $src -> in that variable all special chars are okay Function binary() returns $iptc -> in this variable the special chars are wrong.
Maybe that helps...
Any thing new here? Do you have an idea?
Take a test, download the project now, run the "writeIptc.php" and then run the "readIptc.php" and see if it worked.
I fear, there is no change...

This problem seems to be in the apache configuration, see how it is configured "AddDefaultCharset UTF-8" in "apache2/conf.d/charset"
do not forget to restart apache
work?
naaahh, unfortunately not. I'm running the script on xammp and till now i haven't found out where to change the default charset.
Hm. OK. I changed a few things and now the readlptc is really working. Unfortunately this ist not solving the problem, because in the file, the special chars were still not correct. And, when i upload such a file to, for example Fotolia.com, then they also show the wrong letters.
Any idea?

Not sure, I know very well Windows 7 or 8 (not sure), but I believe it is the same coding problem, your operating system can handle the type "x" and the image is coded for type "y" it would have to be tested in windows.
One option is to try using utf8_encode or utf8_decode before writing the text in the image.
Good idea, I allready tried that, but without success. Do have an idea, where I have to edit this?
You must use the "array_map" to pass an array to the "set"
public function set($tag, $data)
{
$data = array_map("utf8_encode", $data);
//$data = array_map("utf8_decode", $data);//or decode
$this->_meta["2#$tag"] = array($data);
$this->_hasMeta = true;
return $this;
}
see if this works in Windows
I will try that this evening! Thanks a lot for your very detailed help! This is great!
Maaaaan! That's it! Thanks a lot for your help, again!
Glad to have helped, then show me how I got the code to see if I can improve Iptc.php. Hug!
The last hint was perfect. I'm using the utf8_encode for the array, that all :-)
thanks!
Hi agutoli, First, thanks a lot for this useful class. I'm a french user and also need to write special characters in iptc. Using utf8_decode works fine when i use readiptc.php. But, if i open my modified image in Photoshop (CS5) or in Mac Preview's app, there's still some encoding problems. Have you an idea about this ? Thanks a lot for your answer. JG
Hi jgautier2, thanks for reporting this issue. I'll check the problem and call you back as soon as possible. Thanks again!
Thanks for your answer. A precision : I got some jpg files with accents in iptc tags that appears properly in PS CS5 (I could send you one iff you want). But when I modify their tags with your class, all special characters become wrong... In case of it could be useful, i've heard about "CodedCharacterSet" iptc tag... Maybe a way ?
Hi agutoli,
Did you check the problem ? Please let me know when you expect to do it. Thanks a lot. JG
jgautier2, first I'm sorry for the delay, but I've been a bit busy with work ... :/
You could update your lib and test please?
Thanks for your answer and the update.
But, I’ve got this error :
Parse error: syntax error, unexpected '[' in /home/hansluca/sd/site3/www/dbp/lib/Image_Iptc-master/Iptc.php on line 380
JG
Le 12 juil. 2014 à 18:18, Bruno Agutoli [email protected] a écrit :
jgautier2, first I'm sorry for the delay, but I've been a bit busy with work ... :/
You could update your lib and test please?
— Reply to this email directly or view it on GitHub.
It's the php version, try again please. :)
New error (when getting IPTC infos) : Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Passed variable is not an array or object, using empty array instead' in /home/hansluca/sd/site3/www/dbp/lib/Image_Iptc-master/Iptc.php:397 Stack trace: #0 /home/hansluca/sd/site3/www/dbp/lib/Image_Iptc-master/Iptc.php(397): ArrayIterator->__construct('20121030') #1 /home/hansluca/sd/site3/www/dbp/lib/Image_Iptc-master/Iptc.php(224): Iptc->_charset_encode('20121030') #2 /home/hansluca/sd/site3/www/dbp/lib/func.php(67): Iptc->fetch('055') #3 /home/hansluca/sd/site3/www/dbp/edit_image.php(532): GetIptcArrayOfOneMediaFromTagsTab('../../hidef/HAN...', Array) #4 {main} thrown in /home/hansluca/sd/site3/www/dbp/lib/Image_Iptc-master/Iptc.php on line 397
I did a treatment on encode and decode function, but could you show me how you're calling the class? so I can simulate the error here ...
I use a homemade function that loops through an array (called "$tagstab") containing some IPTC tags names, call "fetch" (or "fetch all") on the image ($pathtomedhidef) for each tag found, and then return an array. I call this function with image path and tags array as parameters. See below :
function GetIptcArrayOfOneMediaFromTagsTab($pathtomedhidef, $tagstab)
{
require_once('lib/Image_Iptc-master/Iptc.php');
$iptc = new Iptc($pathtomedhidef);
$iptctab=array();
foreach ($tagstab as $k => $v)
{
switch($v)
{
case 'KEYWORDS':
$kwtab=$iptc->fetchAll(Iptc::KEYWORDS);
if(is_array($kwtab) && sizeof($kwtab) >0)
{
$iptctab[$v]=implode(', ', $kwtab);
}
else
{
$iptctab[$v]='';
}
break;
case 'CREATED_DATE':
$iptctab[$v]=$iptc->fetch(Iptc::CREATED_DATE);
break;
case 'CREATED_TIME':
$iptctab[$v]=$iptc->fetch(Iptc::CREATED_TIME);
break;
case 'CITY':
$iptctab[$v]=$iptc->fetch(Iptc::CITY);
break;
case 'COUNTRY':
$iptctab[$v]=$iptc->fetch(Iptc::COUNTRY);
break;
case 'HEADLINE':
$iptctab[$v]=$iptc->fetch(Iptc::HEADLINE);
break;
case 'CREDIT':
$iptctab[$v]=$iptc->fetch(Iptc::CREDIT);
break;
case 'COPYRIGHT_STRING':
$iptctab[$v]=$iptc->fetch(Iptc::COPYRIGHT_STRING);
break;
case 'CAPTION':
$iptctab[$v]=$iptc->fetch(Iptc::CAPTION);
break;
}
if(empty($iptctab[$v]))
{
unset($iptctab[$v]);
}
}
return $iptctab;
}
// tags array
$tagstab=array('HEADLINE','CAPTION');
// path to img (for ex.)
$pathtomedhidef='../../hidef/HANSLUCA_JGAUTIER_QQQQQ_000010.jpg';
// call function
$iptctab=GetIptcArrayOfOneMediaFromTagsTab($pathtomedhidef, $tagstab);
There was no error before your last update. JG
Hi agutoli,
I've tried again and I didn't get any error : great.
But, I've still some problem with accents when editing modified files in Photoshop (and also Preview or Finder on MacOS). When I use your "writeIptc.php" and then "readIptc.php", it's ok. But when I open "logo_php.jpg" in Photoshop (CS5), accents are not properly shown (neither in Preview or Finder).
This is what appears in PS :

This is what appears in Preview :

Here's "logo_php.jpg" modified file :

Please, let me know if you need more informations to be able to resolve this issue. Thanks a lot,
JG