Author |
Topic  |
|
dave.sellers

United Kingdom
17 Posts |
Posted - May 10 2013 : 06:46:10
|
Hi
ImageEn v4.3.0 Delphi v7
Extracting all the EXIF data from a JPEG I find a spurious character in the Copyright field.
I have attached the sample file:

plus a screen shot of the ImageEn EXIF sample program displaying the spurious character and PhotoMe displaying correctly:

Any suggestions welcome
Regards Dave |
|
w2m
   
USA
1990 Posts |
|
fab
   
1310 Posts |
Posted - May 10 2013 : 07:48:31
|
This is the copyright symbol © encoded as UTF-8 sequence (that is 0xc2 and 0xa9). Delphi 7 shows it as ascii, displaying an "Â" (C2) and a "©" (A9), ignoring that is a UTF8 sequence. Standing to exif tags the Copyright tag (33432) should be simple ASCII, not UTF8 or unicode. I don't know why there is UTF8 inside this tag. |
 |
|
w2m
   
USA
1990 Posts |
Posted - May 10 2013 : 08:28:06
|
Delphi 2010 also shows it too!!!
William Miller |
 |
|
fab
   
1310 Posts |
Posted - May 10 2013 : 08:37:39
|
Yes, because ImageEn expects an ascii string, not unicode or utf8. |
 |
|
w2m
   
USA
1990 Posts |
Posted - May 10 2013 : 09:12:41
|
If Unicode characters appear in the EXIF can they be removed before loading the EXIF value?
Afer I got some help at StackOverFlow you can use this function to get the string to appear correctly:
function ReinterpUTF8storedInAnsiString(const ansi: AnsiString): string;
var
utf8: UTF8String;
begin
SetLength(utf8, Length(ansi));
Move(Pointer(ansi)^, Pointer(utf8)^, Length(ansi));
Result := utf8;
end; William Miller Email: w2m@frontiernet.net EBook: http://www.imageen.com/ebook/ Apprehend: http://www.frontiernet.net/~w2m/index.html |
 |
|
dave.sellers

United Kingdom
17 Posts |
Posted - May 11 2013 : 08:58:54
|
Thanks all.
Well I managed to get that to work with a tiny modification. I added that function to the exif demo program and called it for the Copyright value:
Cells[1, 9] := ReinterpUTF8storedInAnsiString(EXIF_Copyright);
But it still showed the spurious accented A (Â) until I modified the function thus:
function TMainForm.ReinterpUTF8storedInAnsiString(const ansi: AnsiString): string; var utf8: UTF8String; begin SetLength(utf8, Length(ansi)); Move(Pointer(ansi)^, Pointer(utf8)^, Length(ansi)); //*****Added call to Utf8ToAnsi****** Result := Utf8ToAnsi(utf8); end;
So I have a workaround but I'm wondering whether this 'fix' should actually take place within the ImageEn code rather than at the application level? Also, could there be any nasty side effects of this workaround if I were to use it to 'cleanse' all EXIF and IPTC values read from files?
Regards Dave |
 |
|
fab
   
1310 Posts |
Posted - May 13 2013 : 03:44:49
|
This is not a clean, this is an actual conversion from UTF8 to pure ascii. Of course there are side effects (UTF8 has more characters than ascii, and ascii is code page dependent). |
 |
|
w2m
   
USA
1990 Posts |
Posted - May 13 2013 : 06:30:59
|
When I tested ReinterpUTF8storedInAnsiString with Delphi 2010 the proper copyright was displayed without adding the call to Utf8ToAnsi.
Are you using Delphi 7?
William Miller |
 |
|
dave.sellers

United Kingdom
17 Posts |
Posted - May 13 2013 : 09:27:04
|
Hi William
Sadly yes, for this project I'm stuck on D7. It's planned to upgrade to XE2 or higher though unlikely to happen for many (many!) months yet.
Regards Dave |
 |
|
|
Topic  |
|