Skip to content

Instantly share code, notes, and snippets.

@fujiwara
Created June 2, 2010 02:58
Show Gist options
  • Select an option

  • Save fujiwara/421856 to your computer and use it in GitHub Desktop.

Select an option

Save fujiwara/421856 to your computer and use it in GitHub Desktop.
package ImageResize;
use strict;
use warnings;
use nginx;
use Image::Imlib2;
Image::Imlib2->set_cache_size(0);
sub handler {
my $r = shift;
my ($file) = split /\?/, $r->uri;
$file = "/tmp$file";
unless (-e $file) {
return DECLINED;
}
my $im = Image::Imlib2->load($file);
my $im2 = $im->create_scaled_image( 150, 100 );
$im2->set_quality(75);
$im2->save("/tmp/img/$$.jpg");
$r->internal_redirect("/_img/$$.jpg");
return OK;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment