"UNICODE ASCII" in TagExifUserComment

Discussions about image processing and document imaging.
Post Reply
goldrian
Posts: 22
Joined: Fri Jun 03, 2011 7:57 pm

"UNICODE ASCII" in TagExifUserComment

Post by goldrian » Thu Aug 09, 2012 8:30 pm

Hello, I'm having a weird problem.
I'm currently writing and reading Exif codes without problems using GdPictureImaging.
However I need to write a number into the TagExifUserComment field (don't ask why, customer request).
The number is written but using any Exif viewer (Opanda, Irfanview...) the value found is "UNICODE ASCII <number>" and the type of the field is "UNDEFINED".
if I do the same in a field like "tagArtist" I don't have this result, it seems to be something related to TagExifUserComment only. Lucky me, that's the field I need.

I'm writing the exif code using a line like:

TagSetValueString(imgID, GdPicture.Tags.TagExifUserComment, TagType.TagTypeASCII, number.ToString());

This strange behaviour causes a problem, since the other applications I'm interfacing with tries to read a string ans parse it as a number.
Any hint? :|
Thank you.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: "UNICODE ASCII" in TagExifUserComment

Post by Loïc » Fri Aug 10, 2012 11:09 am

Hello there,

Well, everything seems right!

The TIFF Tag UserComment should be of the type UNDEFINED and containing 8 first bytes defining the encoding. And GdPicture correctly do that.

From the specs:
IFD Exif
Code 37510 (hex 0x9286)
Name UserComment
Type UNDEFINED
Count N
Default None

The specification defines these possible values for the first 8 bytes of the tag data:

ASCII (hex 41, 53, 43, 49, 49, 00, 00, 00): ITU-T T.50 IA5
JIS (hex 4A, 49, 53, 00, 00, 00, 00, 00): JIS X208-1990
Unicode (hex 55, 4E, 49, 43, 4F, 44, 45, 00): Unicode Standard
Undefined (hex 00, 00, 00, 00, 00, 00, 00, 00): Undefined
If you attach an example of your image I will confirm you if there any ano possible issue or not.

Cheers!

Loïc

goldrian
Posts: 22
Joined: Fri Jun 03, 2011 7:57 pm

Re: "UNICODE ASCII" in TagExifUserComment

Post by goldrian » Fri Aug 10, 2012 1:33 pm

Thanks for the answer.
Perhaps I'm doing something wrong, but if I try to set the tag as TagType.TagTypeUndefined, no value is saved at all.
But if I use a TagType.TagTypeASCII I see, in the resulting hex, this prefix: "UNICODE ASCII".
So, not only UNICODE or ASCII, but both of them.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: "UNICODE ASCII" in TagExifUserComment

Post by Loïc » Fri Aug 10, 2012 2:38 pm

Hello,
But if I use a TagType.TagTypeASCII I see, in the resulting hex, this prefix: "UNICODE ASCII"
Could you explain further how you process to get this result?
Could you also attach an image with such data?

Kind regards,

Loïc

goldrian
Posts: 22
Joined: Fri Jun 03, 2011 7:57 pm

Re: "UNICODE ASCII" in TagExifUserComment

Post by goldrian » Fri Aug 10, 2012 2:49 pm

With this line of code:

Code: Select all

gdi.TagSetValueString(imgId, Tags.TagExifUserComment, TagType.TagTypeASCII, "0");
I get this in Opanda Exif reader:

Image

goldrian
Posts: 22
Joined: Fri Jun 03, 2011 7:57 pm

Re: "UNICODE ASCII" in TagExifUserComment

Post by goldrian » Fri Aug 10, 2012 3:05 pm

I'm trying to use byte[] instead of string.

Code: Select all

System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
byte[] bytes = enc.GetBytes(value);
gdi.TagSetValueBytes(imgId, Tags.TagExifUserComment, TagType.TagTypeASCII, bytes);
The "ASCII" prefix is no more there, but the value is printed twice... Here, as example, with value = "491,678"

Image

I'm lost :|

goldrian
Posts: 22
Joined: Fri Jun 03, 2011 7:57 pm

Re: "UNICODE ASCII" in TagExifUserComment

Post by goldrian » Fri Aug 10, 2012 3:16 pm

I forgot to say that I'm using GdPicture.NET.dll ver.7.4.0.1 with Visual Studio 2010 on Windows 7 64 bit

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: "UNICODE ASCII" in TagExifUserComment

Post by Loïc » Fri Aug 10, 2012 3:57 pm

I can't understand why there is Unicode displayed. I think it can be a bug with Opanda Exif Viewer. I've checked the source code of GdPicture 7 and I don't find any possible problem.

That said, as I asked before I really need a produced image from your side to advice more.

In case you want to use the TagSetValueBytes, you have to provide an array of bytes that meet the specs, meaning with the 8 bytes of header.

Kind regards,

Loïc

goldrian
Posts: 22
Joined: Fri Jun 03, 2011 7:57 pm

Re: "UNICODE ASCII" in TagExifUserComment

Post by goldrian » Fri Aug 10, 2012 4:07 pm

I thought about Opanda too, but Irfanview show the same, and even Windows file properties.
(Note: perhaps only few people are following the specs... that would not be a big news)

However here's one image:
http://www.licantropi.it/TEO_0002.jpg
Thank you.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests