in reply to Re: tr not working
in thread tr not working
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: tr not working
by ultranerds (Hermit) on Jul 07, 2009 at 12:14 UTC | |
by Anonymous Monk on Jul 07, 2009 at 12:41 UTC | |
by mzedeler (Pilgrim) on Jul 07, 2009 at 18:59 UTC |