You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Stéphane Pain <st...@hotmail.com> on 2019/10/26 17:09:51 UTC

[imaging] Problem with read/write IPTC fields and charset

Hi,

I try to read and write IPTC fields but I think I « lost » charset.

For example, before read and write IPTC fields, the PROVINCE_STATE field was Rhône-Alpes but after the value is Rh√¥ne-Alpes.

I am on Mac and my program is :

final ByteSource byteSource = new ByteSourceFile(file);
JpegPhotoshopMetadata metadata = new JpegImageParser().getPhotoshopMetadata(byteSource, null);

List<IptcBlock> newBlocks = new ArrayList<IptcBlock>();
List<IptcRecord> newRecords = new ArrayList<IptcRecord>();

if (metadata != null) {
List<IptcRecord> oldRecords = metadata.photoshopApp13Data.getRecords();
for (final IptcRecord record : oldRecords) {
newRecords.add(record);
}

newBlocks.addAll(metadata.photoshopApp13Data.getNonIptcBlocks());
}

PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords, newBlocks);

final File fileTmp = new File(file.getParentFile(), "test.jpg");
os = new FileOutputStream(fileTmp);
os = new BufferedOutputStream(os);
new JpegIptcRewriter().writeIPTC(file, os, newData);

Thank you for your help

Best regards