in reply to Re^2: Difficulty with using LWP to display JPEG
in thread Difficulty with using LWP to display JPEG

Aquilae:

LWP lets you talk with servers over the network, it doesn't have anything to do with the browser. If you want the browser to display the images, I'd suggest one of:

...roboticus

When your only tool is a hammer, all problems look like your thumb.

  • Comment on Re^3: Difficulty with using LWP to display JPEG

Replies are listed 'Best First'.
Re^4: Difficulty with using LWP to display JPEG
by Aquilae (Novice) on Apr 11, 2014 at 19:03 UTC

    Roboticus - I am not on a linux machine. Does that mean WWW::Mechanize is going to be useless to me?

    I managed to write some small code but I really do not know which way to go with it. Sadly, I am completely unfamiliar with mechanize so this is what I have come up with:

    use strict; use WWW::Mechanize; my $url = "http://upload.wikimedia.org/wikipedia/en/7/70/Blogscope-log +o-simple.jpg"; #my $cookie_jar; my $mech = WWW::Mechanize->new(); $mech->get($url); $mech->success() or die "Can't fetch the Requested page"; my $val = $mech->content; print $val;

    $val ends up being that same binary nonsense. I took a look at the Image function but it looks like that just scrapes the current page and finds all images and assigns them to an array - I am actually providing a link to the image itself so it doesn't look like that would work.

    Thanks again!

      Aquilae:

      I don't know enough about WWW::Mechanize to determine whether it would be useless to you, though I suspect that's the case. What's the "bigger picture" description of your task? Perhaps someone may have an alternative that suits you. For example, if you're trying to display the image automatically with requiring it to be in a web browser, then one of the graphical toolkits may be of some use.

      I just looked at |cpan.org and searched for "IE" and it came up with a few hits, like Win32::IE::Slideshow, Wx::ActiveX::IE. I can't offer any recommendations, as I haven't tried automating IE with perl. Trawling through the various CPAN modules may help you find something you can use.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        Roboticus - I am writing a script that displays images to the browser to ensure that they are there. It is not enough to verify that the file exists, it must also be displayed to ensure it is the correct file.

        A further caveat is that the files are on a server with HTTP authentication using .HTACCESS. I know that I can do things like:

        $req->authorization_basic('user', 'pass'); to gain access to such images.

        I do not know that I need to automate IE, or Firefox, or Chrome (in my case I use chrome), so much as I need to find a way to display images that require authentication.

        Initially I had simple HTML tags in my code printing like this:

        print "<img height=\"$x\" width=\"$y\" src=\"$ImagePath\">";

        However in the case of images that are behind .HTACCESS I would run into a login prompt over and over and over again.

        Thanks again Roboticus!
      "I took a look at the Image function but it looks like that just scrapes the current page and finds all images and assigns them to an array ...."

      So then foreach... the image array thru code (not included and neither are the batteries) that (if they're .jpgs) spits (choose one) links|$arr[n] out to (choose one) an|the browser.


      Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
      1. code
      2. verbatim error and/or warning messages
      3. a coherent explanation of what "doesn't work actually means.

      check Ln42!