aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew>2009-11-19 00:14:59 +0000
committermatthew <matthew>2009-11-19 00:14:59 +0000
commit6839fa82e4eec60989b78c93d081f72d02616e19 (patch)
tree6251d72442edae2196dea914777f851112e6f206
parente0aaf682d86f58bd8f91a817bbacb20b81e71814 (diff)
Reading from CGI upload() filehandle doesn't appear to be working properly/
at all on Lenny, so save to (a normal) temporary file and read from there.
-rw-r--r--perllib/Page.pm13
1 files changed, 9 insertions, 4 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm
index 246e5a211..72eff7fc8 100644
--- a/perllib/Page.pm
+++ b/perllib/Page.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Page.pm,v 1.208 2009-11-17 13:58:48 louise Exp $
+# $Id: Page.pm,v 1.209 2009-11-19 00:14:59 matthew Exp $
#
package Page;
@@ -1024,9 +1024,15 @@ sub process_photo {
my $fh = shift;
my $import = shift;
- my $photo = Image::Magick->new;
- my $err = $photo->Read(file => \*$fh); # Mustn't be stringified
+ my $blob = join('', <$fh>);
close $fh;
+ my ($handle, $filename) = mySociety::TempFiles::named_tempfile('.jpeg');
+ print $handle $blob;
+ close $handle;
+
+ my $photo = Image::Magick->new;
+ my $err = $photo->Read($filename);
+ unlink $filename;
throw Error::Simple("read failed: $err") if "$err";
$err = $photo->Scale(geometry => "250x250>");
throw Error::Simple("resize failed: $err") if "$err";
@@ -1036,7 +1042,6 @@ sub process_photo {
return $photo unless $import; # Only check orientation for iPhone imports at present
# Now check if it needs orientating
- my $filename;
($fh, $filename) = mySociety::TempFiles::named_tempfile('.jpeg');
print $fh $photo;
close $fh;