ssafronova (ssafronova) wrote in changelog,
ssafronova
ssafronova
changelog

[livejournal] r17476: LJSUP-6110: Livejournal Live - LJSUP-698...

Committer: ssafronova
LJSUP-6110: Livejournal Live - LJSUP-6983: incorrect Live post where no pictures
do not crop&save too small pictures
U   trunk/cgi-bin/ljuserpics.pl
Modified: trunk/cgi-bin/ljuserpics.pl
===================================================================
--- trunk/cgi-bin/ljuserpics.pl	2010-09-30 09:11:14 UTC (rev 17475)
+++ trunk/cgi-bin/ljuserpics.pl	2010-09-30 09:26:10 UTC (rev 17476)
@@ -596,6 +596,8 @@
 #   save_to_FB (bool) - is it need to save to FB (FotoBilder)
 #   fb_gallery - gallery to save target image
 #   auto_crop - is it need to auto_crop image
+#   cancel_size - if size of picture is equal or smaller => cancel processing, caller will not use such small picture
+#                 returns status 'small'
 #####
 # Sample for use as auto-crop:
 #
@@ -627,6 +629,7 @@
     my $fb_username = delete $opts{fb_username}; 
     my $fb_password = delete $opts{fb_password};
     my $auto_crop = delete $opts{auto_crop};
+    my $cancel_size = delete $opts{cancel_size};
     croak "No userid or remote" unless $u || $mogkey || $dataref;
 
     $maxfilesize *= 1024;
@@ -652,6 +655,10 @@
     my ($ow, $oh) = Image::Size::imgsize($dataref);
     return undef unless $ow && $oh;
 
+    my @cancel_size = split /x/, $cancel_size;
+    return { status => 'small' }
+        if $cancel_size and $ow <= $cancel_size[0] and $oh <= $cancel_size[1];
+
     # converts an ImageMagick object to the form returned to our callers
     my $imageParams = sub {
         my $im = shift;
@@ -985,6 +992,7 @@
     my $res = LJ::_get_upf_scaled(
                     source => \$data,
                     size => $opts{size},
+                    cancel_size => $opts{cancel_size},
                     save_to_FB => 1,
                     auto_crop => 1,
                     fb_username => $opts{username},

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