ssafronova (ssafronova) wrote in changelog,
ssafronova
ssafronova
changelog

[livejournal] r17599: LJSV-1202: Userpic factory giving incorr...

Committer: ssafronova
LJSV-1202: Userpic factory giving incorrect error message for large images
U   trunk/cgi-bin/ljuserpics.pl
Modified: trunk/cgi-bin/ljuserpics.pl
===================================================================
--- trunk/cgi-bin/ljuserpics.pl	2010-10-25 06:49:41 UTC (rev 17598)
+++ trunk/cgi-bin/ljuserpics.pl	2010-10-25 10:14:00 UTC (rev 17599)
@@ -810,10 +810,17 @@
     # add border if desired
     $timage->Border(geometry => "1x1", color => 'black') if $border;
 
-    my $ret = undef;
+    # we are PNG here
+    # test, if we can skip compression
+    my $piccopy = $timage->Clone();
+    my $ret = $imageParams->($piccopy);
+    unless ( length(${ $ret->[0] }) < $maxfilesize ) {
+        $timage->Set(magick => 'JPG'); # need compression
+    }
+
     foreach my $qual (qw(100 90 85 75)) {
         # work off a copy of the image so we aren't recompressing it
-        my $piccopy = $timage->Clone();
+        $piccopy = $timage->Clone();
         $piccopy->Set('quality' => $qual);
         $ret = $imageParams->($piccopy);
         last if length(${ $ret->[0] }) < $maxfilesize;

Tags: livejournal, pl, ssafronova
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments