[Moscow.pm] Конкурс

Akzhan Abdulin akzhan.abdulin на gmail.com
Пт Окт 26 05:11:02 PDT 2012


Ах ты блин. Максимального размера :) Это де факто надо усложнить сжатие до
предела )))

26 октября 2012 г., 16:10 пользователь Akzhan Abdulin <
akzhan.abdulin на gmail.com> написал:

> Если я правильно понял ТЗ, то вот решение (надеюсь, там по умолчанию
> черный цвет заливки). :)
>
> Подсказка: нижней границы числа нечерных пискелов нет.
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> use Imager;
> use Time::HiRes qw(time);
>
> my $filename = 'competition.jpg';
> my $image = Imager->new(xsize=>1024, ysize=>1024);
> my $before = time();
>
> my $after = time();
> $image->write(file=>$filename) or die $image->errstr;
> my $filesize = -s $filename;
> my $elapsed = ($after-$before) or die 'You are winner!';
>
> print "Time: ",$elapsed,"\nFile size: ", $filesize, "\nResult:
> ",$filesize/$elapsed,"\n";
>
>
>
> 26 октября 2012 г., 16:01 пользователь Михаил Монашёв <
> postmaster на softsearch.ru> написал:
>
> #!/usr/bin/perl
>> use strict;
>> use warnings;
>>
>> use Imager;
>> use Time::HiRes qw(time);
>>
>> my $filename = 'competition.jpg';
>> my $image = Imager->new(xsize=>1024, ysize=>1024);
>> my $before = time();
>>
>> # этот блок кода надо ускорить
>> srand(123);
>> for (my $i=0; $i<39293; $i++) {
>>         my $color = Imager::Color->new(rand(255), rand(255), rand(255) );
>>         $image->setpixel(x=>rand(1024), y=>rand(1024), color=>$color);
>> }
>>
>> my $after = time();
>> $image->write(file=>$filename) or die $image->errstr;
>> my $filesize = -s $filename;
>> my $elapsed = ($after-$before) or die 'You are winner!';
>>
>> print "Time: ",$elapsed,"\nFile size: ", $filesize, "\nResult:
>> ",$filesize/$elapsed,"\n";
>>
>
>
----------- следущая часть -----------
Вложение в формате HTML было извлечено…
URL: <http://mail.pm.org/pipermail/moscow-pm/attachments/20121026/fb269366/attachment-0001.html>


Подробная информация о списке рассылки Moscow-pm