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 <brunodepau...@yahoo.com.br.invalid> wrote: > Hi Martin, > > >>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 <mgai...@hotmail.com> > To: Commons Users List <user@commons.apache.org>; Bruno P. Kinoshita > <brunodepau...@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 <brunodepau...@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 <andrea.antone...@gmail.com> > To: Commons Users List <user@commons.apache.org> > Sent: Thursday, 26 April 2018 8:02 PM > Subject: Re: [imaging] Comment tag problem > > > >> 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 > > >> 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? > >> 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 > > >> ________________________________ >> From: andrea antonello <andrea.antone...@gmail.com> >> To: Commons Users List <user@commons.apache.org> >> Sent: Thursday, 26 April 2018 7:15 PM >> Subject: Re: [imaging] Comment tag problem >> >> >> >> Hi Bruno, >> >>> 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. >> >> 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? >> >> >>> 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 >> >> >>> >>> >>> 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 <andrea.antone...@gmail.com> >>> To: Commons Users List <user@commons.apache.org> >>> Sent: Thursday, 26 April 2018 1:46 AM >>> Subject: Re: [imaging] Comment tag problem >>> >>> >>> >>> Hi Bruno, >>> thanks for your reply. >>> >>>> 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. >>> >>>> >>>> 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 >>> >>> >>> >>> >>>> >>>> CheersBruno >>>> >>>> >>>> From: andrea antonello <andrea.antone...@gmail.com> >>>> To: Commons Users List <user@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 >>>> >>>> >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org >>> For additional commands, e-mail: user-h...@commons.apache.org > >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org >>> For additional commands, e-mail: user-h...@commons.apache.org > >> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org >> For additional commands, e-mail: user-h...@commons.apache.org >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org >> For additional commands, e-mail: user-h...@commons.apache.org >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@commons.apache.org > For additional commands, e-mail: user-h...@commons.apache.org > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@commons.apache.org > For additional commands, e-mail: user-h...@commons.apache.org > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@commons.apache.org > For additional commands, e-mail: user-h...@commons.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org