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
 Problem saving IPTC data to JPG file
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

jrpcguru

USA
273 Posts

Posted - Feb 21 2013 :  13:04:49  Show Profile  Reply
I am using Delphi XE2, Win7 Pro-64, and Photoshop Elements 10. I'm trying to save IPTC data to JPG and/or TIF files and share that data with PSE10.
I use the following code to save several IPTC tags:
ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_Caption, IPTCCaption.Text);
    ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_Title, IPTCTitle.Text);
    ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_City, XPTitle.text);
    ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_State_Province, EXIFImageDescription.text);
    ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_Country, XPSubject.text);
    ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_Keywords, EXIFKeywords.text);


I have used this code before saving the file as well as with the InjectJpegEXIF command and get the same problem. I note that the problem does not exist when I save to a TIF file.

Problem:
1. Create new image file by scanning with ImageEn and type in a number of IPTC values.
2. Save the file and read it in PSE10. All tags saved by ImageEn are visible.
3. Edit the same tags with PSE10 and save the file.
4. Read the file with ImageEn and all tags modified by PSE10 are visible.
5. Edit the tags again with ImageEn.
6. PSE10 does not see the changes made by ImageEn!

The tags being saved by my program are visible in the demo program IPTC Information Demo.

I have used Chris Rolliston's CCR-EXIF to view the raw Exif data in the .JPG files. It shows that ImageEn initially saves the tags to a data block which PSE10 can read. But when it saves its own changes, it saves to both the data block used by ImageEn and a new data block. ImageEn doesn't know about those data blocks so it doesn't update them and PSE10 apparently preferentially reads its own data blocks once they exist, so it no longer sees any changes made by ImageEn. The following are my notes from CCR-EXIF in case it is useful to you:



Error notes while trying to save IPTC data to agree with Photoshop Elements 10.

I use the following code to save the IPTC data via ImageEn 4.3.0 and Delphi XE2.

ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_Caption, IPTCCaption.Text);
ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_Title, IPTCTitle.Text);
ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_City, XPTitle.text);
ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_State_Province, EXIFImageDescription.text);
ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_Country, XPSubject.text);
ImageEnView1.IO.Params.WriteIPTCField(PhotoShop_IPTC_Records, IPTC_PS_Keywords, EXIFKeywords.text);
ImageEnView1.IO.InjectJpegIPTC(ImageFileName);

(I also placed these lines of code in front of ImageEnView1.IO.SaveToFile(ImageFileName);
and without the InjectJpegIPTC line, with the same result.)

The raw EXIF displays below are from Chris Rollins CCR-Exif library for reading EXIF code.

=======================================================================

1. scan image and save the following to Test 3.jpg via ImageEn

--- Adobe Photoshop (APP13) ---
Segment offset $5FAC
Total size of segment 108 bytes
Contains IPTC data Yes
Number of data blocks 1

Data block 1 (IPTC):
Signature 8BIM
Type ID $0404
Name (none)
Data size 78 bytes
2:120 delphi 3
2:5; delphi 6
2:90 delphi 1
2:95 delphi 5
2:101 delphi 4
2:25; delphi 2


=======================================================================

2. I then opened the file with PSE 10 which saw the data as saved and added the PSE tag name to each item:

The results were visible in my Delphi program via ImageEn.



--- Adobe Photoshop (APP13) ---
Segment offset $15CB
Total size of segment 6778 bytes
Contains IPTC data Yes
Number of data blocks 18

Data block 1 (IPTC):
Signature 8BIM
Type ID $0404
Name (none)
Data size 155 bytes
2:0 0
2:120 delphi 3 PSE Description
2:5; delphi 6 PSE Title
2:90 delphi 1 PSE City
2:95 delphi 5 PSE State
2:101 delphi 4 PSE Country
2:25; delphi 2 PSE Keywords
<<======= PSE adds new tags
Photoshop:
ColorMode 3
ICCProfile; sRGB IEC61966-2.1
City delphi 1 PSE City
State delphi 5 PSE State
Country delphi 4 PSE Country

Dublin Core:
format image/jpeg
description [alternative ('alt') array]
x-default delphi 3 PSE Description
title [alternative ('alt') array]
x-default delphi 6 PSE Title
subject [unordered ('bag') array]
<item 1> delphi 2 PSE Keywords

=========================================================================

3. I then added ' via Delphi' to each tag with my Delphi program and ImageEn:

--- Adobe Photoshop (APP13) ---
Segment offset $2A86
Total size of segment 244 bytes
Contains IPTC data Yes
Number of data blocks 1

Data block 1 (IPTC):
Signature 8BIM
Type ID $0404
Name (none)
Data size 214 bytes
2:120 delphi 3 PSE Description via Delphi
2:5; delphi 6 PSE Title via Delphi
2:90 delphi 1 PSE City via Delphi
2:95 delphi 5 PSE State via Delphi
2:101 delphi 4 PSE Country via Delphi
2:25; delphi 2 PSE Keywords via Delphi

