<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package WWW::Mechanize::Image;
# vi:et:sw=4 ts=4

use strict;
use warnings;

=head1 NAME

WWW::Mechanize::Image - Image object for WWW::Mechanize

=head1 SYNOPSIS

Image object to encapsulate all the stuff that Mech needs

=head1 Constructor

=head2 new()

Creates and returns a new C&lt;WWW::Mechanize::Image&gt; object.

    my $image = WWW::Mechanize::Image-&gt;new( {
        url    =&gt; $url,
        base   =&gt; $base,
        tag    =&gt; $tag,
        name   =&gt; $name,    # From the INPUT tag
        height =&gt; $height,  # optional
        width  =&gt; $width,   # optional
        alt    =&gt; $alt,     # optional
    } );

=cut

sub new {
    my $class = shift;
    my $parms = shift || {};

    my $self = bless {}, $class;

    for my $parm ( qw( url base tag height width alt name ) ) {
        # Check for what we passed in, not whether it's defined
        $self-&gt;{$parm} = $parms-&gt;{$parm} if exists $parms-&gt;{$parm};
    }

    # url and tag are always required
    for ( qw( url tag ) ) {
        exists $self-&gt;{$_} or die "WWW::Mechanize::Image-&gt;new must have a $_ argument";
    }

    return $self;
}

=head1 Accessors

=head2 $link-&gt;url()

URL from the link

=head2 $link-&gt;base()

Base URL to which the links are relative.

=head2 $link-&gt;name()

Name for the field from the NAME attribute, if any.

=head2 $link-&gt;tag()

Tag name (either "image" or "input")

=head2 $link-&gt;height()

Image height

=head2 $link-&gt;width()

Image width

=head2 $link-&gt;alt()

ALT attribute from the source tag, if any.

=cut

sub url     { return ($_[0])-&gt;{url}; }
sub base    { return ($_[0])-&gt;{base}; }
sub name    { return ($_[0])-&gt;{name}; }
sub tag     { return ($_[0])-&gt;{tag}; }
sub height  { return ($_[0])-&gt;{height}; }
sub width   { return ($_[0])-&gt;{width}; }
sub alt     { return ($_[0])-&gt;{alt}; }

=head2 $link-&gt;URI()

Returns the URL as a L&lt;URI::URL&gt; object.

=cut

sub URI {
    my $self = shift;

    require URI::URL;
    my $URI = URI::URL-&gt;new( $self-&gt;url, $self-&gt;base );

    return $URI;
}

=head2 $link-&gt;url_abs()

Returns the URL as an absolute URL string.

=cut

sub url_abs {
    my $self = shift;

    return $self-&gt;URI-&gt;abs;
}

=head1 SEE ALSO

L&lt;WWW::Mechanize&gt; and L&lt;WWW::Mechanize::Link&gt;

=head1 COPYRIGHT &amp; LICENSE

Copyright 2004-2010 Andy Lester.

This program is free software; you can redistribute it and/or modify
it under the terms of either:

=over 4

=item * the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
version, or

=item * the Artistic License version 2.0.

=back

=cut

1;
</pre></body></html>