commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Damjan Jovanovic <damjan....@gmail.com>
Subject Re: [sanselan] Writing EXIF data to JPEG
Date Thu, 08 Mar 2012 05:26:32 GMT
On Wed, Mar 7, 2012 at 10:37 PM, Kasper Føns <kfoens@gmail.com> wrote:
> On 07-03-2012 19:41, Damjan Jovanovic wrote:
>>
>> On Wed, Mar 7, 2012 at 8:07 PM, Kasper Føns<kfoens@gmail.com>  wrote:
>>>
>>> On 07-03-2012 06:37, Damjan Jovanovic wrote:
>>>>
>>>> On Wed, Mar 7, 2012 at 12:46 AM, Kasper Føns<kfoens@gmail.com>  
 wrote:
>>>>>
>>>>> Hi Sanselan.
>>>>>
>>>>> I have a hard time finding out how to use Sanselan.
>>>>>
>>>>> Suppose I have some JPEG picture which I want to add some attributes
>>>>> to.
>>>>> If for example I want to add some user comment or date I try this:
>>>>>
>>>>> TiffOutputSet outputSet = new TiffOutputSet();
>>>>> TiffOutputField dateTaken =
>>>>> TiffOutputField.create(TiffConstants.EXIF_TAG_CREATE_DATE,
>>>>> outputSet.byteOrder, "2003:03:29 17:47:50");
>>>>> TiffOutputField comment =
>>>>> TiffOutputField.create(TiffConstants.EXIF_TAG_IMAGE_DESCRIPTION,
>>>>> outputSet.byteOrder, "This is a test!");
>>>>>
>>>>> However, both of these fails on "unexpected data type".
>>>>> If I am not supposed to give a String, then what I am supposed to
>>>>> supply?
>>>>>
>>>>> I hope you can help with these, probably noobish questions.
>>>>>
>>>>> /Kasper
>>>>
>>>> That TiffOutputField.create() was a horribly broken API that I've
>>>> eliminated in the latest SVN, and replaced with a new, beautiful, type
>>>> safe, code completable, byte order independent
>>>> TiffOutputDirectory.add() API.
>>>>
>>>> I recommend you use the latest SVN, or wait for the 1.0 release in a
>>>> few weeks. If you really must use version 0.97, I think the only way
>>>> to get strings to work is to convert the string to bytes with
>>>> getBytes(), null-terminate those yourself, then pass them to the
>>>> low-level constructor "new TiffOutputField(...)".
>>>>
>>>> Damjan
>>>
>>>
>>> Hi again Damjan.
>>>
>>> Thanks for the response. I have had a look at the new API, and it looks
>>> cleaner.
>>>
>>> I want to run this on Android, and I can see that there is a heavy
>>> dependency on java.awt, which unfortunately is not in Android.
>>> Do you have some hints as what to do?
>>>
>>>
>>> /Kasper
>>
>> No, sorry, Android isn't supported at the moment. There is a fork
>> (http://code.google.com/p/sanselanandroid/) which supposedly lets you
>> do EXIF on Android, but I've never tried it.
>>
>> Damjan
>>
> Hi again again.
>
> So, the android port is using 0.97 unfortunately, so I can't make use of
> your nice API.
> Is it possible that you could show me with an example, how I would write the
> tag "UserComment" using 0.97? Do you have some samples I can look at?
> Also, the website seems to contain a lot of dead links.
>
>
> /Kasper

Sorry about the website, I plan on fixing it with the 1.0 release.

UserComment is one of the uglier cases, as it uses that GPS string
type with a special prefix to distinguish character encodings.

Try using TagInfo.Text's encodeValue() method to convert the String to
byte[], then pass that to
new TiffOutputField(ExifTagConstants.EXIF_TAG_USER_COMMENT,
	            ExifTagConstants.EXIF_TAG_USER_COMMENT.fieldTypes,
bytes.length, bytes);

Good luck
Damjan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message