Mac line feed problem

Started by Archive, May 12, 2010, 08:53:53 AM

Previous topic - Next topic

Archive

[Originally posted by eljetico on 2006-03-23 14:30:09-08]

Hello. I'm having some difficulty with Mac-originated returns/linefeeds in my images, particularly when attempting to set new values/overwrite the data.

By way of example, this is what I get after placing two returns/linefeeds into the Description and testing the result:

Under the XMP group,

Code:
---- XMP ----

Description: This is data before the line feed

This is data after the line feed

Under the IPTC group,

---- IPTC ----

ApplicationRecordVersion         : 2

This is data after the line feed : This is data before the line feed

SpecialInstructions              : Instructions go here

...somehow the IPTC tags are getting confused, which causes problems when trying to address the IPTC:Caption-Abstract tag to set a new value.

I guess I could target the XMP Description tag instead but I'd rather not...

I'm using v5.05 so things may have changed since. Any ideas?

Many thanks for the tool and your help with this

Archive

[Originally posted by exiftool on 2006-03-23 14:51:42-08]

There should be no problem with ExifTool putting whatever linefeeds you want in any tags.  This shouldn't have

If you are having problems, it could be with the terminal and how it handles newlines.  Try writing the description to a file with an editor, then using "exiftool -caption-abstract'<=file.txt' image.jpg" to set the IPTC Caption-Abstract.  I just tried this myself (on my Mac) and it works fine with mac-sytle carriage returns.  Note that when you extract the tag again the exiftool script will convert the newlines (and any other control characters) to "." unless you use the -b option.  But if you extract with "exiftool -caption-abstract -b image.jpg > newfile.txt", you should get back exactly what you put in.

Archive

[Originally posted by eljetico on 2006-03-23 15:11:45-08]

Thanks for the quick response!

The problem is occurring in my Perl script rather than resulting from the terminal. The output above comes simply from calling

Code:
exiftool->Options( Group0 => [ 'IPTC', 'XMP' ] );
$info = $exiftool->ImageInfo($filepath);

on the image in $filepath.

If I use:

Code:
$exiftool->setNewValue('Caption-Abstract', 'New description text', Group=>'IPTC');
$exifTool->WriteInfo($filepath, $newfilepath);

...I got an error, having to go back into Photoshop to clear the linefeeds before the writeinfo would work.

Archive

[Originally posted by exiftool on 2006-03-23 15:27:43-08]

I think I need to see the code you used to write the caption that is causing the problems, and the resulting image if possible.  I can't think of anything obvious that could be causing the problem you observe, so I will need some more details.

Archive

[Originally posted by eljetico on 2006-03-23 16:12:57-08]

I used Photoshop to write the original caption, containing linefeeds, rather than a script. The code to read and over-write the caption is as stated. I can send you a sample image - where to?

Archive

[Originally posted by exiftool on 2006-03-23 16:28:11-08]

I understand now.  You can send the sample image to philharvey66 at gmail.com

Thanks.

Archive

[Originally posted by exiftool on 2006-03-23 23:01:27-08]

Thanks for the sample.  I ran the following script using ExifTool 5.05 on the image you sent:

Code:
#!/usr/bin/perl -w
use strict;
BEGIN { unshift @INC, 'Image-ExifTool-5.05/lib' }
use Image::ExifTool;
my $e = new Image::ExifTool;
$e->Options(Group0 => ['IPTC','XMP']);
my $info = $e->ImageInfo('line_feed_image.jpg');
my $capt = $$info{'Caption-Abstract'};
$capt =~ s/\x0d/\(CR\)/g;
$capt =~ s/\x0a/\(LF\)/g;
print "The caption is: $capt\n";
$e->SetNewValue('Caption-Abstract', 'New description text',Group=>'IPTC');
unlink 'b.jpg';
$e->WriteInfo('line_feed_image.jpg', 'b.jpg');
$info = $e->ImageInfo('b.jpg');
$capt = $$info{'Caption-Abstract'};
$capt =~ s/\x0d/\(CR\)/g;
$capt =~ s/\x0a/\(LF\)/g;
print "The new caption is: $capt\n";
# end

The output was:

Code:
The caption is: This is data before the line feed(CR)(CR)This is data after the line feed
The new caption is: New description text

I don't see anything wrong.  Is this not the results you get?

Archive

[Originally posted by exiftool on 2006-03-24 12:18:38-08]

The issue was resolved in an e-mail exchange.  It wasn't a problem with ExifTool, but a problem with the way Tim was handling the carriage returns.

- Phil