Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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; }

In reply to Re^3: shrink.pl - Scales down images by swilting
in thread shrink.pl - Scales down images by Vortacist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found