Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Perl: how to save an image from a URL?

  • 15-04-2007 3:30pm
    #1
    Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭


    Can someone tell me how I can download and save an image using a perl script if I have the URL of the image?

    Does the Mechanize library allow this, or will it only save information about the image?

    Cheers


Comments

  • Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭Mr. Flibble


    I got it
    use LWP::Simple;
    
    my $picture_binary = get "http://domain.com/logo.gif";
    
    open (SAVE, "./local_copy.gif");
    binmode SAVE;
    print SAVE $picture_binary;
    close (SAVE);
    


  • Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭Mr. Flibble


    Actually I haven't got it.

    This code seems to only work on images which are hosted on the same server which the script is running from. When I try it on other images it saves an image of the URL for the image which seems very odd. Anyone know what is going on here?


Advertisement