From tony at metracom.com Mon Apr 4 17:16:21 2016 From: tony at metracom.com (Tony) Date: Mon, 04 Apr 2016 17:16:21 -0700 Subject: [Oc-pm] Next OC Perl meeting April 25th @ 7pm Message-ID: <2130933.2NuLAeBuqs@dell-server> OC Perl Mongers, Please mark your calendar for the next Perl meeting. The April Perl challenge is posted on the website. See you on the 25th. http://oc.pm.org Tony Gasparovic -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony at metracom.com Mon Apr 18 09:37:37 2016 From: tony at metracom.com (Tony) Date: Mon, 18 Apr 2016 09:37:37 -0700 Subject: [Oc-pm] OC Perl meeting April 25th @ 7pm Message-ID: <2923376.FmcVEGaDty@dell-server> OC Perl Mongers, our monthly meeting is one week from today. Please mark your calendars. If you would like to present please let me know ASAP so that I can update the website. The April Perl challenge is posted on the website. Please bring your code to the meeting. We will share solutions. It's all part of the fun! See you next Monday the 25th. http://oc.pm.org Tony Gasparovic -------------- next part -------------- An HTML attachment was scrubbed... URL: From vijay2 at cox.net Tue Apr 19 19:49:11 2016 From: vijay2 at cox.net (Vijay Anand) Date: Tue, 19 Apr 2016 19:49:11 -0700 Subject: [Oc-pm] 2016 April Challange In-Reply-To: References: Message-ID: <5716EE27.3040709@cox.net> I struggled with Image::Magick, then gave up on it, and went with GD. That seems to have worked - the pictures are : A cat, A Parrot, and 2 penguins. The colors look a little weird, so I probably have a bug. Here is the code: use strict; use warnings; use GD; ############################### # April Challange ## Reconstruct JPG images one pixel at a time, from JSON. ### By Vijay Anand ################################################# my $inp = shift @ARGV or die "NO file specified"; my $out = $inp . ".jpg"; local $/; open my $f, "<", $inp or die "Cannot open $inp:$!"; my $str=<$f>; close $f; print "Read ",length($str)," bytes\n"; $str=~s/:/=>/g; my $j = eval $str; print "Converted to perl.", my $rows=scalar(keys(%$j)), " Rows, ", my $cols=scalar(keys(%{$j->{'0'}})), " Columns\n"; my $image = GD::Image::->new($cols,$rows) or die "Cannot create GD object"; # width,height my $black = $image->colorAllocate(0,0,0); my $red = $image->colorAllocate(255,0,0); $image->rectangle(0,0,$cols -1,$rows -1,$black); # Put a black frame around the picture $image->fill($cols-2,$rows-2,$red); my $pxcount = 0; for my $r(keys %$j){ for my $c(keys %{$j->{$r}}){ my $px = $j->{$r}{$c}; $image->setPixel($c,$r,$image->colorResolve(@$px{qw|RED GREEN BLUE|})); $pxcount++; } } print "$pxcount pixels color set\n"; open my $o, ">", $out or die "Cannot open $out:$!"; binmode $o; print $o $image->jpeg(90); close $o; print "Processed $out. Created $out \n"; From bobmath11 at icloud.com Wed Apr 20 08:52:30 2016 From: bobmath11 at icloud.com (Bob Mathews) Date: Wed, 20 Apr 2016 08:52:30 -0700 Subject: [Oc-pm] 2016 April Challange In-Reply-To: <5716EE27.3040709@cox.net> References: <5716EE27.3040709@cox.net> Message-ID: > On Apr 19, 2016, at 7:49 PM, Vijay Anand wrote: > The colors look a little weird, so I probably have a bug. It works better with a true-color image (third argument to the constructor). my $image = GD::Image::->new($cols,$rows,1) Good lord, string eval is slow. It?s much faster if you write it out to a temp file and then require it. That?s still much slower than JSON::XS. -bob -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony at metracom.com Mon Apr 25 07:35:11 2016 From: tony at metracom.com (Tony) Date: Mon, 25 Apr 2016 07:35:11 -0700 Subject: [Oc-pm] OC Perl Meeting today @ 7pm Message-ID: <1907857.uuXTbT6PJ4@dell-server> Just a reminder that the OC Perl meeting is tonight at 7pm. See you there, Tony -------------- next part -------------- An HTML attachment was scrubbed... URL: