Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Re: - Scales down images

by Anonymous Monk
on Dec 19, 2002 at 23:02 UTC ( #221281=note: print w/replies, xml ) Need Help??

in reply to Re: - Scales down images
in thread - Scales down images

I just recently stumbled across this script and it doesn't seem to be working for me.. Is this how i call the script?: -d My/Directory -s 120 Thanks ~Chuckles

Replies are listed 'Best First'.
Re^3: - Scales down images
by swilting (Beadle) on Jan 07, 2009 at 14:33 UTC
    my cgi shrink image it is necessary to use javascript
    #!/usr/bin/perl -wT use strict; use Image::Magick; use CGI qw(:standard escapeHTML); use CGI::Carp qw(fatalsToBrowser); # Declares defaults my ( $dir,$file,$img) = ('/home/renelacroute/imagepublic',"",""); my $q = new CGI; my $r = param("r"); my $hauteur = param("hauteur"); my $largueur = param("largeur"); $file = random_file ($dir, '\\.(png|PNG||jpg|JPG|jpeg|JPEG|gif)$' ); print $q->header( -type => "image/png", -expires => "-1d" ); binmode STDOUT; $img = &shrink($file,$hauteur,$largueur); sub random_file { my( $dir,$mask ) = @_; my $i = 0; my ($file); local( *DIR); opendir DIR, $dir or die "Cannot open $dir: $!"; while ( defined ( $_ = readdir DIR ) ) { /$mask/o or next if defined $mask; rand ++$i < 1 and $file = $_; } closedir DIR; return "$dir/$file"; } # Load the given image ans shrinks it to be within the given size # or percentage sub shrink () { my($name,$hauteur,$largueur) = @_; my($img) = new Image::Magick; print "i got to $name!\n"; ## print $size; my $x = $img->Read($name); warn "$x" if $x; my $y = $img->Resize('width' => $hauteur , 'height' => $largueur ) +; warn "$y" if $y; my $z = $img->Write('png:-'); warn "$z" if $z; undef $img; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://221281]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2017-05-28 07:18 GMT
Find Nodes?
    Voting Booth?