Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, November 17, 2011 7:05:53 AM(UTC)
xdepalol

Groups: Registered
Posts: 8


Hello,

I am using LT v17.5 and Visual Studio 2010 (C# with framework 4.0).

I can manipulate an image and write IPTC comments to it, but I have problems with the encoding of those comments. I cannot find an example showing how to write IPTC comments in UTF8 (or Unicode).

The following code shows how I write the comments:

++++++++++++++++++++++++++++++
// Loading IPTC values
RasterCollection comments = new RasterCollection();
comments.Add(new RasterCommentMetadata(RasterCommentMetadataType.IptcObjectName, Encoding.ASCII.GetBytes(foto.Code)));
comments.Add(new RasterCommentMetadata(RasterCommentMetadataType.IptcCaption, Encoding.ASCII.GetBytes(foto.Caption)));
codecs.WriteComments(destFileName, 1, comments);
++++++++++++++++++++++++++++++

As most of my comments are not represented in ASCII, the text in the IPTC field is not read properly. How should I write the comments in UTF8 in order that a common image viewer can read those comments properly?

This is an example of Caption text: "Museo de las Artesanías"

Thank you for your help.
Xavier.
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Friday, November 18, 2011 12:19:54 PM(UTC)

Danny H  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

If you want specifically UTF8 encoding you using use the Encoding.UTF8 encoder.

Replace Encoding.ASCII.GetBytes( ) above with the Encoding.UTF8.GetBytes( ) call. This should give you what you're looking for.

In my test with ASCII I got this when decoded with UTF8:
Museo de las Artesan?as

With UTF8 encoding and decoding with UTF8 I get the appropriate string.
 
#3 Posted : Wednesday, November 23, 2011 1:21:02 AM(UTC)
xdepalol

Groups: Registered
Posts: 8


Hello Danny,

I already did that. When I use directly UTF8 I get the following in my viewer (IrfanView):
Museo de las Artesanías

I was wondering whether I have to put an escape sequence for a common viewer to interpret the text in UTF8. Does it make any sense?

Thanks for your help,
Xavier.
 
#4 Posted : Wednesday, November 23, 2011 11:12:44 AM(UTC)

Danny H  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

The problem you're seeing is that IrfanView and Windows decode the tags as ASCII. The tag's are proper in UTF8 if you use:

RasterCommentMetadata cm = codecs.ReadComment( fileName, 1 , RasterCommentMetadataType.IptcObjectName );
Console.WriteLine( Encoding.UTF8.GetString( cm.GetData() ) );

You will see the tag is properly saved at UTF8. The problem is the viewer and the nature of ASCII encoding.
 
#5 Posted : Thursday, November 24, 2011 1:43:28 AM(UTC)
xdepalol

Groups: Registered
Posts: 8


Hi Danny,

I understand what you say. However, how a common viewer knows which specific encoding system has been used to codify the IPTC comments for a given image? As there exist a lot of possibilities, there should be a way of telling to a viewer that an image has coded its IPTC comments using an specific enconding: Something like a "IptcCodedCharacterSet".

I have opened a LT generated image using PhotoShopc CS5 and it also has problems with the coding.

What am I missing? Thank you for your help.

Xavier.
 
#6 Posted : Monday, November 28, 2011 9:57:14 AM(UTC)

Danny H  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Common viewers are going to decode them as ASCII as that is the encoding IPTC is built for. Yes it can accept UTF8, but that is not what common viewers are going to read.

http://leadtools.com/help/leadtools/v175/dh/L/Leadtools~Leadtools.RasterCommentMetadataDataType.html

As you can see in the above link we do not register IPTC tags as UTF8. With leadtools you can however build a viewer which can recognize tags written in UTF8, but common viewers will not recognize these tags.
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.110 seconds.