Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

TCL(Tool Command Language) Scripting

tcllib jpeg package and JPEG comments ...


Hello,

I used IrfanView to put a comment to a JPEG file and afterwards I used
the tcllib jpeg package to access this comment like this:

    % ::jpeg::getComments $fileName
    ...

I realized, that if the comment has line breaks, the returned comment
contains "\r" (CarriageReturns) instead of newlines.
And at the end of the comment there is an ASCII 0.

Even being confused about the procedure name "getComments" and the
help text:

    Returns a list containing all the JPEG comments found in the file.
Throws an error if file is not a valid JPEG image.

I ask myself, if I have really understood this JPEG comment thing.

Can I have more than one? Does the "\r" instead of "\n" and the "\0"
have undocumentated reasons?

Thanks for any thought and hint!

Best regards,

Martin

Hello again,

I went now experimenting the other way, writing comments with the jpeg
package like this:

    % package require jpeg
    0.3
    % puts '[jpeg::getComments $fileName]'
    ''
    % jpeg::addComment $fileName "abc"
    % jpeg::addComment $fileName "def"
    % puts '[jpeg::getComments $fileName]'
    'abc def'

Then I opened the JPEG file with IrfanView, saved the non-changed
comment and reread the comment inside the tcl shell:

    % puts '[jpeg::getComments $fileName]'
    def } def'
    % puts '[string map {"\r" "\n"} [jpeg::getComments $fileName]]'
    '{abc
    def } def'
    % scan [string index [lindex [jpeg::getComments $fileName] 0] end]
%c
    0

I know, that IrfanView may handle the comments in a wrong way, but
currently I don't have any other bitmap application allowing to view
or to change the JPEG comments!

Can somebody help?

Thanks and best regards,

Martin

On May 29, 5:46 pm, "MartinLemburg@UGS" <martin.lemburg.@gmx.net>
wrote:

The return value of getComments is a list because a jpeg file may have
multiple comment chunks. However most jpeg writers will only write a
single one. The line ending is platform or writer specific. Your use
of single quotes in the examples is confusing the issue somewhat,
single quotes are not special in tcl. 'abc def' is actually a 2
element list as the manual page indicates.

On May 29, 9:06 am, "MartinLemburg@UGS" <martin.lemburg.@gmx.net>
wrote:

What platform? unix/cygwin:
you can try with rd|wrjpegcom from the jpeg package
--->  http://www.ijg.org/files/
xv can display the comments as well.
---> http://www.trilon.com/xv/

this might be of interest:
        http://netzreport.googlepages.com/hidden_data_in_jpeg_files.html

uwe

Hello Uwe,

sorry, but I'm on MS Windows XP and have no running X Server to use
the XV for NT.

But I tried to examine what's going on with different applications
able to read/write JPEG comments.

1. using the utility jhead - depending on the data written to the
comment, the comment can contain any of the line end combinations like
\r\n, \n, or \r. jhead only reads and writes the first comment block.

2. using Exifer - Exifer always uses \r\n (like normal on MS Windows)
and reads/modifies only the last comment block

3. using IrfanView - IrfanView uses \r as line end, reads all comment
blocks, but modifies only the first without removing the other blocks
and appends a \0 at the end

So using the jpeg package to read comments is not necessarily the best
not knowing the comment writing application.
While it's no problem to deal with line ends, the problems are raised
by something like the \0 at the comments end or by the existence of
multiple comment blocks, where only one may be is most current -
depending on the software used to write the comments.

Perhabs it is a good enhancement for the jpeg package to deal inside
with the line ends and probably non-printable characters inside the
comments?
Or are binary comments allowed? I don't think so.

Best regards,

Martin Lemburg
----

On May 30, 7:03 am, "MartinLemburg@UGS" <martin.lemburg.@gmx.net>
wrote:

> So using the jpeg package to read comments is not necessarily the best
> not knowing the comment writing application.

Sounds to me like the best thing to do is to write a tcl application
to read and write the comments, then package it up as a starkit, so
that it would run on all the various platforms.
Hi Larry,

I thought of this too, but ... I don't think I have the time to do
this.

:(

Best regards,

Martin Lemburg

On May 30, 4:52 pm, "Larry W. Virden" <lvir@gmail.com> wrote:

There is no limitation on what may appear in a comment chunk. The jpeg
fields are specified by byte length so there isnt even an ending
sequence to be careful of. I think it would be incorrect for the jpeg
module to not return the exact contents of the field, including nulls.

I think your problem could be handled with a simple string map:

set comments [string map {\r\n \n \r \n \x00 ""} [jpeg::getComments
$file]]

it would also be possible to remove all non ascii characters with a
regsub.

On May 30, 4:03 am, "MartinLemburg@UGS" <martin.lemburg.@gmx.net>
wrote:

Hi and good morning,

yes, you are right a simple "string map" and a "regsub" and everything
is ok.

That's the way I already deal with the JPEG comments returned from the
jpeg package.

The only problem exists, if an application like IrfanView changes the
first comment chunk using all comment chunks, without deleting the
2,...,n th comment chunk.

How should I interpret the probably doubled comment context?

Or if an application like Exifer uses only the last comment chunk, no
matter how many exist.

So - not knowing which chunk was last edited or had a kind of
"priority" while being edited from an application, I don't know
anything about the comment chunks to be used!

But ... like Larry already wrote ... I should write my own JPEG
comment editor and than I should rely only on this selfmade
application!

Or ... like I did with IrfanView ... I have to write e-mails to the
developers maintaining tools like IrfanView or Exifer (last version
from 2005). And there are many other such EXIF, IPCT, comment editing
utilities.

Best regards,

Martin Lemburg

On May 30, 7:59 pm, aar@gmail.com wrote:

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc