Committer: ailyin
LJSUP-7322 (fotobilder throws "Scaling dimensions must be smaller than original")U trunk/lib/FB/Gpic.pm
Modified: trunk/lib/FB/Gpic.pm =================================================================== --- trunk/lib/FB/Gpic.pm 2010-11-10 11:38:10 UTC (rev 1435) +++ trunk/lib/FB/Gpic.pm 2010-11-12 07:26:47 UTC (rev 1436) @@ -125,6 +125,12 @@ # if we're not told to create a new gpic, and one doesn't exist, that's it return undef unless $opts->{create}; + # only allow to downscale pictures; in case the original picture + # is smaller, return the original itself + if ($self->{'width'} <= $w and $self->{'height'} <= $h) { + return $self; + } + # if our caller allows us to create new gpics, register a job to do so now my $gpicid_ref = FB::Job->do ( job_name => 'scale_image', @@ -208,7 +214,10 @@ # now get a scaling width/height my ($nw, $nh) = FB::scale($g_orig->{width}, $g_orig->{height}, $w, $h); - croak "Scaling dimensions must be smaller than original" + + # only allow to downscale pictures; in case the original picture + # is smaller, return the original itself + return \$gpicid if $nw > $g_orig->{width} || $nh > $g_orig->{height}; # check database to see if a scaled version should exist