At 1:42 PM -0400 25/07/01, Katherine Richmond wrote:
>Maybe I have to create a simple text file, copy
>the comment info. into it, and ftp that too. I can name the text file the same
>as the jpeg, but with a .txt file extension. How does that sound?


At 2:20 PM -0400 25/07/01, Scott R. Godin wrote:
>you might think about looking into a way to edit the internal comment in a
>JPEG/JFIF file. :)
>


Just out of interest I poked about a bit in a JPEG file and came up 
with this script:

#!perl-w
use strict;

my ($file,$data,$comment);

$file='Sirius A:Desktop Folder:untitled.jpg';


open (IN, $file);

$data= (<IN>);
($comment,$data)=split(/\n/,$data);
print $data,"\n";
__END__

In JPEGS the comment is stored at the beginning of the file. If I had 
more time I could probably figure out just how much of the file to 
read in to get at the part of the file containing the comment only, 
however the quick and dirty hack above basically splits the file on a 
*newline character which conveniently separates the data from the 
file header, depending on what you need to do you can add to or 
change the contents.

*note  This is platform specific: the value of  '\n'  is fixed, it 
changes from OS to OS-
Mac  \n                 => ASCII 13 ( '\r' )
UNIX   \n              => ASCII 10 ("\012")
DOSish** \n        => '\012'


**(unlesss you acess a file in "text" mode, STDIO translates it to 
(or from) \015\012, depending on whether you're reading or writing.)

HTH

Robin

Reply via email to