hi-

I am trying to save a image from a website by using the LWP Simple get store function. However, when being saved the image file is saved in ASCII format and not BINARY, leaving the picture to be displayed wrong. I researched on how I can do this and I think it invovles using binmode??

previous code:
my $image_name = "heybuddy.jpg"; my $image_full = "/home/temp/$image_name"; #image full path to the tem +p file my $status = getstore($video_src, $image_full); #uses getstore to retr +ieve image and to be stored in the temp path. die "Error $status on $video_src" unless is_success($status);


The above code correctly stores the file retrieved from the website, but now I need to convert the temp file to a binary file and store it in my image dir and not temp dir.

So I tried adding this right below the above coding:
open(IN, ">/home/images/$image_name") or die "Can't open: $!"; + binmode IN; while (<$image_full>) { print IN; } close IN or die "Can't close: $!"; }


This code does save the image name to my image directory (home/images) but it comes out to 0 kilobytes.
Ahhhh any help will be appreciated.

tanger

In reply to LWP Simple - getstore function by tanger

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.