Revision 364
- Date:
- 2013/06/18 16:37:39
- Files:
Legend:
- Added
- Removed
- Modified
-
koi8/core/GNUmakefile
1134 1134 CASCADE \ 1135 1135 COMP_CACHE_ENABLED \ 1136 1136 COMP_TIMINGS_DISABLE \ 1137 COMPOSITE \ 1137 1138 CONF \ 1138 1139 CONTENIDO_VERSION \ 1139 1140 CONVERT \ -
koi8/core/lib/Contenido/File.pm
188 188 189 189 my ($prop) = exists $opts{prop} && ref $opts{prop} ? ($opts{prop}) : $attr ? grep { $_->{attr} eq $attr } $object->structure : (undef); 190 190 return unless ref $prop; 191 192 warn Dumper \%opts if $DEBUG; 191 193 my @preview = exists $prop->{'preview'} && ref $prop->{'preview'} eq 'ARRAY' ? @{$prop->{'preview'}} : exists $prop->{'preview'} && $prop->{'preview'} ? ($prop->{'preview'}) : (); 192 194 my @crops = exists $prop->{'crop'} && ref $prop->{'crop'} eq 'ARRAY' ? @{$prop->{'crop'}} : exists $prop->{'crop'} && $prop->{'crop'} ? ($prop->{'crop'}) : (); 193 195 my @shrinks = exists $prop->{'shrink'} && ref $prop->{'shrink'} eq 'ARRAY' ? @{$prop->{'shrink'}} : exists $prop->{'shrink'} && $prop->{'shrink'} ? ($prop->{'shrink'}) : (); … … 243 245 if ( exists $prop->{transform} && ref $prop->{transform} eq 'ARRAY' && scalar @{$prop->{transform}} == 2 && $prop->{transform}[0] =~ /(crop|resize|shrink)/ ) { 244 246 my $c_line; 245 247 if ( $prop->{transform}[0] eq 'resize' ) { 246 $c_line = $state->{'convert_binary'}.' -resize \''.$prop->{transform}[1].'\' -quality 80 '.$filename_tmp.'.'.$ext.' '.$filename_tmp.'.transformed.'.$ext; 248 $c_line = $state->{'convert_binary'}.' -adaptive-resize \''.$prop->{transform}[1].'>\' -quality 100 '.$filename_tmp.'.'.$ext.' '.$filename_tmp.'.transformed.'.$ext; 247 249 } elsif ( $prop->{transform}[0] eq 'crop' ) { 248 250 my $shave_string; 249 251 my ($nwidth, $nheight) = $prop->{transform}[1] =~ /(\d+)x(\d+)/i ? ($1, $2) : (0, 0); … … 269 271 return undef; 270 272 } 271 273 } 272 $c_line = $state->{'convert_binary'}.' -geometry \''.$prop->{transform}[1].'!\' -quality 80 '.$filename_tmp.'.shaved.'.$ext.' '.$filename_tmp.'.transformed.'.$ext; 274 $c_line = $state->{'convert_binary'}.' -adaptive-resize \''.$prop->{transform}[1].'!\' -quality 100 '.$filename_tmp.'.shaved.'.$ext.' '.$filename_tmp.'.transformed.'.$ext; 273 275 } elsif ( $prop->{transform}[0] eq 'shrink' ) { 274 $c_line = $state->{'convert_binary'}.' -geometry \''.$prop->{transform}[1].'!\' -quality 80 '.$filename_tmp.'.'.$ext.' '.$filename_tmp.'.transformed.'.$ext; 276 $c_line = $state->{'convert_binary'}.' -adaptive-resize \''.$prop->{transform}[1].'!\' -quality 100 '.$filename_tmp.'.'.$ext.' '.$filename_tmp.'.transformed.'.$ext; 275 277 } 276 278 my $result = `$c_line`; 277 279 $transformed = 1; 278 280 unlink $filename_tmp.'.shaved.'.$ext if -e $filename_tmp.'.shaved.'.$ext; 279 281 } 280 282 283 if ( exists $opts{watermark} && $opts{watermark} ) { 284 my $gravity = delete $opts{gravity} || 'Center'; 285 my $source = $transformed ? $filename_tmp.'.transformed.'.$ext : $filename_tmp.'.'.$ext; 286 my $target = $filename_tmp.'.transformed.'.$ext; 287 my $offset = delete $opts{offset} || '+0+0'; 288 my $c_line = $state->{'composite_binary'}." -geometry $offset -gravity $gravity -quality 99 $opts{watermark} $source $target"; 289 warn "Watermark: $c_line\n" if $DEBUG; 290 my $result = `$c_line`; 291 $transformed = 1; 292 } 293 281 294 my $IMAGE; 282 295 my $stored = $transformed ? store($filename.'.'.$ext, $filename_tmp.'.transformed.'.$ext) : store($filename.'.'.$ext, $filename_tmp.'.'.$ext); 283 296 if ( $stored ) { … … 298 311 } 299 312 300 313 foreach my $suffix (@preview) { 301 my $c_line = $state->{'convert_binary'}.' -geometry \''.$suffix.'\' -quality 80 '.$filename_tmp.'.'.$ext.' '.$filename_tmp.'.'.$suffix.'.'.$ext; 314 my $c_line = $state->{'convert_binary'}.' -resize \''.$suffix.'>\' -quality 90 '.$filename_tmp.'.'.$ext.' '.$filename_tmp.'.'.$suffix.'.'.$ext; 302 315 my $result = `$c_line`; 303 316 304 317 if (length $result > 0) { … … 344 357 } 345 358 } 346 359 347 my $c_line = $state->{'convert_binary'}.' -geometry \''.$suffix.'!\' -quality 80 '.$filename_tmp.'.shaved.'.$ext.' '.$filename_tmp.'.'.$suffix.'.'.$ext; 360 my $c_line = $state->{'convert_binary'}.' -geometry \''.$suffix.'!\' -quality 90 '.$filename_tmp.'.shaved.'.$ext.' '.$filename_tmp.'.'.$suffix.'.'.$ext; 348 361 my $result = `$c_line`; 349 362 350 363 if (length $result > 0) { … … 371 384 ########## SHRINKS 372 385 foreach my $suffix (@shrinks) { 373 386 374 my $c_line = $state->{'convert_binary'}.' -geometry \''.$suffix.'!\' -quality 80 '.$filename_tmp.'.'.$ext.' '.$filename_tmp.'.'.$suffix.'.'.$ext; 387 my $c_line = $state->{'convert_binary'}.' -geometry \''.$suffix.'!\' -quality 90 '.$filename_tmp.'.'.$ext.' '.$filename_tmp.'.'.$suffix.'.'.$ext; 375 388 my $result = `$c_line`; 376 389 377 390 if (length $result > 0) { -
koi8/core/lib/Contenido/Object.pm
1138 1138 # 1139 1139 # ������ �������������: 1140 1140 # $document->_store_image( INPUT, attr => 'fieldname' ) 1141 # $document->_store_image( INPUT, prop => $prophash ) 1141 1142 # ---------------------------------------------------------------------------- 1142 1143 sub _store_image { 1143 1144 my $self = shift; … … 1146 1147 my $input = shift; 1147 1148 my (%opts) = @_; 1148 1149 1149 return Contenido::File::store_image( $input, object => $self, attr => $opts{attr}, prop => $opts{prop} ); 1150 return Contenido::File::store_image( $input, object => $self, %opts ); 1150 1151 } 1151 1152 1152 1153 # ---------------------------------------------------------------------------- -
koi8/core/lib/Contenido/State.pm.proto
77 77 $self->{files_dir} = [split /\s+/ms, $files_dir]; 78 78 } 79 79 80 $self->{composite_binary} = '@COMPOSITE@'; 80 81 $self->{convert_binary} = '@CONVERT@'; 81 82 $self->{file_web_storage} = lc('@FILE_WEB_STORAGE@'); 82 83 -
koi8/core/project-default.mk
205 205 echo 'exit 1;'; \ 206 206 fi;} 207 207 208 COMPOSITE = ${shell export PATH=${LOCAL}/bin:$${PATH}; which composite} 208 209 CONVERT = ${shell export PATH=${LOCAL}/bin:$${PATH}; which convert} 209 210 ifeq (${CONVERT},) 210 211 ${error ERROR: No executable convert found, you need to install ImageMagick first}