After reading sch's post, I realized I should have posted this a while ago.

This will retrieve the most current image from NOAA and upload it to a website.

It's currently set to capture the Mount Holly, NJ radar, and crop it to 300x200, centered on Glassboro, NJ. You can modify this, follow the instructions in the comments.

#!/usr/bin/perl -w use strict; use LWP::Simple; use Image::Magick; use Net::FTP; ### Modify these values for your purposes my $tempfile = "temp.gif"; # leave as gif my $outfile = "weather.jpg"; # change file type as desired my %web = ( 'dir' => '/httpdocs/images', 'user' => 'username', 'pass' => 'password', 'server' => 'server.tld' ); my %image = ( 'xlength' => '300', 'ylength' => '200', 'xoffset' => '115', 'yoffset' => '256' ); my $url = q[ http://weather.noaa.gov/radar/images/DS.80stp/SI.kdix/lat +est.gif ]; # Image to grab my $tos = 1800; # Time to Sleep (30 Min, suggested) ### my $count = 1; while(1){ print "Starting iteration $count\n"; print "Getting image...\n"; getstore($url, $tempfile); my $o = new Image::Magick; $o->Read("$tempfile"); print "Modifying Image...\n"; my $geo = $image{xlength}.'x'.$image{ylength}.'+'.$image{xoffset}.'+'. +$image{yoffset}.'!'; $o->Crop(geometry=>$geo); if(0){ # set to one for comments $o->Annotate(text=>"Current Weather from NOAA", font=>"Verdana", pointsize=>12, antialias=>"true", x=>150, y=>180, align=>"Center", fill=>"#ffffff", stroke=>"#ffffff", strokewidth=>"2"); } $o->Write(filename=>"$outfile", compression=>"jpeg"); print "Uploading file...\n"; my $ftp = Net::FTP->new($web{server}); $ftp->login($web{user},$web{pass}); $ftp->cwd($web{dir}); $ftp->binary(); $ftp->delete($outfile); $ftp->put($outfile); print "Sleeping for $tos seconds.\n\n"; sleep($tos); $count++; }

John J Reiser
newrisedesigns.com


In reply to Weather for your website by newrisedesigns

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.