Hi,
$IN->param is a GT::CGI (basically CGI.pm)
I also tried using
use utf8;
..and:
use Encode qw(encode decode);
..but that converts it into even weirder text:
IMAGE BEFORE: $VAR1 = '00001ËéêèëÏÌÎï whatever.jpg';
IMAGE AFTER: $VAR1 = "00001\x{cb}\x{e9}\x{ea}\x{e8}\x{eb}\x{cf}\x{cc}\x{ce}\x{ef}_whatever.jpg";
Any other ideas?
BTW, as I said before - in the same script - it works fine for other functions - just not this one.
Here is the full function, if it may help:
sub MakeThumb {
# print $IN->header;
# print "FOO";
my ($id,$field,$table,$size,$key_field) = @_;
if (!$id || !$field || !$table || !$size) {
use Data::Dumper;
return qq|ERROR: Please pass in ALL values (ID, field, table a
+nd size) - got "$id","$field","$table","$size"| . Dumper(@_);
}
## NEW STUFF
# fix the image, so we convert things like accented charachters to
+ plain charachters
# rename_file_with_odd_charachters(filename,table,field,id)
my ($img) = $IN->param($field) =~ m|([^\\/]+)$|; # grab the i
+mage name...and then assign the path...
use Data::Dumper;
print "IMAGE BEFORE: " . Dumper($img);
# my $img = '00001ËéêèëÏÌÎï whatever.gif';
print STDERR "\n\n$img\n\n";
# $img = decode("utf-8",$img);
$img =~ tr{ÀÂÄàâäÇçÉÊÈËéêèëÏÌÎïìîÖÔÒöôòÜÛÙüûùA-Z?!;«»()" }{aa
+aaaacceeeeeeeeiiiiiioooooouuuuuua-z__________};
print "IMAGE AFTER: " . Dumper($img);
print $IN->header;
print qq|XXX: $img,$table,$field,$id <Br />|;
rename_file_with_odd_charachters_other($img,$table,$field,$id
+);
## END NEW STUFF
# get the actual path to where the file is/will be saved...
my $schema = $DB->table($table)->cols;
my $path = $schema->{$field}->{'file_save_in'};
$path =~ s,/$,,; # get rid of trailing / at end of $path
# now we have the highest ID, lets get the image stuff for thi
+s link.
my $col = $field; # column name where file is held
my $tbl = $DB->table( $table );
my $fh = $tbl->file_info( $col, $id ); # return a glob refere
+nce to the file that you can print <$fh> if you want
my $rel_path;
if ($fh) {
$rel_path = $fh->File_RelativePath;
} # else {
# return @args; }
undef $fh; # explicit close of the filehandle for good measur
+e
# create the variable for where the small image will be held...
my @img_create = split("/",$rel_path);
my $count = $#img_create;
my $rel_path_small = undef; # make sure we have this variable
+ as an undef, otherwise we get probs...
for (my $i = 0; $i < $count; $i++) { $rel_path_small .= $img_
+create[$i] . "/"; }
$rel_path_small .= "small-" . $img_create[$count]; # create t
+he small image name...
my $ReadImage = $path . $rel_path;
my $WriteImage = $path . $rel_path_small;
do_shrink($ReadImage,$WriteImage,$id,$size);
return;
}
The stuff between
## NEW STUFF
and
## END NEW STUFF
..is where the issue is coming up.
TIA
Andy |