ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 encoding issue EXIF data?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

dave.sellers

United Kingdom
17 Posts

Posted - May 10 2013 :  06:46:10  Show Profile  Reply
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

Posted - May 10 2013 :  07:23:03  Show Profile  Reply
Thank you for your report. I have reproduced the described behavior.
Perhaps Nigel or Fabrizio will provide further comment.


William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

fab

1310 Posts

Posted - May 10 2013 :  07:48:31  Show Profile  Reply
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.
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 10 2013 :  08:28:06  Show Profile  Reply
Delphi 2010 also shows it too!!!

William Miller
Go to Top of Page

fab

1310 Posts

Posted - May 10 2013 :  08:37:39  Show Profile  Reply
Yes, because ImageEn expects an ascii string, not unicode or utf8.
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 10 2013 :  09:12:41  Show Profile  Reply
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
Go to Top of Page

dave.sellers

United Kingdom
17 Posts

Posted - May 11 2013 :  08:58:54  Show Profile  Reply
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
Go to Top of Page

fab

1310 Posts

Posted - May 13 2013 :  03:44:49  Show Profile  Reply
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).
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 13 2013 :  06:30:59  Show Profile  Reply
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
Go to Top of Page

dave.sellers

United Kingdom
17 Posts

Posted - May 13 2013 :  09:27:04  Show Profile  Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: