Revision 148

Date:
2011/10/06 17:51:31
Author:
ahitrov
Revision Log:
New param transform => ['crop','WxH'] in image field description
More comprehensive libwww
Files:

Legend:

 
Added
 
Removed
 
Modified
  • koi8/core/lib/Contenido/File.pm

     
    214 214 if ( ref $image_info && $image_info->{file_ext} ne $ext ) {
    215 215 rename $filename_tmp.'.'.$ext, $filename_tmp.'.'.$image_info->{file_ext};
    216 216 $ext = $image_info->{file_ext};
    217 } elsif ( !ref $image_info ) {
    218 unlink $filename_tmp.'.'.$ext;
    219 return undef;
    217 220 }
    221 my $transformed;
    222 if ( exists $prop->{transform} && ref $prop->{transform} eq 'ARRAY' && scalar @{$prop->{transform}} == 2 && $prop->{transform}[0] =~ /(crop|resize|shrink)/ ) {
    223 my $c_line;
    224 if ( $prop->{transform}[0] eq 'resize' ) {
    225 $c_line = $state->{'convert_binary'}.' -resize \''.$prop->{transform}[1].'\' -quality 80 '.$filename_tmp.'.'.$ext.' '.$filename_tmp.'.transformed.'.$ext;
    226 } elsif ( $prop->{transform}[0] eq 'crop' ) {
    227 my $shave_string;
    228 my ($nwidth, $nheight) = $prop->{transform}[1] =~ /(\d+)x(\d+)/i ? ($1, $2) : (0, 0);
    229 if ( ($image_info->{width} / $image_info->{height}) > ($nwidth / $nheight) ) {
    230 my $shave_pixels = (($image_info->{width} / $image_info->{height}) - ($nwidth / $nheight)) * $image_info->{height};
    231 $shave_string = ' -shave '.int($shave_pixels / 2).'x0';
    232 } elsif ( ($image_info->{height} / $image_info->{width}) > ($nheight / $nwidth) ) {
    233 my $shave_pixels = (($image_info->{height} / $image_info->{width}) - ($nheight / $nwidth)) * $image_info->{width};
    234 $shave_string = ' -shave 0x'.int($shave_pixels / 2);
    235 }
    236 if ( $shave_string ) {
    237 my $c_line = $state->{"convert_binary"}." $shave_string $filename_tmp.$ext $filename_tmp.shaved.$ext";
    238 my $result = `$c_line`;
    239 if (length $result > 0) {
    240 print "Contenido Error: ��� ������ '$c_line' ��������� ������ '$result' ($@)\n";
    241 return undef;
    242 }
    243 } else {
    244 my $c_line = "cp $filename_tmp.$ext $filename_tmp.shaved.$ext";
    245 my $result = `$c_line`;
    246 if (length $result > 0) {
    247 print "Contenido Error: ��� ������ '$c_line' ��������� ������ '$result' ($@)\n";
    248 return undef;
    249 }
    250 }
    251 $c_line = $state->{'convert_binary'}.' -geometry \''.$prop->{transform}[1].'!\' -quality 80 '.$filename_tmp.'.shaved.'.$ext.' '.$filename_tmp.'.transformed.'.$ext;
    252 } elsif ( $prop->{transform}[0] eq 'shrink' ) {
    253 $c_line = $state->{'convert_binary'}.' -geometry \''.$prop->{transform}[1].'!\' -quality 80 '.$filename_tmp.'.'.$ext.' '.$filename_tmp.'.transformed.'.$ext;
    254 }
    255 my $result = `$c_line`;
    256 $transformed = 1;
    257 unlink $filename_tmp.'.shaved.'.$ext if -e $filename_tmp.'.shaved.'.$ext;
    258 }
    218 259
    219 260 my $IMAGE;
    220 if ( store($filename.'.'.$ext, $filename_tmp.'.'.$ext) ) {
    261 my $stored = $transformed ? store($filename.'.'.$ext, $filename_tmp.'.transformed.'.$ext) : store($filename.'.'.$ext, $filename_tmp.'.'.$ext);
    262 if ( $stored ) {
    221 263 $IMAGE = {};
    222 # hashref slice assigning - ������
    223 @{$IMAGE}{'filename', 'width', 'height'} = (
    224 $filename.'.'.$ext,
    225 Image::Size::imgsize($filename_tmp.'.'.$ext),
    226 );
    264 if ( $transformed && -e $filename_tmp.'.transformed.'.$ext ) {
    265 # hashref slice assigning - ������
    266 @{$IMAGE}{'filename', 'width', 'height'} = (
    267 $filename.'.transformed.'.$ext,
    268 Image::Size::imgsize($filename_tmp.'.'.$ext),
    269 );
    270 unlink $filename_tmp.'.transformed.'.$ext;
    271 } else {
    272 # hashref slice assigning - ������
    273 @{$IMAGE}{'filename', 'width', 'height'} = (
    274 $filename.'.'.$ext,
    275 Image::Size::imgsize($filename_tmp.'.'.$ext),
    276 );
    277 }
    227 278
    228 279 foreach my $suffix (@preview) {
    229 280 my $c_line = $state->{'convert_binary'}.' -geometry \''.$suffix.'\' -quality 80 '.$filename_tmp.'.'.$ext.' '.$filename_tmp.'.'.$suffix.'.'.$ext;
  • koi8/core/ports/all/libwww/GNUmakefile

     
    1 1 ##############################################################################
    2 # $HeadURL: http://svn.dev.rambler.ru/Contenido/trunk/ports/all/libwww/GNUmakefile $
    2 # $HeadURL: http://svn.dev.rambler.ru/Contenido/branches/utf8/ports/all/libwww/GNUmakefile $
    3 3 # $Id: GNUmakefile 175 2006-06-16 12:50:03Z lonerr $
    4 4 ###############################################################################
    5 5
    6 6 #include ../../etc/perl.mk
    7 7
    8 PORTVERSION = 5.805
    8 PORTVERSION = 5.836
    9 9 DISTFILE = ${PORTNAME}-perl-${PORTVERSION}.tar.gz
    10 10 PERL_MAKEMAKER = yes
    11 11 MASTER_CPAN_SUBDIR = LWP