<<====== the new PSE tags are not updated by ImageEn
Photoshop:
ColorMode 3
ICCProfile; sRGB IEC61966-2.1
City delphi 1 PSE City
State delphi 5 PSE State
Country delphi 4 PSE Country

Dublin Core:
format image/jpeg
description [alternative ('alt') array]
x-default delphi 3 PSE Description
title [alternative ('alt') array]
x-default delphi 6 PSE Title
subject [unordered ('bag') array]
<item 1> delphi 2 PSE Keywords

========================================================================

4. When opened in PSE, the ' via Delphi' is not visible in PSE. Note that ImageEn only changed the IPTC data block and not the Dublin Core.

I then changed the tags via PSE by adding ' via PSE'
My Delphi program sees the ' via PSE' and the 'via Delphi' has been over written like so:

-- Adobe Photoshop (APP13) ---
Segment offset $1661
Total size of segment 6832 bytes
Contains IPTC data Yes
Number of data blocks 18

Data block 1 (IPTC):
Signature 8BIM
Type ID $0404
Name (none)
Data size 203 bytes
2:0 0
2:120 delphi 3 PSE Description via PSE
2:5; delphi 6 PSE Title via PSE
2:90 delphi 1 PSE City via PSE
2:95 delphi 5 PSE State via PSE
2:101 delphi 4 PSE Country via PSE
2:25; delphi 2 PSE Keywords via PSE

Photoshop:
ColorMode 3
ICCProfile; sRGB IEC61966-2.1
City delphi 1 PSE City via PSE
State delphi 5 PSE State via PSE
Country delphi 4 PSE Country via PSE

Dublin Core:
format image/jpeg
description [alternative ('alt') array]
x-default delphi 3 PSE Description via PSE
title [alternative ('alt') array]
x-default delphi 6 PSE Title via PSE
subject [unordered ('bag') array]
<item 1> delphi 2 PSE Keywords via PSE

======================================================================
Conclusion: ImageEn writes only one IPTC set of tags, but PSE 10 writes two sets of tags and preferentially reads the tags that it introduces, thus making ImageEn incompatible with PSE 10.

J.R.

jrpcguru

USA
273 Posts

Posted - Feb 21 2013 :  15:23:17  Show Profile  Reply
I have stumbled on the solution to this post:

ImageEnView1.IO.Params.ResetInfo; //clear all Exif & IPTC //without this, it failed to be PSE compatible

It would be very helpful if the Help file incorporated this detail more obviously. Thanks.

J.R.
Go to Top of Page

jrpcguru

USA
273 Posts

Posted - Feb 22 2013 :  09:50:41  Show Profile  Reply
I was incorrect in saying that I found the solution. Using ImageEnView1.IO.Params.ResetInfo before saving did prevent the problem but it also destroyed all other EXIF and IPTC data. Also, I was also incorrect that saving .TIF file did not suffer from the problem. I had used Params.ResetInfo before testing saving .TIF files.

I have now tried using ImageEnView1.IO.Params.ResetInfo before loading any .jpg file and before acquiring a scanned image, then saving the file. This prevented the destruction of prior EXIF and IPTC data, but the problem returns.

I tried clearing only specific IPTC tags before saving the file:
ImageEnView1.IO.Params.ClearIPTCField(PhotoShop_IPTC_Records, IPTC_PS_Caption);
The problem still exists.

Bottom line: PSE10 and ImageEn are not compatible for read/write of IPTC data. I hope there is an easy solution.

J.R.
Go to Top of Page

fab

1310 Posts

Posted - Feb 27 2013 :  02:06:47  Show Profile  Reply
"6. PSE10 does not see the changes made by ImageEn!"

Does PSE10 save meta tags into XMP field?
Please look also to ImageEnView1.IO.Params.XMP_Info. It is a string containing metatags as XML.
Go to Top of Page

jrpcguru

USA
273 Posts

Posted - Feb 28 2013 :  13:58:46  Show Profile  Reply
I can confirm that PSE10 is setting the IPTC fields that I'm using into the XMP data.

MemoTempText.text := ImageEnView1.IO.Params.XMP_Info ;

This successfully loads the tags into a memo field. I can change the tags and

ImageEnView1.IO.Params.XMP_Info := MemoTempText.text;

successfully saves the changes to the XMP data, but only if I re-save the entire file with

ImageEnView1.IO.SaveToFile(ImageFileName);

I can find no method of injecting the XMP into a previously existing file without re-writing the entire file instead of only the XMP data. (I don't want to degrade the file.) It seems that either your

ImageEnView1.IO.InjectJpegIPTC(ImageFileName);

needs to inject the XMP or changing the IPTC needs to change the matching XMP data since you are trying to be Photoshop compatible. (I hope Adobe does the same thing with PSE as with big Photoshop??)

If I had a method of injecting the XMP data, I can do the parsing of the XMP data. For now, I will just warn users if the XMP data will cause problems.


J.R.
Go to Top of Page

fab

1310 Posts

Posted - Mar 04 2013 :  14:07:14  Show Profile  Reply
At the moment there isn't a method to inject XMP marker (as for IPTC or EXIF). It could be added in a future release.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: