Discussion:
[imaging] Comment tag problem
(too old to reply)
andrea antonello
2018-04-24 13:56:03 UTC
Permalink
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.

Here is the output of the info given by ImageMagick:



The tag I need should be under "Properties"
and be named: comment

I have tried to use user_comment and xpcomment, but they produce something
different, like:



Can anyone tell me which tag I can use to generate the "comment" tag?

Thanks for any hint,
Best regards,
Andrea
Bruno P. Kinoshita
2018-04-25 12:07:52 UTC
Permalink
Hi Andrea,
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list. Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
CheersBruno


From: andrea antonello <***@gmail.com>
To: Commons Users List <***@commons.apache.org>
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem

Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.

Here is the output of the info given by ImageMagick:



The tag I need should be under "Properties"
and be named: comment

I have tried to use user_comment and xpcomment, but they produce something
different, like:



Can anyone tell me which tag I can use to generate the "comment" tag?

Thanks for any hint,
Best regards,
Andrea
andrea antonello
2018-04-25 13:46:17 UTC
Permalink
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.

The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section

Properties:

and under start section I find

comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000

The most similar result I have been able to produce with the tags is:

exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000

and

exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000

both not the same as what i am looking for.


I have been able to print the following information through an
application called exifprobe:

@0x0000002=2 : <JPEG_COM> length 137:
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694

So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.

Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
Bruno P. Kinoshita
2018-04-26 06:57:43 UTC
Permalink
Hi Andrea,

The EXIF tags in imaging should match what's in this page:
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html

Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.


If you really need to match that tag, then I think you should be able to create your own custom metadata entry.

I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)


Hope that helps,
Bruno


[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java

________________________________
From: andrea antonello <***@gmail.com>
To: Commons Users List <***@commons.apache.org>
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem



Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.

The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section

Properties:

and under start section I find

comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000

The most similar result I have been able to produce with the tags is:

exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000

and

exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000

both not the same as what i am looking for.


I have been able to print the following information through an
application called exifprobe:

@0x0000002=2 : <JPEG_COM> length 137:
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694

So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.

Any help is most appreciated,
Thanks,

Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
andrea antonello
2018-04-26 07:15:25 UTC
Permalink
Hi Bruno,
Post by Bruno P. Kinoshita
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.
this is quite inetersting. Actually I have been told that the command:

exiftool -comment='mycomment'

creates exaclty the comment I am not able to reproduce. Do you know
what that is?
Post by Bruno P. Kinoshita
If you really need to match that tag, then I think you should be able to create your own custom metadata entry.
I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)
I will try again. I tried already that path, but since it asks me for
a tag (integer) I then end up to have it named as the tag I am trying
to substitute...

Thanks,
Andrea
Post by Bruno P. Kinoshita
Hope that helps,
Bruno
[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
________________________________
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.
The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section
and under start section I find
comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
and
exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
both not the same as what i am looking for.
I have been able to print the following information through an
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694
So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.
Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
Bruno P. Kinoshita
2018-04-26 07:26:17 UTC
Permalink
I normally use exiftool to compare what imaging is producing. The htmldump is quite useful. I thought you had to create the tag in Java, but if you can use other tools and it's easier for you, then that might be the best option.


Otherwise you can create pretty much any other metadata tag you'd like with some Java coding.
________________________________
From: andrea antonello <***@gmail.com>
To: Commons Users List <***@commons.apache.org>
Sent: Thursday, 26 April 2018 7:15 PM
Subject: Re: [imaging] Comment tag problem



Hi Bruno,
Post by Bruno P. Kinoshita
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.
this is quite inetersting. Actually I have been told that the command:

exiftool -comment='mycomment'

creates exaclty the comment I am not able to reproduce. Do you know
what that is?
Post by Bruno P. Kinoshita
If you really need to match that tag, then I think you should be able to create your own custom metadata entry.
I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)
I will try again. I tried already that path, but since it asks me for
a tag (integer) I then end up to have it named as the tag I am trying
to substitute...

