Re: [sanselan] Writing EXIF data to JPEG
Sorry about the website, I plan on fixing it with the 1.0 release. UserComment is one of the uglier cases, as it uses that GPS string type with a special prefix to distinguish character encodings. Try using TagInfo.Text's encodeValue() method to convert the String to byte[], then pass that to new TiffOutputField(ExifTagConstants.EXIF_TAG_USER_COMMENT, ExifTagConstants.EXIF_TAG_USER_COMMENT.fieldTypes, bytes.length, bytes); Thanks for the help, I can now save a usercomment and the artist field successfully. There is just one tiny little problem that I am now requesting some help for. I am able to put international characters into the artist and usercomment field, however, the usercomment field is not shown in Windows Explorer, but the artist is. I have been searching the internet and found that the byteorder should be little_endian, but that was the default case. Is there some way to put in internation characters in the usercomment field? Here is my current code. I altered yours a bit: TiffOutputSet set = new TiffOutputSet(TiffConstants.BYTE_ORDER_LITTLE_ENDIAN); byte[] bytesComment = ExifTagConstants.EXIF_TAG_USER_COMMENT.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperCommentÅ, set.byteOrder); byte[] bytesAuthor = TiffTagConstants.TIFF_TAG_ARTIST.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperAuthorÅ, set.byteOrder); TiffOutputField commentField = new TiffOutputField(ExifTagConstants.EXIF_TAG_USER_COMMENT, ExifTagConstants.EXIF_TAG_USER_COMMENT.dataTypes[0], bytesComment.length, bytesComment); TiffOutputField authorField = new TiffOutputField(TiffTagConstants.TIFF_TAG_ARTIST, TiffTagConstants.TIFF_TAG_ARTIST.dataTypes[0], bytesAuthor.length, bytesAuthor); set.getOrCreateExifDirectory().add(commentField); set.getOrCreateRootDirectory().add(authorField); Thanks on beforehand, and thanks for the help so far! /Kasper - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
[daemon] ftp access code as service
Hi, I am trying to run a piece of java code that uses apache commons net library to connect to a folder and download some files as a service. The service is installed ok and runs but hangs at the part where it has to connect to a ftp server, no error, no timeouts, just goes silent. Cheers, - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [daemon] ftp access code as service
On 03/08/2012 12:25 PM, Ahsan Ikram wrote: Hi, I am trying to run a piece of java code that uses apache commons net library to connect to a folder and download some files as a service. Since you are speaking about 'folder' I presume this is on windows, right? The service is installed ok and runs but hangs at the part where it has to connect to a ftp server, no error, no timeouts, just goes silent. Check your firewall. Services do not have GUI so the firewall can't ask you about consent. Regards -- ^TM - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [sanselan] Writing EXIF data to JPEG
On Thu, Mar 8, 2012 at 2:45 PM, Kasper Føns kfo...@gmail.com wrote: Sorry about the website, I plan on fixing it with the 1.0 release. UserComment is one of the uglier cases, as it uses that GPS string type with a special prefix to distinguish character encodings. Try using TagInfo.Text's encodeValue() method to convert the String to byte[], then pass that to new TiffOutputField(ExifTagConstants.EXIF_TAG_USER_COMMENT, ExifTagConstants.EXIF_TAG_USER_COMMENT.fieldTypes, bytes.length, bytes); Thanks for the help, I can now save a usercomment and the artist field successfully. There is just one tiny little problem that I am now requesting some help for. I am able to put international characters into the artist and usercomment field, however, the usercomment field is not shown in Windows Explorer, but the artist is. I have been searching the internet and found that the byteorder should be little_endian, but that was the default case. Is there some way to put in internation characters in the usercomment field? Here is my current code. I altered yours a bit: TiffOutputSet set = new TiffOutputSet(TiffConstants.BYTE_ORDER_LITTLE_ENDIAN); byte[] bytesComment = ExifTagConstants.EXIF_TAG_USER_COMMENT.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperCommentĹ, set.byteOrder); byte[] bytesAuthor = TiffTagConstants.TIFF_TAG_ARTIST.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperAuthorĹ, set.byteOrder); TiffOutputField commentField = new TiffOutputField(ExifTagConstants.EXIF_TAG_USER_COMMENT, ExifTagConstants.EXIF_TAG_USER_COMMENT.dataTypes[0], bytesComment.length, bytesComment); TiffOutputField authorField = new TiffOutputField(TiffTagConstants.TIFF_TAG_ARTIST, TiffTagConstants.TIFF_TAG_ARTIST.dataTypes[0], bytesAuthor.length, bytesAuthor); set.getOrCreateExifDirectory().add(commentField); set.getOrCreateRootDirectory().add(authorField); Thanks on beforehand, and thanks for the help so far! /Kasper I wouldn't count on Windows Explorer to give you the right values. Rather check it against exiftool (www.sno.phy.queensu.ca/~phil/exiftool/): exiftool -a -g1 -u image.tiff Windows Explorer also likes the XP values (eg. EXIF_TAG_XPCOMMENT, EXIF_TAG_XPAUTHOR), maybe try writing those as well? Damjan - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [sanselan] Writing EXIF data to JPEG
I wouldn't count on Windows Explorer to give you the right values. Rather check it against exiftool (www.sno.phy.queensu.ca/~phil/exiftool/): exiftool -a -g1 -u image.tiff Windows Explorer also likes the XP values (eg. EXIF_TAG_XPCOMMENT, EXIF_TAG_XPAUTHOR), maybe try writing those as well? Damjan Sorry for asking so many questions :( I hope it is okay. Hmm. It does not seem like the XP values work. They do not show correctly. Anyways, I tried using the code I sent you without special characters: byte[] bytesComment = ExifTagConstants.EXIF_TAG_USER_COMMENT.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperComment, set.byteOrder); byte[] bytesAuthor = TiffTagConstants.TIFF_TAG_ARTIST.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperAuthor, set.byteOrder); TiffOutputField commentField = new TiffOutputField(ExifTagConstants.EXIF_TAG_USER_COMMENT, ExifTagConstants.EXIF_TAG_USER_COMMENT.dataTypes[0], bytesComment.length, bytesComment); TiffOutputField authorField = new TiffOutputField(TiffTagConstants.TIFF_TAG_ARTIST, TiffTagConstants.TIFF_TAG_ARTIST.dataTypes[0], bytesAuthor.length, bytesAuthor); set.getOrCreateExifDirectory().add(commentField); set.getOrCreateRootDirectory().add(authorField); Then the exif tools shows (and so do windows explorer): IFD0 Artist : KasperAuthor ExifIFD User Comment: KasperComment JFIF JFIF Version: 1.01 However, trying the same, but adding an å to KasperComment and KasperAuthor gives the following: IFD0 Artist : KasperAuthorå ExifIFD User Comment: 䭡獰敲䍯浭敮瓃 JFIF JFIF Version: 1.01 It seems the UserComment has been destroyed. Now it is suddenly chinese characters!? Windows explorer shows the artist but not the usercomment. Is this something to do with ExifDirectory vs RootDirectory? /Kasper - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [sanselan] Writing EXIF data to JPEG
Windows Explorer also likes the XP values (eg. EXIF_TAG_XPCOMMENT, EXIF_TAG_XPAUTHOR), maybe try writing those as well? Hmm. You seem to be right that explorer likes the XP values. However, I can't figure out how to write to them. I can see that they are BYTE values, but how to convert a string into the wanted bytes? This is the result I get: IFD0 XP Comment : 態灳牥潃浭湥t XP Author : 態灳牥畁桴牯 With this code: byte[] bytesComment = ExifTagConstants.EXIF_TAG_XPCOMMENT.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperComment, set.byteOrder); byte[] bytesAuthor = ExifTagConstants.EXIF_TAG_XPAUTHOR.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperAuthor, set.byteOrder); TiffOutputField commentField = new TiffOutputField(ExifTagConstants.EXIF_TAG_XPCOMMENT, ExifTagConstants.EXIF_TAG_XPCOMMENT.dataTypes[0], bytesComment.length, bytesComment); TiffOutputField authorField = new TiffOutputField(ExifTagConstants.EXIF_TAG_XPAUTHOR, ExifTagConstants.EXIF_TAG_XPAUTHOR.dataTypes[0], bytesAuthor.length, bytesAuthor); set.getOrCreateRootDirectory().add(commentField); set.getOrCreateRootDirectory().add(authorField); /Kasper - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [sanselan] Writing EXIF data to JPEG
On Thu, Mar 8, 2012 at 7:02 PM, Kasper Føns kfo...@gmail.com wrote: Windows Explorer also likes the XP values (eg. EXIF_TAG_XPCOMMENT, EXIF_TAG_XPAUTHOR), maybe try writing those as well? Hmm. You seem to be right that explorer likes the XP values. However, I can't figure out how to write to them. I can see that they are BYTE values, but how to convert a string into the wanted bytes? This is the result I get: IFD0 XP Comment : 態灳牥潃浭湥t XP Author : 態灳牥畁桴牯 With this code: byte[] bytesComment = ExifTagConstants.EXIF_TAG_XPCOMMENT.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperComment, set.byteOrder); byte[] bytesAuthor = ExifTagConstants.EXIF_TAG_XPAUTHOR.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperAuthor, set.byteOrder); TiffOutputField commentField = new TiffOutputField(ExifTagConstants.EXIF_TAG_XPCOMMENT, ExifTagConstants.EXIF_TAG_XPCOMMENT.dataTypes[0], bytesComment.length, bytesComment); TiffOutputField authorField = new TiffOutputField(ExifTagConstants.EXIF_TAG_XPAUTHOR, ExifTagConstants.EXIF_TAG_XPAUTHOR.dataTypes[0], bytesAuthor.length, bytesAuthor); set.getOrCreateRootDirectory().add(commentField); set.getOrCreateRootDirectory().add(authorField); /Kasper There's no easy way in Sanselan 0.97: the XP fields use little-endian UTF-16 (no matter what the byte ordering of the file is, thanks Microsoft you useless @*#%!) so try this: byte[] rawBytes = KasperAuthor.getBytes(UTF-16LE); byte[] nullTerminatedBytes = new byte[rawBytes.length + 2]; TiffOutputField authorField = new TiffOutputField(ExifTagConstants.EXIF_TAG_XPAUTHOR, ExifTagConstants.EXIF_TAG_XPAUTHOR.dataTypes[0], nullTerminatedBytes.length, nullTerminatedBytes); Damjan - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [sanselan] Writing EXIF data to JPEG
On Thu, Mar 8, 2012 at 6:39 PM, Kasper Føns kfo...@gmail.com wrote: I wouldn't count on Windows Explorer to give you the right values. Rather check it against exiftool (www.sno.phy.queensu.ca/~phil/exiftool/): exiftool -a -g1 -u image.tiff Windows Explorer also likes the XP values (eg. EXIF_TAG_XPCOMMENT, EXIF_TAG_XPAUTHOR), maybe try writing those as well? Damjan Sorry for asking so many questions :( I hope it is okay. Yes it's okay :). Hmm. It does not seem like the XP values work. They do not show correctly. Anyways, I tried using the code I sent you without special characters: byte[] bytesComment = ExifTagConstants.EXIF_TAG_USER_COMMENT.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperComment, set.byteOrder); byte[] bytesAuthor = TiffTagConstants.TIFF_TAG_ARTIST.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, KasperAuthor, set.byteOrder); TiffOutputField commentField = new TiffOutputField(ExifTagConstants.EXIF_TAG_USER_COMMENT, ExifTagConstants.EXIF_TAG_USER_COMMENT.dataTypes[0], bytesComment.length, bytesComment); TiffOutputField authorField = new TiffOutputField(TiffTagConstants.TIFF_TAG_ARTIST, TiffTagConstants.TIFF_TAG_ARTIST.dataTypes[0], bytesAuthor.length, bytesAuthor); set.getOrCreateExifDirectory().add(commentField); set.getOrCreateRootDirectory().add(authorField); Then the exif tools shows (and so do windows explorer): IFD0 Artist : KasperAuthor ExifIFD User Comment : KasperComment JFIF JFIF Version : 1.01 However, trying the same, but adding an å to KasperComment and KasperAuthor gives the following: IFD0 Artist : KasperAuthorå ExifIFD User Comment : 䭡獰敲䍯浭敮瓃 JFIF JFIF Version : 1.01 It seems the UserComment has been destroyed. Now it is suddenly chinese characters!? Windows explorer shows the artist but not the usercomment. Is this something to do with ExifDirectory vs RootDirectory? No, the directory wouldn't affect the output. Sanselan 0.97: * doesn't null-terminate ASCII strings (eg. Artist), so you have to allocate a byte array one element bigger and copy the encoded bytes to it. * uses the system locale for ASCII encoding, which is UTF-16LE on Windows, even though TIFF requires UTF-8 So for ASCII fields instead of using encodeValue(), use getBytes(UTF-8) and copy to a byte array with one more element (so that the last element is null) like I showed you in the previous email. For UserComment what Sanselan does is autodetect the encoding: this will work for ASCII and write ASCII, but in 0.97 it wrongly assumed that the unicode encoding is UTF-8, whereas it's actually UTF-16 with byte ordering depending on the file's byte ordering. So in 0.97 you have to encode this manually yourself using a big hack: byte[] unicodeMarker = new byte[]{ 0x55, 0x4E, 0x49, 0x43, 0x4F, 0x44, 0x45, 0x00 }; byte[] comment = My Comment.getBytes(UTF-16LE); // OR UTF-16BE if the file is big-endian! byte[] bytesComment = new byte[unicodeMarker.length + comment.length]; System.arraycopy(marker, 0, bytesComment, 0, marker.length); System.arraycopy(comment, 0, bytesComment, marker.length, comment.length); TiffOutputField commentField = new TiffOutputField(ExifTagConstants.EXIF_TAG_USER_COMMENT, ExifTagConstants.EXIF_TAG_USER_COMMENT.dataTypes[0], bytesComment.length, bytesComment); We can safely conclude from this that there is many reasons why 1.0 needs to be released, and 0.97 needs to die :). /Kasper Damjan - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [Collections] Circular Buffer
On 8 March 2012 06:38, manoj mokashi manojmoka...@gmail.com wrote: @James : Does the header include a record size ? Yes. I suppose you are wondering why i need to detect the headers if the record size is known. Actually its a corrupted archive in which the header size is correct, but the body size is not, and so i don't know where the body ends and hence where the next header starts. And i do still need to parse the header to get at things like isDirectory, timestamp. @Sebb : I think it should be possible to do this efficiently as the underlying storage is an array. So should i raise a request in JIRA ? I already did: https://issues.apache.org/jira/browse/COLLECTIONS-399 Please review. - 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