Incompatible encondig with Image::ExifTool

Started by luigifab, March 14, 2011, 02:39:20 PM

Previous topic - Next topic

luigifab

Hello,

I have a big problem :'(
See my script :

#!/usr/bin/perl

use encoding qw(utf8);
use open qw(:std utf8);
use Image::ExifTool;

system 'exiftool -Artist="Azerty" -Copyright="Qwerty" -q -q -fast -overwrite_original /home/fabrice/Bureau/monImage.jpg';

my $exifTool = new Image::ExifTool;
$exifTool->Options(FastScan => 1);
$exifTool->SetNewValue(Artist => 'Wxcvbn');
$exifTool->SetNewValue(Copyright => 'Uiopmlkj');
$exifTool->WriteInfo('/home/fabrice/Bureau/monImage.jpg');


It doesn't work :
Incompatible encoding!
Compilation failed in require at Bureau/et.pl line 5.
BEGIN failed--compilation aborted at Bureau/et.pl line 5


Can you help me please ?

Phil Harvey

#1
Hi,

Your first line (setting the encoding to "utf8") is incompatible with Image-ExifTool because it breaks the ability to treat strings as a series of bytes.

- Phil

Edit:  FYI, here is a link to a perl-porters thread in which Tom Christiansen (co-author of "Programming Perl") discusses the problem, and this thread which concluded the discussion.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

luigifab

Thanks for you reply.
But all problem's have a solution...

This is my program :
- program files are encoded in UTF8 without BOM,
- it using UTF8 characters (é à...),
- it write files using UTF8 characters, so it must write files in UTF8.

So, in my program, I have changed use encoding qw(utf8); use open qw(:std utf8); by use utf8; use open OUT => ':utf8';.
And it works.

http://www.gossamer-threads.com/lists/perl/porters/215382?do=post_view_threaded#215382

luigifab

New code for UTF8 support :

use open(IO => ':encoding(utf8)');
binmode(STDERR, ':utf8');
binmode(STDOUT, ':utf8');
binmode(STDIN, ':utf8');

open(FILE, '>:utf8', '/tmp/azerty');


It works better, but, I don't know if this code is very good.
Moreover ExifTool continue to work.

Stop spaming.
Thanks for your previous help.

Phil Harvey

I can't answer your question about whether or not this technique is good.  I haven't ever done anything like this myself.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).