Thanks,
Andrea
Post by Bruno P. Kinoshita
Hope that helps,
Bruno
[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
________________________________
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.
The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section
and under start section I find
comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
and
exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
both not the same as what i am looking for.
I have been able to print the following information through an
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694
So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.
Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
andrea antonello
2018-04-26 08:02:04 UTC
Permalink
Post by Bruno P. Kinoshita
I normally use exiftool to compare what imaging is producing. The htmldump is quite useful.
I just ran the normal info extraction and here you see the comment I
would like to reproduce (Comment):

ExifTool Version Number : 10.94
File Name : 109_Background.jpg
Directory : .
File Size : 428 kB
File Modification Date/Time : 2018:03:31 11:01:51+02:00
File Access Date/Time : 2018:04:26 08:59:06+02:00
File Inode Change Date/Time : 2018:03:31 11:01:56+02:00
File Permissions : rw-rw-r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
Comment :
GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
JFIF Version : 1.01
Resolution Unit : inches
X Resolution : 96
Y Resolution : 96
Image Width : 1608
Image Height : 901
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 1608x901
Megapixels : 1.4
Post by Bruno P. Kinoshita
I thought you had to create the tag in Java, but if you can use other tools and it's easier for you, then that might be the best option.
Yes, I do have to recreate it in java. I was just trying to use other
tools to check what the comment tag is.
Do you have an idea on how to create the above Comment tag?
Post by Bruno P. Kinoshita
Otherwise you can create pretty much any other metadata tag you'd like with some Java coding.
That is what I would love to end up with.
Thanks a ton,
Andrea
Post by Bruno P. Kinoshita
________________________________
Sent: Thursday, 26 April 2018 7:15 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
Post by Bruno P. Kinoshita
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.
exiftool -comment='mycomment'
creates exaclty the comment I am not able to reproduce. Do you know
what that is?
Post by Bruno P. Kinoshita
If you really need to match that tag, then I think you should be able to create your own custom metadata entry.
I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)
I will try again. I tried already that path, but since it asks me for
a tag (integer) I then end up to have it named as the tag I am trying
to substitute...
Thanks,
Andrea
Post by Bruno P. Kinoshita
Hope that helps,
Bruno
[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
________________________________
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.
The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section
and under start section I find
comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
and
exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
both not the same as what i am looking for.
I have been able to print the following information through an
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694
So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.
Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
Bruno P. Kinoshita
2018-04-27 12:39:55 UTC
Permalink
Hi Andrea!

Today spent some minutes with Eclipse and the code base, plus exiftool, to see where that comment was coming from.

That COM, or Comment, that you see in exiftool output is not exactly a metadata tag. It is actually a JPEG Segment. Sorry for the other suggestions.

As far as I know, we are not able to change the segments, but only the metadata within the TIFF/EXIF directories & tags [2].

You can still use comments if that's OK, but not sure how you would achieve adding the Comment in Java.

Bruno


[1] http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0
[2] https://issues.apache.org/jira/browse/IMAGING-55


________________________________
From: andrea antonello <***@gmail.com>
To: Commons Users List <***@commons.apache.org>
Sent: Thursday, 26 April 2018 8:02 PM
Subject: Re: [imaging] Comment tag problem
Post by Bruno P. Kinoshita
I normally use exiftool to compare what imaging is producing. The htmldump is quite useful.
I just ran the normal info extraction and here you see the comment I
would like to reproduce (Comment):

ExifTool Version Number : 10.94
File Name : 109_Background.jpg
Directory : .
File Size : 428 kB
File Modification Date/Time : 2018:03:31 11:01:51+02:00
File Access Date/Time : 2018:04:26 08:59:06+02:00
File Inode Change Date/Time : 2018:03:31 11:01:56+02:00
File Permissions : rw-rw-r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
Comment :
GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
JFIF Version : 1.01
Resolution Unit : inches
X Resolution : 96
Y Resolution : 96
Image Width : 1608
Image Height : 901
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 1608x901
Megapixels : 1.4
Post by Bruno P. Kinoshita
I thought you had to create the tag in Java, but if you can use other tools and it's easier for you, then that might be the best option.
Yes, I do have to recreate it in java. I was just trying to use other
tools to check what the comment tag is.
Do you have an idea on how to create the above Comment tag?
Post by Bruno P. Kinoshita
Otherwise you can create pretty much any other metadata tag you'd like with some Java coding.
That is what I would love to end up with.
Thanks a ton,
Andrea
Post by Bruno P. Kinoshita
________________________________
Sent: Thursday, 26 April 2018 7:15 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
Post by Bruno P. Kinoshita
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.
exiftool -comment='mycomment'
creates exaclty the comment I am not able to reproduce. Do you know
what that is?
Post by Bruno P. Kinoshita
If you really need to match that tag, then I think you should be able to create your own custom metadata entry.
I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)
I will try again. I tried already that path, but since it asks me for
a tag (integer) I then end up to have it named as the tag I am trying
to substitute...
Thanks,
Andrea
Post by Bruno P. Kinoshita
Hope that helps,
Bruno
[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
________________________________
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.
The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section
and under start section I find
comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
and
exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
both not the same as what i am looking for.
I have been able to print the following information through an
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694
So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.
Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
Martin Gainty
2018-04-27 17:37:56 UTC
Permalink
Bruno

if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool

http://www.exiv2.org/manpage.html

Exiv2 utility manual - Image metadata library and tools<http://www.exiv2.org/manpage.html>
www.exiv2.org
Open Source Exif, IPTC and XMP metadata library and tools with Exif MakerNote and read/write support


MG>see below

________________________________
From: Bruno P. Kinoshita <***@yahoo.com.br.INVALID>
Sent: Friday, April 27, 2018 8:39 AM
To: Commons Users List
Subject: Re: [imaging] Comment tag problem

Hi Andrea!

Today spent some minutes with Eclipse and the code base, plus exiftool, to see where that comment was coming from.

That COM, or Comment, that you see in exiftool output is not exactly a metadata tag. It is actually a JPEG Segment. Sorry for the other suggestions.

As far as I know, we are not able to change the segments, but only the metadata within the TIFF/EXIF directories & tags [2].

You can still use comments if that's OK, but not sure how you would achieve adding the Comment in Java.
MG>testXMPInsert borrowed from JpegXmpRewriteTest.java
{
// test insert
String newXmpXml = "comment";
//subin your fileName to imageFile.getName()
File updated = createTempFile(imageFile.getName() + ".", ".jpg");
OutputStream os = null;
try
{
os = new FileOutputStream(updated);
os = new BufferedOutputStream(os);
new org.apache.sanselan.formats.jpeg..xmp.JpegXmpRewriter().updateXmpXml(
org.apache.sanselan.common.byteSources.ByteSourceFile(noXmpFile), os,
newXmpXml);
} finally
{
os.close();
os = null;
}

// Debug.debug("Source Segments:");
// new JpegUtils().dumpJFIF(new ByteSourceFile(updated));

String outXmp = new org.apache.sanselan.formats.jpeg.JpegImageParser().getXmpXml(
new ByteSourceFile(updated), params);
assertNotNull(outXmp);
assertEquals(outXmp, newXmpXml);
}

MG>please confirm this works for you
MG>required sanselanependency for pom.xml:
<groupId>org.apache.sanselan</groupId>
<artifactId>sanselan</artifactId>
<version>0.97-incubator</version>


Bruno
MG>?
MG>Martin-


[1] http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0
Writing comments<http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0>
u88.n24.queensu.ca
Writing comments



[2] https://issues.apache.org/jira/browse/IMAGING-55


________________________________
From: andrea antonello <***@gmail.com>
To: Commons Users List <***@commons.apache.org>
Sent: Thursday, 26 April 2018 8:02 PM
Subject: Re: [imaging] Comment tag problem
Post by Bruno P. Kinoshita
I normally use exiftool to compare what imaging is producing. The htmldump is quite useful.
I just ran the normal info extraction and here you see the comment I
would like to reproduce (Comment):

ExifTool Version Number : 10.94
File Name : 109_Background.jpg
Directory : .
File Size : 428 kB
File Modification Date/Time : 2018:03:31 11:01:51+02:00
File Access Date/Time : 2018:04:26 08:59:06+02:00
File Inode Change Date/Time : 2018:03:31 11:01:56+02:00
File Permissions : rw-rw-r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
Comment :
GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
JFIF Version : 1.01
Resolution Unit : inches
X Resolution : 96
Y Resolution : 96
Image Width : 1608
Image Height : 901
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 1608x901
Megapixels : 1.4
Post by Bruno P. Kinoshita
I thought you had to create the tag in Java, but if you can use other tools and it's easier for you, then that might be the best option.
Yes, I do have to recreate it in java. I was just trying to use other
tools to check what the comment tag is.
Do you have an idea on how to create the above Comment tag?
Post by Bruno P. Kinoshita
Otherwise you can create pretty much any other metadata tag you'd like with some Java coding.
That is what I would love to end up with.
Thanks a ton,
Andrea
Post by Bruno P. Kinoshita
________________________________
Sent: Thursday, 26 April 2018 7:15 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
Post by Bruno P. Kinoshita
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.
exiftool -comment='mycomment'
creates exaclty the comment I am not able to reproduce. Do you know
what that is?
Post by Bruno P. Kinoshita
If you really need to match that tag, then I think you should be able to create your own custom metadata entry.
I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)
I will try again. I tried already that path, but since it asks me for
a tag (integer) I then end up to have it named as the tag I am trying
to substitute...
Thanks,
Andrea
Post by Bruno P. Kinoshita
Hope that helps,
Bruno
[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
________________________________
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.
The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section
and under start section I find
comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
and
exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
both not the same as what i am looking for.
I have been able to print the following information through an
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694
So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.
Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
Bruno P. Kinoshita
2018-04-28 01:15:28 UTC
Permalink
Hi Martin,
Post by Martin Gainty
if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool
It's actually Andrea who is working with comments & JPEG images. I was just trying to help him, assuming he wants/needs to do that in Java. He pointed that he could do that with exiftool too (see previous e-mails in the thread for more).

@Andrea, see Martin's code in the e-mail below.
Thanks Martin!
Bruno



________________________________
From: Martin Gainty <***@hotmail.com>
To: Commons Users List <***@commons.apache.org>; Bruno P. Kinoshita <***@yahoo.com.br>
Sent: Saturday, 28 April 2018 5:38 AM
Subject: Re: [imaging] Comment tag problem



Bruno

if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool

http://www.exiv2.org/manpage.html

Exiv2 utility manual - Image metadata library and tools<http://www.exiv2.org/manpage.html>
www.exiv2.org
Open Source Exif, IPTC and XMP metadata library and tools with Exif MakerNote and read/write support


MG>see below

________________________________
From: Bruno P. Kinoshita <***@yahoo.com.br.INVALID>
Sent: Friday, April 27, 2018 8:39 AM
To: Commons Users List
Subject: Re: [imaging] Comment tag problem

Hi Andrea!

Today spent some minutes with Eclipse and the code base, plus exiftool, to see where that comment was coming from.

That COM, or Comment, that you see in exiftool output is not exactly a metadata tag. It is actually a JPEG Segment. Sorry for the other suggestions.

As far as I know, we are not able to change the segments, but only the metadata within the TIFF/EXIF directories & tags [2].

You can still use comments if that's OK, but not sure how you would achieve adding the Comment in Java.
MG>testXMPInsert borrowed from JpegXmpRewriteTest.java
{
// test insert
String newXmpXml = "comment";
//subin your fileName to imageFile.getName()
File updated = createTempFile(imageFile.getName() + ".", ".jpg");
OutputStream os = null;
try
{
os = new FileOutputStream(updated);
os = new BufferedOutputStream(os);
new org.apache.sanselan.formats.jpeg..xmp.JpegXmpRewriter().updateXmpXml(
org.apache.sanselan.common.byteSources.ByteSourceFile(noXmpFile), os,
newXmpXml);
} finally
{
os.close();
os = null;
}

// Debug.debug("Source Segments:");
// new JpegUtils().dumpJFIF(new ByteSourceFile(updated));

String outXmp = new org.apache.sanselan.formats.jpeg.JpegImageParser().getXmpXml(
new ByteSourceFile(updated), params);
assertNotNull(outXmp);
assertEquals(outXmp, newXmpXml);
}

MG>please confirm this works for you
MG>required sanselanependency for pom.xml:
<groupId>org.apache.sanselan</groupId>
<artifactId>sanselan</artifactId>
<version>0.97-incubator</version>


Bruno
MG>?
MG>Martin-


[1] http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0
Writing comments<http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0>
u88.n24.queensu.ca
Writing comments



[2] https://issues.apache.org/jira/browse/IMAGING-55


________________________________
From: andrea antonello <***@gmail.com>
To: Commons Users List <***@commons.apache.org>
Sent: Thursday, 26 April 2018 8:02 PM
Subject: Re: [imaging] Comment tag problem
Post by Martin Gainty
I normally use exiftool to compare what imaging is producing. The htmldump is quite useful.
I just ran the normal info extraction and here you see the comment I
would like to reproduce (Comment):

ExifTool Version Number : 10.94
File Name : 109_Background.jpg
Directory : .
File Size : 428 kB
File Modification Date/Time : 2018:03:31 11:01:51+02:00
File Access Date/Time : 2018:04:26 08:59:06+02:00
File Inode Change Date/Time : 2018:03:31 11:01:56+02:00
File Permissions : rw-rw-r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
Comment :
GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
JFIF Version : 1.01
Resolution Unit : inches
X Resolution : 96
Y Resolution : 96
Image Width : 1608
Image Height : 901
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 1608x901
Megapixels : 1.4
Post by Martin Gainty
I thought you had to create the tag in Java, but if you can use other tools and it's easier for you, then that might be the best option.
Yes, I do have to recreate it in java. I was just trying to use other
tools to check what the comment tag is.
Do you have an idea on how to create the above Comment tag?
Post by Martin Gainty
Otherwise you can create pretty much any other metadata tag you'd like with some Java coding.
That is what I would love to end up with.
Thanks a ton,
Andrea
Post by Martin Gainty
________________________________
Sent: Thursday, 26 April 2018 7:15 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
Post by Bruno P. Kinoshita
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.
exiftool -comment='mycomment'
creates exaclty the comment I am not able to reproduce. Do you know
what that is?
Post by Bruno P. Kinoshita
If you really need to match that tag, then I think you should be able to create your own custom metadata entry.
I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)
I will try again. I tried already that path, but since it asks me for
a tag (integer) I then end up to have it named as the tag I am trying
to substitute...
Thanks,
Andrea
Post by Bruno P. Kinoshita
Hope that helps,
Bruno
[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
________________________________
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.
The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section
and under start section I find
comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
and
exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
both not the same as what i am looking for.
I have been able to print the following information through an
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694
So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.
Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org

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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
andrea antonello
2018-04-30 07:54:52 UTC
Permalink
Hi Bruno and Martin,
thanks a ton for your help.

I tried the code but nothing changes.

My output doesn't have a COM segment, but I noticed something.

This is the info dump of the image before applying Martin's code:

File Type = JPEG
File Size = 231038
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x000000b=11 : Version = 1.2
@0x000000d=13 : Units = 'aspect ratio'
@0x000000e=14 : Xdensity = 1
@0x0000010=16 : Ydensity = 1
@0x0000012=18 : XThumbnail = 0
@0x0000013=19 : YThumbnail = 0
@0x0000013=19 : </JPEG_APP0>
@0x0000014=20 : <JPEG_DQT> length 67
@0x0000059=89 : <JPEG_DQT> length 67
@0x000009e=158 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1418, height=969
@0x00000b1=177 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x00000d2=210 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000189=393 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x00001aa=426 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x0000261=609 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1374042 pixels
@0x003867c=231036 : <JPEG_EOI> JPEG length 231038
-0x003867d=231037 : END OF FILE
@000000000=0 : Start of JPEG baseline DCT compressed primary
image [1418x969] length 231038 (APP0)
-0x003867d=231037 : End of JPEG primary image data
Number of images = 1
File Format = JPEG/APP0/JFIF


and this is when I do apply it:

File Type = JPEG
File Size = 231183
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x000000b=11 : Version = 1.2
@0x000000d=13 : Units = 'aspect ratio'
@0x000000e=14 : Xdensity = 1
@0x0000010=16 : Ydensity = 1
@0x0000012=18 : XThumbnail = 0
@0x0000013=19 : YThumbnail = 0
@0x0000013=19 : </JPEG_APP0>
@0x0000014=20 : <JPEG_APP1> 0xffe1 length 143,
'http://ns.adobe.com/xap/1.0/' - unknown format - (not dumped: use -A)
-0x00000a4=164 : </JPEG_APP1>
@0x00000a5=165 : <JPEG_DQT> length 67
@0x00000ea=234 : <JPEG_DQT> length 67
@0x000012f=303 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1418, height=969
@0x0000142=322 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x0000163=355 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x000021a=538 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x000023b=571 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002f2=754 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1374042 pixels
@0x003870d=231181 : <JPEG_EOI> JPEG length 231183
-0x003870e=231182 : END OF FILE
@000000000=0 : Start of JPEG baseline DCT compressed primary
image [1418x969] length 231183
-0x003870e=231182 : End of JPEG primary image data
Number of images = 1
File Format = JPEG/APP0/JFIF/APP1

It looks like what I did got into the tag: JPEG_APP1, while not
JPEG_COM has been created as in:

File Type = JPEG
File Size = 438694
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_COM> length 137:
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
[...]


Did I miss something or can something be changed to get there?

I tried to have a look at the mentioned testcase but have not been
able to understand how to switch segment or how segments are chosen in
first place.

Any idea?
Thank you,
Andrea







On Sat, Apr 28, 2018 at 3:15 AM, Bruno P. Kinoshita
Post by Bruno P. Kinoshita
Hi Martin,
Post by Martin Gainty
if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool
It's actually Andrea who is working with comments & JPEG images. I was just trying to help him, assuming he wants/needs to do that in Java. He pointed that he could do that with exiftool too (see previous e-mails in the thread for more).
@Andrea, see Martin's code in the e-mail below.
Thanks Martin!
Bruno
________________________________
Sent: Saturday, 28 April 2018 5:38 AM
Subject: Re: [imaging] Comment tag problem
Bruno
if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool
http://www.exiv2.org/manpage.html
Exiv2 utility manual - Image metadata library and tools<http://www.exiv2.org/manpage.html>
www.exiv2.org
Open Source Exif, IPTC and XMP metadata library and tools with Exif MakerNote and read/write support
MG>see below
________________________________
Sent: Friday, April 27, 2018 8:39 AM
To: Commons Users List
Subject: Re: [imaging] Comment tag problem
Hi Andrea!
Today spent some minutes with Eclipse and the code base, plus exiftool, to see where that comment was coming from.
That COM, or Comment, that you see in exiftool output is not exactly a metadata tag. It is actually a JPEG Segment. Sorry for the other suggestions.
As far as I know, we are not able to change the segments, but only the metadata within the TIFF/EXIF directories & tags [2].
You can still use comments if that's OK, but not sure how you would achieve adding the Comment in Java.
MG>testXMPInsert borrowed from JpegXmpRewriteTest.java
{
// test insert
String newXmpXml = "comment";
//subin your fileName to imageFile.getName()
File updated = createTempFile(imageFile.getName() + ".", ".jpg");
OutputStream os = null;
try
{
os = new FileOutputStream(updated);
os = new BufferedOutputStream(os);
new org.apache.sanselan.formats.jpeg..xmp.JpegXmpRewriter().updateXmpXml(
org.apache.sanselan.common.byteSources.ByteSourceFile(noXmpFile), os,
newXmpXml);
} finally
{
os.close();
os = null;
}
// Debug.debug("Source Segments:");
// new JpegUtils().dumpJFIF(new ByteSourceFile(updated));
String outXmp = new org.apache.sanselan.formats.jpeg.JpegImageParser().getXmpXml(
new ByteSourceFile(updated), params);
assertNotNull(outXmp);
assertEquals(outXmp, newXmpXml);
}
MG>please confirm this works for you
<groupId>org.apache.sanselan</groupId>
<artifactId>sanselan</artifactId>
<version>0.97-incubator</version>
Bruno
MG>?
MG>Martin-
[1] http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0
Writing comments<http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0>
u88.n24.queensu.ca
Writing comments
[2] https://issues.apache.org/jira/browse/IMAGING-55
________________________________
Sent: Thursday, 26 April 2018 8:02 PM
Subject: Re: [imaging] Comment tag problem
Post by Martin Gainty
I normally use exiftool to compare what imaging is producing. The htmldump is quite useful.
I just ran the normal info extraction and here you see the comment I
ExifTool Version Number : 10.94
File Name : 109_Background.jpg
Directory : .
File Size : 428 kB
File Modification Date/Time : 2018:03:31 11:01:51+02:00
File Access Date/Time : 2018:04:26 08:59:06+02:00
File Inode Change Date/Time : 2018:03:31 11:01:56+02:00
File Permissions : rw-rw-r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
JFIF Version : 1.01
Resolution Unit : inches
X Resolution : 96
Y Resolution : 96
Image Width : 1608
Image Height : 901
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 1608x901
Megapixels : 1.4
Post by Martin Gainty
I thought you had to create the tag in Java, but if you can use other tools and it's easier for you, then that might be the best option.
Yes, I do have to recreate it in java. I was just trying to use other
tools to check what the comment tag is.
Do you have an idea on how to create the above Comment tag?
Post by Martin Gainty
Otherwise you can create pretty much any other metadata tag you'd like with some Java coding.
That is what I would love to end up with.
Thanks a ton,
Andrea
Post by Martin Gainty
________________________________
Sent: Thursday, 26 April 2018 7:15 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
Post by Bruno P. Kinoshita
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.
exiftool -comment='mycomment'
creates exaclty the comment I am not able to reproduce. Do you know
what that is?
Post by Bruno P. Kinoshita
If you really need to match that tag, then I think you should be able to create your own custom metadata entry.
I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)
I will try again. I tried already that path, but since it asks me for
a tag (integer) I then end up to have it named as the tag I am trying
to substitute...
Thanks,
Andrea
Post by Bruno P. Kinoshita
Hope that helps,
Bruno
[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
________________________________
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.
The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section
and under start section I find
comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
and
exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
both not the same as what i am looking for.
I have been able to print the following information through an
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694
So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.
Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
Bruno P. Kinoshita
2018-04-30 08:25:37 UTC
Permalink
Hi Andrea,

I believe the issue is that what you are trying to do is to add a segment, not a tag.


I think what you are trying to add, is a comment in the COM segment.

Have a look at this page

[1] https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html

There you should find a table. Where you see the JPEG tags, they are the identifier of
JPEG segments.

Near the bottom of that table, you will find the COM segment. It is a bit confusing
to speak about tags, segments, markers. So here's a practical example with exiftool,
which you mentioned before you used too.

1. This Exiv2 page has a sample image with some metadata http://www.exiv2.org/sample.html. Save it somewhere
2. Run `exiftool -htmldump img_1771.jpg > before.html`
3. Run `exiftool -comment=KIAORA img_1771.jpg`
4. Run `exiftool -htmldump img_1771.jpg > after.html`


Now open before.html and after.html. Search for "segment" in your browser. In before.html, you should find
just the following:

"APP0 JFIF segment APP1 header Exif header"

Which if you look at [1] you should be able to compare the EXIF tags in that segment,
matching by tag name (e.g.FocalLength) and perhaps by group name too (e.g.
ExifIFD).

You won't find the COM segment in before.html, as the Exiv2 sample image doesn't have it.


Now, if you open after.html, and search for "KIAORA", or if you have noticed before when you
searched by "segment", there should be now a second segment. Look again at [1], near the
bottom of the first table. You should find a COM segment.

In [imaging], there is a certain distinction between tag and segment. The example I had sent before
was for tags, sorry. I am not aware of a way to modify the COM segment in [imaging] at the moment.
There is an open JIRA ticket for that (sent in my previous e-mail).

Might be easier to use the UserComment tag perhaps, or dig a bit deeper into the code to
see if you can find a way to modify it in a lower level, by modifying bytes perhaps...


Feel free to chime in there and watch that ticket if you would like to see that feature
implemented, or give any suggestions.


Hope that helps,

Bruno

________________________________
From: andrea antonello <***@gmail.com>
To: Commons Users List <***@commons.apache.org>
Sent: Monday, 30 April 2018 7:55 PM
Subject: Re: [imaging] Comment tag problem



Hi Bruno and Martin,
thanks a ton for your help.

I tried the code but nothing changes.

My output doesn't have a COM segment, but I noticed something.

This is the info dump of the image before applying Martin's code:

File Type = JPEG
File Size = 231038
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x000000b=11 : Version = 1.2
@0x000000d=13 : Units = 'aspect ratio'
@0x000000e=14 : Xdensity = 1
@0x0000010=16 : Ydensity = 1
@0x0000012=18 : XThumbnail = 0
@0x0000013=19 : YThumbnail = 0
@0x0000013=19 : </JPEG_APP0>
@0x0000014=20 : <JPEG_DQT> length 67
@0x0000059=89 : <JPEG_DQT> length 67
@0x000009e=158 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1418, height=969
@0x00000b1=177 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x00000d2=210 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000189=393 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x00001aa=426 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x0000261=609 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1374042 pixels
@0x003867c=231036 : <JPEG_EOI> JPEG length 231038
-0x003867d=231037 : END OF FILE
@000000000=0 : Start of JPEG baseline DCT compressed primary
image [1418x969] length 231038 (APP0)
-0x003867d=231037 : End of JPEG primary image data
Number of images = 1
File Format = JPEG/APP0/JFIF


and this is when I do apply it:

File Type = JPEG
File Size = 231183
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x000000b=11 : Version = 1.2
@0x000000d=13 : Units = 'aspect ratio'
@0x000000e=14 : Xdensity = 1
@0x0000010=16 : Ydensity = 1
@0x0000012=18 : XThumbnail = 0
@0x0000013=19 : YThumbnail = 0
@0x0000013=19 : </JPEG_APP0>
@0x0000014=20 : <JPEG_APP1> 0xffe1 length 143,
'http://ns.adobe.com/xap/1.0/' - unknown format - (not dumped: use -A)
-0x00000a4=164 : </JPEG_APP1>
@0x00000a5=165 : <JPEG_DQT> length 67
@0x00000ea=234 : <JPEG_DQT> length 67
@0x000012f=303 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1418, height=969
@0x0000142=322 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x0000163=355 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x000021a=538 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x000023b=571 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002f2=754 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1374042 pixels
@0x003870d=231181 : <JPEG_EOI> JPEG length 231183
-0x003870e=231182 : END OF FILE
@000000000=0 : Start of JPEG baseline DCT compressed primary
image [1418x969] length 231183
-0x003870e=231182 : End of JPEG primary image data
Number of images = 1
File Format = JPEG/APP0/JFIF/APP1

It looks like what I did got into the tag: JPEG_APP1, while not
JPEG_COM has been created as in:

File Type = JPEG
File Size = 438694
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_COM> length 137:
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
[...]


Did I miss something or can something be changed to get there?

I tried to have a look at the mentioned testcase but have not been
able to understand how to switch segment or how segments are chosen in
first place.

Any idea?
Thank you,
Andrea







On Sat, Apr 28, 2018 at 3:15 AM, Bruno P. Kinoshita
Post by Bruno P. Kinoshita
Hi Martin,
Post by Martin Gainty
if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool
It's actually Andrea who is working with comments & JPEG images. I was just trying to help him, assuming he wants/needs to do that in Java. He pointed that he could do that with exiftool too (see previous e-mails in the thread for more).
@Andrea, see Martin's code in the e-mail below.
Thanks Martin!
Bruno
________________________________
Sent: Saturday, 28 April 2018 5:38 AM
Subject: Re: [imaging] Comment tag problem
Bruno
if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool
http://www.exiv2.org/manpage.html
Exiv2 utility manual - Image metadata library and tools<http://www.exiv2.org/manpage.html>
www.exiv2.org
Open Source Exif, IPTC and XMP metadata library and tools with Exif MakerNote and read/write support
MG>see below
________________________________
Sent: Friday, April 27, 2018 8:39 AM
To: Commons Users List
Subject: Re: [imaging] Comment tag problem
Hi Andrea!
Today spent some minutes with Eclipse and the code base, plus exiftool, to see where that comment was coming from.
That COM, or Comment, that you see in exiftool output is not exactly a metadata tag. It is actually a JPEG Segment. Sorry for the other suggestions.
As far as I know, we are not able to change the segments, but only the metadata within the TIFF/EXIF directories & tags [2].
You can still use comments if that's OK, but not sure how you would achieve adding the Comment in Java.
MG>testXMPInsert borrowed from JpegXmpRewriteTest.java
{
// test insert
String newXmpXml = "comment";
//subin your fileName to imageFile.getName()
File updated = createTempFile(imageFile.getName() + ".", ".jpg");
OutputStream os = null;
try
{
os = new FileOutputStream(updated);
os = new BufferedOutputStream(os);
new org.apache.sanselan.formats.jpeg..xmp.JpegXmpRewriter().updateXmpXml(
org.apache.sanselan.common.byteSources.ByteSourceFile(noXmpFile), os,
newXmpXml);
} finally
{
os.close();
os = null;
}
// Debug.debug("Source Segments:");
// new JpegUtils().dumpJFIF(new ByteSourceFile(updated));
String outXmp = new org.apache.sanselan.formats.jpeg.JpegImageParser().getXmpXml(
new ByteSourceFile(updated), params);
assertNotNull(outXmp);
assertEquals(outXmp, newXmpXml);
}
MG>please confirm this works for you
<groupId>org.apache.sanselan</groupId>
<artifactId>sanselan</artifactId>
<version>0.97-incubator</version>
Bruno
MG>?
MG>Martin-
[1] http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0
Writing comments<http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0>
u88.n24.queensu.ca
Writing comments
[2] https://issues.apache.org/jira/browse/IMAGING-55
________________________________
Sent: Thursday, 26 April 2018 8:02 PM
Subject: Re: [imaging] Comment tag problem
Post by Martin Gainty
I normally use exiftool to compare what imaging is producing. The htmldump is quite useful.
I just ran the normal info extraction and here you see the comment I
ExifTool Version Number : 10.94
File Name : 109_Background.jpg
Directory : .
File Size : 428 kB
File Modification Date/Time : 2018:03:31 11:01:51+02:00
File Access Date/Time : 2018:04:26 08:59:06+02:00
File Inode Change Date/Time : 2018:03:31 11:01:56+02:00
File Permissions : rw-rw-r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
JFIF Version : 1.01
Resolution Unit : inches
X Resolution : 96
Y Resolution : 96
Image Width : 1608
Image Height : 901
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 1608x901
Megapixels : 1.4
Post by Martin Gainty
I thought you had to create the tag in Java, but if you can use other tools and it's easier for you, then that might be the best option.
Yes, I do have to recreate it in java. I was just trying to use other
tools to check what the comment tag is.
Do you have an idea on how to create the above Comment tag?
Post by Martin Gainty
Otherwise you can create pretty much any other metadata tag you'd like with some Java coding.
That is what I would love to end up with.
Thanks a ton,
Andrea
Post by Martin Gainty
________________________________
Sent: Thursday, 26 April 2018 7:15 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
Post by Bruno P. Kinoshita
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.
exiftool -comment='mycomment'
creates exaclty the comment I am not able to reproduce. Do you know
what that is?
Post by Bruno P. Kinoshita
If you really need to match that tag, then I think you should be able to create your own custom metadata entry.
I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)
I will try again. I tried already that path, but since it asks me for
a tag (integer) I then end up to have it named as the tag I am trying
to substitute...
Thanks,
Andrea
Post by Bruno P. Kinoshita
Hope that helps,
Bruno
[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
________________________________
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.
The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section
and under start section I find
comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
and
exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
both not the same as what i am looking for.
I have been able to print the following information through an
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694
So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.
Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
andrea antonello
2018-04-30 08:34:20 UTC
Permalink
Hi Bruno,
thanks again for coming back to me.
Post by Bruno P. Kinoshita
I believe the issue is that what you are trying to do is to add a segment, not a tag.
I think what you are trying to add, is a comment in the COM segment.
yes, exactly.
Post by Bruno P. Kinoshita
Have a look at this page
[1] https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html
There you should find a table. Where you see the JPEG tags, they are the identifier of
JPEG segments.
Near the bottom of that table, you will find the COM segment. It is a bit confusing
to speak about tags, segments, markers. So here's a practical example with exiftool,
which you mentioned before you used too.
1. This Exiv2 page has a sample image with some metadata http://www.exiv2.org/sample.html. Save it somewhere
2. Run `exiftool -htmldump img_1771.jpg > before.html`
3. Run `exiftool -comment=KIAORA img_1771.jpg`
4. Run `exiftool -htmldump img_1771.jpg > after.html`
Now open before.html and after.html. Search for "segment" in your browser. In before.html, you should find
"APP0 JFIF segment APP1 header Exif header"
Which if you look at [1] you should be able to compare the EXIF tags in that segment,
matching by tag name (e.g.FocalLength) and perhaps by group name too (e.g.
ExifIFD).
You won't find the COM segment in before.html, as the Exiv2 sample image doesn't have it.
Now, if you open after.html, and search for "KIAORA", or if you have noticed before when you
searched by "segment", there should be now a second segment. Look again at [1], near the
bottom of the first table. You should find a COM segment.
In [imaging], there is a certain distinction between tag and segment. The example I had sent before
was for tags, sorry. I am not aware of a way to modify the COM segment in [imaging] at the moment.
There is an open JIRA ticket for that (sent in my previous e-mail).
Ok, in fact I had been fooled by the code that had been added and
thought that there was a way to do it fo which you didn't know. Sorry,
my misunderstanding here.
Now everything is clear, thank you.
Post by Bruno P. Kinoshita
Might be easier to use the UserComment tag perhaps, or dig a bit deeper into the code to
see if you can find a way to modify it in a lower level, by modifying bytes perhaps...
Feel free to chime in there and watch that ticket if you would like to see that feature
implemented, or give any suggestions.
Hope that helps,
It does, thanks a lot.

All the best,
Andrea
Post by Bruno P. Kinoshita
Bruno
________________________________
Sent: Monday, 30 April 2018 7:55 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno and Martin,
thanks a ton for your help.
I tried the code but nothing changes.
My output doesn't have a COM segment, but I noticed something.
File Type = JPEG
File Size = 231038
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x000000b=11 : Version = 1.2
@0x000000d=13 : Units = 'aspect ratio'
@0x000000e=14 : Xdensity = 1
@0x0000010=16 : Ydensity = 1
@0x0000012=18 : XThumbnail = 0
@0x0000013=19 : YThumbnail = 0
@0x0000013=19 : </JPEG_APP0>
@0x0000014=20 : <JPEG_DQT> length 67
@0x0000059=89 : <JPEG_DQT> length 67
@0x000009e=158 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1418, height=969
@0x00000b1=177 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x00000d2=210 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000189=393 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x00001aa=426 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x0000261=609 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1374042 pixels
@0x003867c=231036 : <JPEG_EOI> JPEG length 231038
-0x003867d=231037 : END OF FILE
@000000000=0 : Start of JPEG baseline DCT compressed primary
image [1418x969] length 231038 (APP0)
-0x003867d=231037 : End of JPEG primary image data
Number of images = 1
File Format = JPEG/APP0/JFIF
File Type = JPEG
File Size = 231183
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x000000b=11 : Version = 1.2
@0x000000d=13 : Units = 'aspect ratio'
@0x000000e=14 : Xdensity = 1
@0x0000010=16 : Ydensity = 1
@0x0000012=18 : XThumbnail = 0
@0x0000013=19 : YThumbnail = 0
@0x0000013=19 : </JPEG_APP0>
@0x0000014=20 : <JPEG_APP1> 0xffe1 length 143,
'http://ns.adobe.com/xap/1.0/' - unknown format - (not dumped: use -A)
-0x00000a4=164 : </JPEG_APP1>
@0x00000a5=165 : <JPEG_DQT> length 67
@0x00000ea=234 : <JPEG_DQT> length 67
@0x000012f=303 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1418, height=969
@0x0000142=322 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x0000163=355 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x000021a=538 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x000023b=571 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002f2=754 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1374042 pixels
@0x003870d=231181 : <JPEG_EOI> JPEG length 231183
-0x003870e=231182 : END OF FILE
@000000000=0 : Start of JPEG baseline DCT compressed primary
image [1418x969] length 231183
-0x003870e=231182 : End of JPEG primary image data
Number of images = 1
File Format = JPEG/APP0/JFIF/APP1
It looks like what I did got into the tag: JPEG_APP1, while not
File Type = JPEG
File Size = 438694
@000000000=0 : <JPEG_SOI>
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
[...]
Did I miss something or can something be changed to get there?
I tried to have a look at the mentioned testcase but have not been
able to understand how to switch segment or how segments are chosen in
first place.
Any idea?
Thank you,
Andrea
On Sat, Apr 28, 2018 at 3:15 AM, Bruno P. Kinoshita
Post by Bruno P. Kinoshita
Hi Martin,
Post by Martin Gainty
if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool
It's actually Andrea who is working with comments & JPEG images. I was just trying to help him, assuming he wants/needs to do that in Java. He pointed that he could do that with exiftool too (see previous e-mails in the thread for more).
@Andrea, see Martin's code in the e-mail below.
Thanks Martin!
Bruno
________________________________
Sent: Saturday, 28 April 2018 5:38 AM
Subject: Re: [imaging] Comment tag problem
Bruno
if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool
http://www.exiv2.org/manpage.html
Exiv2 utility manual - Image metadata library and tools<http://www.exiv2.org/manpage.html>
www.exiv2.org
Open Source Exif, IPTC and XMP metadata library and tools with Exif MakerNote and read/write support
MG>see below
________________________________
Sent: Friday, April 27, 2018 8:39 AM
To: Commons Users List
Subject: Re: [imaging] Comment tag problem
Hi Andrea!
Today spent some minutes with Eclipse and the code base, plus exiftool, to see where that comment was coming from.
That COM, or Comment, that you see in exiftool output is not exactly a metadata tag. It is actually a JPEG Segment. Sorry for the other suggestions.
As far as I know, we are not able to change the segments, but only the metadata within the TIFF/EXIF directories & tags [2].
You can still use comments if that's OK, but not sure how you would achieve adding the Comment in Java.
MG>testXMPInsert borrowed from JpegXmpRewriteTest.java
{
// test insert
String newXmpXml = "comment";
//subin your fileName to imageFile.getName()
File updated = createTempFile(imageFile.getName() + ".", ".jpg");
OutputStream os = null;
try
{
os = new FileOutputStream(updated);
os = new BufferedOutputStream(os);
new org.apache.sanselan.formats.jpeg..xmp.JpegXmpRewriter().updateXmpXml(
org.apache.sanselan.common.byteSources.ByteSourceFile(noXmpFile), os,
newXmpXml);
} finally
{
os.close();
os = null;
}
// Debug.debug("Source Segments:");
// new JpegUtils().dumpJFIF(new ByteSourceFile(updated));
String outXmp = new org.apache.sanselan.formats.jpeg.JpegImageParser().getXmpXml(
new ByteSourceFile(updated), params);
assertNotNull(outXmp);
assertEquals(outXmp, newXmpXml);
}
MG>please confirm this works for you
<groupId>org.apache.sanselan</groupId>
<artifactId>sanselan</artifactId>
<version>0.97-incubator</version>
Bruno
MG>?
MG>Martin-
[1] http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0
Writing comments<http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0>
u88.n24.queensu.ca
Writing comments
[2] https://issues.apache.org/jira/browse/IMAGING-55
________________________________
Sent: Thursday, 26 April 2018 8:02 PM
Subject: Re: [imaging] Comment tag problem
Post by Martin Gainty
I normally use exiftool to compare what imaging is producing. The htmldump is quite useful.
I just ran the normal info extraction and here you see the comment I
ExifTool Version Number : 10.94
File Name : 109_Background.jpg
Directory : .
File Size : 428 kB
File Modification Date/Time : 2018:03:31 11:01:51+02:00
File Access Date/Time : 2018:04:26 08:59:06+02:00
File Inode Change Date/Time : 2018:03:31 11:01:56+02:00
File Permissions : rw-rw-r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
JFIF Version : 1.01
Resolution Unit : inches
X Resolution : 96
Y Resolution : 96
Image Width : 1608
Image Height : 901
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 1608x901
Megapixels : 1.4
Post by Martin Gainty
I thought you had to create the tag in Java, but if you can use other tools and it's easier for you, then that might be the best option.
Yes, I do have to recreate it in java. I was just trying to use other
tools to check what the comment tag is.
Do you have an idea on how to create the above Comment tag?
Post by Martin Gainty
Otherwise you can create pretty much any other metadata tag you'd like with some Java coding.
That is what I would love to end up with.
Thanks a ton,
Andrea
Post by Martin Gainty
________________________________
Sent: Thursday, 26 April 2018 7:15 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
Post by Bruno P. Kinoshita
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.
exiftool -comment='mycomment'
creates exaclty the comment I am not able to reproduce. Do you know
what that is?
Post by Bruno P. Kinoshita
If you really need to match that tag, then I think you should be able to create your own custom metadata entry.
I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)
I will try again. I tried already that path, but since it asks me for
a tag (integer) I then end up to have it named as the tag I am trying
to substitute...
Thanks,
Andrea
Post by Bruno P. Kinoshita
Hope that helps,
Bruno
[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
________________________________
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.
The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section
and under start section I find
comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
and
exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
both not the same as what i am looking for.
I have been able to print the following information through an
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694
So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.
Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
andrea antonello
2018-07-06 10:26:24 UTC
Permalink
Hi Bruno, all,
a short update for the original request.

I have been able to lay my hands on the C code that was writing the
comment (to remind, a comment in the COM segment).
It runs out to be something quite simeple, if you know how to do it.

Basically, it is done by squeezing the comment into the existing image
(i.e. doing a modified copy), using the following few lines of code :

String inPath = "blah.jpg";
String outPath = "blah_out.jpg";
try (RandomAccessFile raIn = new RandomAccessFile(new File(inPath), "r");
RandomAccessFile raOut = new RandomAccessFile(new
File(outPath), "rw");) {

// first 2 bytes are the same of the original image
raOut.write(raIn.read());
raOut.write(raIn.read());

// 2 bytes to identify the comment
raOut.write(0xFF);
raOut.write(0xFE);

// define the length of the comment you are going to insert
int length = 3 + geoInfo.length();
raOut.write(length / 0x100);
raOut.write(length % 0x100);

// write the bytes of the comment
raOut.write(geoInfo.getBytes());

// add final 0
raOut.write(0);

// write the rest of the original image
int b;
while( (b = raIn.read()) != -1 ) {
raOut.write(b);
}
}

This could be done better and I have no idea if this is defined in some specs.
But it works and it might help someone in my same need.

Cheers,
Andrea



On Mon, Apr 30, 2018 at 10:34 AM andrea antonello
Post by andrea antonello
Hi Bruno,
thanks again for coming back to me.
Post by Bruno P. Kinoshita
I believe the issue is that what you are trying to do is to add a segment, not a tag.
I think what you are trying to add, is a comment in the COM segment.
yes, exactly.
Post by Bruno P. Kinoshita
Have a look at this page
[1] https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html
There you should find a table. Where you see the JPEG tags, they are the identifier of
JPEG segments.
Near the bottom of that table, you will find the COM segment. It is a bit confusing
to speak about tags, segments, markers. So here's a practical example with exiftool,
which you mentioned before you used too.
1. This Exiv2 page has a sample image with some metadata http://www.exiv2.org/sample.html. Save it somewhere
2. Run `exiftool -htmldump img_1771.jpg > before.html`
3. Run `exiftool -comment=KIAORA img_1771.jpg`
4. Run `exiftool -htmldump img_1771.jpg > after.html`
Now open before.html and after.html. Search for "segment" in your browser. In before.html, you should find
"APP0 JFIF segment APP1 header Exif header"
Which if you look at [1] you should be able to compare the EXIF tags in that segment,
matching by tag name (e.g.FocalLength) and perhaps by group name too (e.g.
ExifIFD).
You won't find the COM segment in before.html, as the Exiv2 sample image doesn't have it.
Now, if you open after.html, and search for "KIAORA", or if you have noticed before when you
searched by "segment", there should be now a second segment. Look again at [1], near the
bottom of the first table. You should find a COM segment.
In [imaging], there is a certain distinction between tag and segment. The example I had sent before
was for tags, sorry. I am not aware of a way to modify the COM segment in [imaging] at the moment.
There is an open JIRA ticket for that (sent in my previous e-mail).
Ok, in fact I had been fooled by the code that had been added and
thought that there was a way to do it fo which you didn't know. Sorry,
my misunderstanding here.
Now everything is clear, thank you.
Post by Bruno P. Kinoshita
Might be easier to use the UserComment tag perhaps, or dig a bit deeper into the code to
see if you can find a way to modify it in a lower level, by modifying bytes perhaps...
Feel free to chime in there and watch that ticket if you would like to see that feature
implemented, or give any suggestions.
Hope that helps,
It does, thanks a lot.
All the best,
Andrea
Post by Bruno P. Kinoshita
Bruno
________________________________
Sent: Monday, 30 April 2018 7:55 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno and Martin,
thanks a ton for your help.
I tried the code but nothing changes.
My output doesn't have a COM segment, but I noticed something.
File Type = JPEG
File Size = 231038
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x000000b=11 : Version = 1.2
@0x000000d=13 : Units = 'aspect ratio'
@0x000000e=14 : Xdensity = 1
@0x0000010=16 : Ydensity = 1
@0x0000012=18 : XThumbnail = 0
@0x0000013=19 : YThumbnail = 0
@0x0000013=19 : </JPEG_APP0>
@0x0000014=20 : <JPEG_DQT> length 67
@0x0000059=89 : <JPEG_DQT> length 67
@0x000009e=158 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1418, height=969
@0x00000b1=177 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x00000d2=210 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000189=393 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x00001aa=426 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x0000261=609 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1374042 pixels
@0x003867c=231036 : <JPEG_EOI> JPEG length 231038
-0x003867d=231037 : END OF FILE
@000000000=0 : Start of JPEG baseline DCT compressed primary
image [1418x969] length 231038 (APP0)
-0x003867d=231037 : End of JPEG primary image data
Number of images = 1
File Format = JPEG/APP0/JFIF
File Type = JPEG
File Size = 231183
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x000000b=11 : Version = 1.2
@0x000000d=13 : Units = 'aspect ratio'
@0x000000e=14 : Xdensity = 1
@0x0000010=16 : Ydensity = 1
@0x0000012=18 : XThumbnail = 0
@0x0000013=19 : YThumbnail = 0
@0x0000013=19 : </JPEG_APP0>
@0x0000014=20 : <JPEG_APP1> 0xffe1 length 143,
'http://ns.adobe.com/xap/1.0/' - unknown format - (not dumped: use -A)
-0x00000a4=164 : </JPEG_APP1>
@0x00000a5=165 : <JPEG_DQT> length 67
@0x00000ea=234 : <JPEG_DQT> length 67
@0x000012f=303 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1418, height=969
@0x0000142=322 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x0000163=355 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x000021a=538 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x000023b=571 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002f2=754 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1374042 pixels
@0x003870d=231181 : <JPEG_EOI> JPEG length 231183
-0x003870e=231182 : END OF FILE
@000000000=0 : Start of JPEG baseline DCT compressed primary
image [1418x969] length 231183
-0x003870e=231182 : End of JPEG primary image data
Number of images = 1
File Format = JPEG/APP0/JFIF/APP1
It looks like what I did got into the tag: JPEG_APP1, while not
File Type = JPEG
File Size = 438694
@000000000=0 : <JPEG_SOI>
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
[...]
Did I miss something or can something be changed to get there?
I tried to have a look at the mentioned testcase but have not been
able to understand how to switch segment or how segments are chosen in
first place.
Any idea?
Thank you,
Andrea
On Sat, Apr 28, 2018 at 3:15 AM, Bruno P. Kinoshita
Post by Bruno P. Kinoshita
Hi Martin,
Post by Martin Gainty
if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool
It's actually Andrea who is working with comments & JPEG images. I was just trying to help him, assuming he wants/needs to do that in Java. He pointed that he could do that with exiftool too (see previous e-mails in the thread for more).
@Andrea, see Martin's code in the e-mail below.
Thanks Martin!
Bruno
________________________________
Sent: Saturday, 28 April 2018 5:38 AM
Subject: Re: [imaging] Comment tag problem
Bruno
if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool
http://www.exiv2.org/manpage.html
Exiv2 utility manual - Image metadata library and tools<http://www.exiv2.org/manpage.html>
www.exiv2.org
Open Source Exif, IPTC and XMP metadata library and tools with Exif MakerNote and read/write support
MG>see below
________________________________
Sent: Friday, April 27, 2018 8:39 AM
To: Commons Users List
Subject: Re: [imaging] Comment tag problem
Hi Andrea!
Today spent some minutes with Eclipse and the code base, plus exiftool, to see where that comment was coming from.
That COM, or Comment, that you see in exiftool output is not exactly a metadata tag. It is actually a JPEG Segment. Sorry for the other suggestions.
As far as I know, we are not able to change the segments, but only the metadata within the TIFF/EXIF directories & tags [2].
You can still use comments if that's OK, but not sure how you would achieve adding the Comment in Java.
MG>testXMPInsert borrowed from JpegXmpRewriteTest.java
{
// test insert
String newXmpXml = "comment";
//subin your fileName to imageFile.getName()
File updated = createTempFile(imageFile.getName() + ".", ".jpg");
OutputStream os = null;
try
{
os = new FileOutputStream(updated);
os = new BufferedOutputStream(os);
new org.apache.sanselan.formats.jpeg..xmp.JpegXmpRewriter().updateXmpXml(
org.apache.sanselan.common.byteSources.ByteSourceFile(noXmpFile), os,
newXmpXml);
} finally
{
os.close();
os = null;
}
// Debug.debug("Source Segments:");
// new JpegUtils().dumpJFIF(new ByteSourceFile(updated));
String outXmp = new org.apache.sanselan.formats.jpeg.JpegImageParser().getXmpXml(
new ByteSourceFile(updated), params);
assertNotNull(outXmp);
assertEquals(outXmp, newXmpXml);
}
MG>please confirm this works for you
<groupId>org.apache.sanselan</groupId>
<artifactId>sanselan</artifactId>
<version>0.97-incubator</version>
Bruno
MG>?
MG>Martin-
[1] http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0
Writing comments<http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0>
u88.n24.queensu.ca
Writing comments
[2] https://issues.apache.org/jira/browse/IMAGING-55
________________________________
Sent: Thursday, 26 April 2018 8:02 PM
Subject: Re: [imaging] Comment tag problem
Post by Martin Gainty
I normally use exiftool to compare what imaging is producing. The htmldump is quite useful.
I just ran the normal info extraction and here you see the comment I
ExifTool Version Number : 10.94
File Name : 109_Background.jpg
Directory : .
File Size : 428 kB
File Modification Date/Time : 2018:03:31 11:01:51+02:00
File Access Date/Time : 2018:04:26 08:59:06+02:00
File Inode Change Date/Time : 2018:03:31 11:01:56+02:00
File Permissions : rw-rw-r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
JFIF Version : 1.01
Resolution Unit : inches
X Resolution : 96
Y Resolution : 96
Image Width : 1608
Image Height : 901
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 1608x901
Megapixels : 1.4
Post by Martin Gainty
I thought you had to create the tag in Java, but if you can use other tools and it's easier for you, then that might be the best option.
Yes, I do have to recreate it in java. I was just trying to use other
tools to check what the comment tag is.
Do you have an idea on how to create the above Comment tag?
Post by Martin Gainty
Otherwise you can create pretty much any other metadata tag you'd like with some Java coding.
That is what I would love to end up with.
Thanks a ton,
Andrea
Post by Martin Gainty
________________________________
Sent: Thursday, 26 April 2018 7:15 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
Post by Bruno P. Kinoshita
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.
exiftool -comment='mycomment'
creates exaclty the comment I am not able to reproduce. Do you know
what that is?
Post by Bruno P. Kinoshita
If you really need to match that tag, then I think you should be able to create your own custom metadata entry.
I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)
I will try again. I tried already that path, but since it asks me for
a tag (integer) I then end up to have it named as the tag I am trying
to substitute...
Thanks,
Andrea
Post by Bruno P. Kinoshita
Hope that helps,
Bruno
[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
________________________________
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.
The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section
and under start section I find
comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
and
exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
both not the same as what i am looking for.
I have been able to print the following information through an
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694
So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.
Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org
Bruno P. Kinoshita
2018-07-06 11:04:51 UTC
Permalink
Hi Andrea,

Thanks for updating the thread with a solution for other users!

I am planning to have a cycle to work on issues in JIRA for imaging, and try to push it a bit closer to a 1.0 release. So if you have other issues or enhancements for the library, feel free to log them in JIRA or drop a message here or on the dev-list if necessary.

Cheers

Bruno




________________________________
From: andrea antonello <***@gmail.com>
To: Commons Users List <***@commons.apache.org>
Sent: Friday, 6 July 2018 10:26 PM
Subject: Re: [imaging] Comment tag problem



Hi Bruno, all,

a short update for the original request.


I have been able to lay my hands on the C code that was writing the

comment (to remind, a comment in the COM segment).

It runs out to be something quite simeple, if you know how to do it.


Basically, it is done by squeezing the comment into the existing image

(i.e. doing a modified copy), using the following few lines of code :


String inPath = "blah.jpg";

String outPath = "blah_out.jpg";

try (RandomAccessFile raIn = new RandomAccessFile(new File(inPath), "r");

RandomAccessFile raOut = new RandomAccessFile(new

File(outPath), "rw");) {


// first 2 bytes are the same of the original image

raOut.write(raIn.read());

raOut.write(raIn.read());


// 2 bytes to identify the comment

raOut.write(0xFF);

raOut.write(0xFE);


// define the length of the comment you are going to insert

int length = 3 + geoInfo.length();

raOut.write(length / 0x100);

raOut.write(length % 0x100);


// write the bytes of the comment

raOut.write(geoInfo.getBytes());


// add final 0

raOut.write(0);


// write the rest of the original image

int b;

while( (b = raIn.read()) != -1 ) {

raOut.write(b);

}

}


This could be done better and I have no idea if this is defined in some specs.

But it works and it might help someone in my same need.


Cheers,

Andrea




On Mon, Apr 30, 2018 at 10:34 AM andrea antonello
Post by andrea antonello
Hi Bruno,
thanks again for coming back to me.
Post by Bruno P. Kinoshita
I believe the issue is that what you are trying to do is to add a segment, not a tag.
I think what you are trying to add, is a comment in the COM segment.
yes, exactly.
Post by Bruno P. Kinoshita
Have a look at this page
[1] https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html
There you should find a table. Where you see the JPEG tags, they are the identifier of
JPEG segments.
Near the bottom of that table, you will find the COM segment. It is a bit confusing
to speak about tags, segments, markers. So here's a practical example with exiftool,
which you mentioned before you used too.
1. This Exiv2 page has a sample image with some metadata http://www.exiv2.org/sample.html. Save it somewhere
2. Run `exiftool -htmldump img_1771.jpg > before.html`
3. Run `exiftool -comment=KIAORA img_1771.jpg`
4. Run `exiftool -htmldump img_1771.jpg > after.html`
Now open before.html and after.html. Search for "segment" in your browser. In before.html, you should find
"APP0 JFIF segment APP1 header Exif header"
Which if you look at [1] you should be able to compare the EXIF tags in that segment,
matching by tag name (e.g.FocalLength) and perhaps by group name too (e.g.
ExifIFD).
You won't find the COM segment in before.html, as the Exiv2 sample image doesn't have it.
Now, if you open after.html, and search for "KIAORA", or if you have noticed before when you
searched by "segment", there should be now a second segment. Look again at [1], near the
bottom of the first table. You should find a COM segment.
In [imaging], there is a certain distinction between tag and segment. The example I had sent before
was for tags, sorry. I am not aware of a way to modify the COM segment in [imaging] at the moment.
There is an open JIRA ticket for that (sent in my previous e-mail).
Ok, in fact I had been fooled by the code that had been added and
thought that there was a way to do it fo which you didn't know. Sorry,
my misunderstanding here.
Now everything is clear, thank you.
Post by Bruno P. Kinoshita
Might be easier to use the UserComment tag perhaps, or dig a bit deeper into the code to
see if you can find a way to modify it in a lower level, by modifying bytes perhaps...
Feel free to chime in there and watch that ticket if you would like to see that feature
implemented, or give any suggestions.
Hope that helps,
It does, thanks a lot.
All the best,
Andrea
Post by Bruno P. Kinoshita
Bruno
________________________________
Sent: Monday, 30 April 2018 7:55 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno and Martin,
thanks a ton for your help.
I tried the code but nothing changes.
My output doesn't have a COM segment, but I noticed something.
File Type = JPEG
File Size = 231038
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x000000b=11 : Version = 1.2
@0x000000d=13 : Units = 'aspect ratio'
@0x000000e=14 : Xdensity = 1
@0x0000010=16 : Ydensity = 1
@0x0000012=18 : XThumbnail = 0
@0x0000013=19 : YThumbnail = 0
@0x0000013=19 : </JPEG_APP0>
@0x0000014=20 : <JPEG_DQT> length 67
@0x0000059=89 : <JPEG_DQT> length 67
@0x000009e=158 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1418, height=969
@0x00000b1=177 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x00000d2=210 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000189=393 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x00001aa=426 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x0000261=609 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1374042 pixels
@0x003867c=231036 : <JPEG_EOI> JPEG length 231038
-0x003867d=231037 : END OF FILE
@000000000=0 : Start of JPEG baseline DCT compressed primary
image [1418x969] length 231038 (APP0)
-0x003867d=231037 : End of JPEG primary image data
Number of images = 1
File Format = JPEG/APP0/JFIF
File Type = JPEG
File Size = 231183
@000000000=0 : <JPEG_SOI>
@0x0000002=2 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x000000b=11 : Version = 1.2
@0x000000d=13 : Units = 'aspect ratio'
@0x000000e=14 : Xdensity = 1
@0x0000010=16 : Ydensity = 1
@0x0000012=18 : XThumbnail = 0
@0x0000013=19 : YThumbnail = 0
@0x0000013=19 : </JPEG_APP0>
@0x0000014=20 : <JPEG_APP1> 0xffe1 length 143,
'http://ns.adobe.com/xap/1.0/' - unknown format - (not dumped: use -A)
-0x00000a4=164 : </JPEG_APP1>
@0x00000a5=165 : <JPEG_DQT> length 67
@0x00000ea=234 : <JPEG_DQT> length 67
@0x000012f=303 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1418, height=969
@0x0000142=322 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x0000163=355 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x000021a=538 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x000023b=571 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002f2=754 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1374042 pixels
@0x003870d=231181 : <JPEG_EOI> JPEG length 231183
-0x003870e=231182 : END OF FILE
@000000000=0 : Start of JPEG baseline DCT compressed primary
image [1418x969] length 231183
-0x003870e=231182 : End of JPEG primary image data
Number of images = 1
File Format = JPEG/APP0/JFIF/APP1
It looks like what I did got into the tag: JPEG_APP1, while not
File Type = JPEG
File Size = 438694
@000000000=0 : <JPEG_SOI>
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
[...]
Did I miss something or can something be changed to get there?
I tried to have a look at the mentioned testcase but have not been
able to understand how to switch segment or how segments are chosen in
first place.
Any idea?
Thank you,
Andrea
On Sat, Apr 28, 2018 at 3:15 AM, Bruno P. Kinoshita
Post by Bruno P. Kinoshita
Hi Martin,
Post by Martin Gainty
if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool
It's actually Andrea who is working with comments & JPEG images. I was just trying to help him, assuming he wants/needs to do that in Java. He pointed that he could do that with exiftool too (see previous e-mails in the thread for more).
@Andrea, see Martin's code in the e-mail below.
Thanks Martin!
Bruno
________________________________
Sent: Saturday, 28 April 2018 5:38 AM
Subject: Re: [imaging] Comment tag problem
Bruno
if your requirement is to insert a comment regardless of Java being installed why not insert a XMP comment into JPEG or GIF using exiv2 tool
http://www.exiv2.org/manpage.html
Exiv2 utility manual - Image metadata library and tools<http://www.exiv2.org/manpage.html>
www.exiv2.org
Open Source Exif, IPTC and XMP metadata library and tools with Exif MakerNote and read/write support
MG>see below
________________________________
Sent: Friday, April 27, 2018 8:39 AM
To: Commons Users List
Subject: Re: [imaging] Comment tag problem
Hi Andrea!
Today spent some minutes with Eclipse and the code base, plus exiftool, to see where that comment was coming from.
That COM, or Comment, that you see in exiftool output is not exactly a metadata tag. It is actually a JPEG Segment. Sorry for the other suggestions.
As far as I know, we are not able to change the segments, but only the metadata within the TIFF/EXIF directories & tags [2].
You can still use comments if that's OK, but not sure how you would achieve adding the Comment in Java.
MG>testXMPInsert borrowed from JpegXmpRewriteTest.java
{
// test insert
String newXmpXml = "comment";
//subin your fileName to imageFile.getName()
File updated = createTempFile(imageFile.getName() + ".", ".jpg");
OutputStream os = null;
try
{
os = new FileOutputStream(updated);
os = new BufferedOutputStream(os);
new org.apache.sanselan.formats.jpeg..xmp.JpegXmpRewriter().updateXmpXml(
org.apache.sanselan.common.byteSources.ByteSourceFile(noXmpFile), os,
newXmpXml);
} finally
{
os.close();
os = null;
}
// Debug.debug("Source Segments:");
// new JpegUtils().dumpJFIF(new ByteSourceFile(updated));
String outXmp = new org.apache.sanselan.formats.jpeg.JpegImageParser().getXmpXml(
new ByteSourceFile(updated), params);
assertNotNull(outXmp);
assertEquals(outXmp, newXmpXml);
}
MG>please confirm this works for you
<groupId>org.apache.sanselan</groupId>
<artifactId>sanselan</artifactId>
<version>0.97-incubator</version>
Bruno
MG>?
MG>Martin-
[1] http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0
Writing comments<http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3893.0>
u88.n24.queensu.ca
Writing comments
[2] https://issues.apache.org/jira/browse/IMAGING-55
________________________________
Sent: Thursday, 26 April 2018 8:02 PM
Subject: Re: [imaging] Comment tag problem
Post by Martin Gainty
I normally use exiftool to compare what imaging is producing. The htmldump is quite useful.
I just ran the normal info extraction and here you see the comment I
ExifTool Version Number : 10.94
File Name : 109_Background.jpg
Directory : .
File Size : 428 kB
File Modification Date/Time : 2018:03:31 11:01:51+02:00
File Access Date/Time : 2018:04:26 08:59:06+02:00
File Inode Change Date/Time : 2018:03:31 11:01:56+02:00
File Permissions : rw-rw-r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
JFIF Version : 1.01
Resolution Unit : inches
X Resolution : 96
Y Resolution : 96
Image Width : 1608
Image Height : 901
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 1608x901
Megapixels : 1.4
Post by Martin Gainty
I thought you had to create the tag in Java, but if you can use other tools and it's easier for you, then that might be the best option.
Yes, I do have to recreate it in java. I was just trying to use other
tools to check what the comment tag is.
Do you have an idea on how to create the above Comment tag?
Post by Martin Gainty
Otherwise you can create pretty much any other metadata tag you'd like with some Java coding.
That is what I would love to end up with.
Thanks a ton,
Andrea
Post by Martin Gainty
________________________________
Sent: Thursday, 26 April 2018 7:15 PM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
Post by Bruno P. Kinoshita
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.
exiftool -comment='mycomment'
creates exaclty the comment I am not able to reproduce. Do you know
what that is?
Post by Bruno P. Kinoshita
If you really need to match that tag, then I think you should be able to create your own custom metadata entry.
I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)
I will try again. I tried already that path, but since it asks me for
a tag (integer) I then end up to have it named as the tag I am trying
to substitute...
Thanks,
Andrea
Post by Bruno P. Kinoshita
Hope that helps,
Bruno
[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java
________________________________
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem
Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.
The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section
and under start section I find
comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
and
exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000
both not the same as what i am looking for.
I have been able to print the following information through an
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694
So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.
Any help is most appreciated,
Thanks,
Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------

To unsubscribe, e-mail: user-***@commons.apache.org

For additional commands, e-mail: user-***@commons.apache.org

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

Martin Gainty
2018-04-26 12:43:24 UTC
Permalink
that would work for embedding comment tag into images which conform to JPEG and TIFF formats


if your requirement includes embedding tag into GIF image format you will want to consider Adobe XMP
https://docs.oracle.com/cd/B19306_01/appdev.102/b14302/ch_metadata.htm

5 Working with Metadata in Images - Oracle<https://docs.oracle.com/cd/B19306_01/appdev.102/b14302/ch_metadata.htm>
docs.oracle.com
5 Working with Metadata in Images. Image files can contain information about the content of the images, the image rasters, and image metadata. In general, data about data is referred to as metadata.


HTH

Martin
___________
________________________________
From: Bruno P. Kinoshita <***@yahoo.com.br.INVALID>
Sent: Thursday, April 26, 2018 2:57 AM
To: Commons Users List
Subject: Re: [imaging] Comment tag problem

Hi Andrea,

The EXIF tags in imaging should match what's in this page:
https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
EXIF Tags - Queen's University<https://sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html>
sno.phy.queensu.ca
EXIF Tags. EXIF stands for "Exchangeable Image File Format". This type of information is formatted according to the TIFF specification, and may be found in JPG, TIFF, PNG, JP2, PGF, MIFF, HDP, PSP and XCF images, as well as many TIFF-based RAW images, and even some AVI and MOV videos.




Which contains the XPComment and UserComment tags you mentioned, but no equivalent to the other comment one.


If you really need to match that tag, then I think you should be able to create your own custom metadata entry.

I think [1] the ExifRewriter and its test class have some code that shows how to rewrite metadata. Find the directory (TiffOutputDirectory.java) with the metadata fields, perhaps remove the UserComment/XPComment if necessary, and then add a new field (TiffOutputField.java), with your metadata tag (TagInfo.java)


Hope that helps,
Bruno


[1]
https://github.com/apache/commons-imaging/blob/master/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java

________________________________
From: andrea antonello <***@gmail.com>
To: Commons Users List <***@commons.apache.org>
Sent: Thursday, 26 April 2018 1:46 AM
Subject: Re: [imaging] Comment tag problem



Hi Bruno,
thanks for your reply.
Post by Bruno P. Kinoshita
I think you tried to include screenshots? If so, it doesn't work very well in this mailing list.
ohh, I didn't figure and didn't notice.
Post by Bruno P. Kinoshita
Could you try adding as attachment, or upload them, or use plain text to describe the issue? I recently had to work on the tags for some TIFF & JPEG metadata in [imaging], so hopefully we will be able to locate the right tag.
Fantastic. I investigated further but am still not able to solve this.

The tag I would like to update is one that produces (at least this is
what I read in the imagemagick image info) a section

Properties:

and under start section I find

comment: GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000

The most similar result I have been able to produce with the tags is:

exif:UserComment:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000

and

exif:WinXP-Comments:GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000

both not the same as what i am looking for.


I have been able to print the following information through an
application called exifprobe:

@0x0000002=2 : <JPEG_COM> length 137:
''GEO-Information,46.5640616313:11.523790723,46.5640616313:11.5093674258,46.5585048222:11.523790723,46.5585048222:11.5093674258,0.000000\0''
@0x000008d=141 : <JPEG_APP0> 0xffe0 length 16, 'JFIF'
@0x0000096=150 : Version = 1.1
@0x0000098=152 : Units = 'dots/inch'
@0x0000099=153 : Xdensity = 96
@0x000009b=155 : Ydensity = 96
@0x000009d=157 : XThumbnail = 0
@0x000009e=158 : YThumbnail = 0
@0x000009e=158 : </JPEG_APP0>
@0x000009f=159 : <JPEG_DQT> length 67
@0x00000e4=228 : <JPEG_DQT> length 67
@0x0000129=297 : <JPEG_SOF_0> length 17, 8 bits/sample,
components=3, width=1608, height=901
@0x000013c=316 : <JPEG_DHT> length 31 table class = 0 table id = 0
@0x000015d=349 : <JPEG_DHT> length 181 table class = 0 table id = 1
@0x0000214=532 : <JPEG_DHT> length 31 table class = 1 table id = 0
@0x0000235=565 : <JPEG_DHT> length 181 table class = 1 table id = 1
@0x00002ec=748 : <JPEG_SOS> length 12 start of JPEG data, 3
components 1448808 pixels
@0x006b1a4=438692 : <JPEG_EOI> JPEG length 438694

So I think this (JPEG_COM) is not an exif tag as I had been told. I am
guessing this is reflected by the library's ComSegment class, but I
could not find any documentation or testcase which would tell me what
it is and how to rewrite/update it.

Any help is most appreciated,
Thanks,

Andrea
Post by Bruno P. Kinoshita
CheersBruno
Sent: Wednesday, 25 April 2018 1:56 AM
Subject: [imaging] Comment tag problem
Hi, I need some help to find the right tag to use to recreate a tag in a
jpeg file.
The tag I need should be under "Properties"
and be named: comment
I have tried to use user_comment and xpcomment, but they produce something
Can anyone tell me which tag I can use to generate the "comment" tag?
Thanks for any hint,
Best regards,
Andrea
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@commons.apache.org
For additional commands, e-mail: user-***@commons.apache.org

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