Created
June 2, 2010 02:58
-
-
Save fujiwara/421856 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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