casimo has asked for the wisdom of the Perl Monks concerning the following question:
use Win32::IE::Mechanize; use Time::HiRes; $ie = Win32::IE::Mechanize->new( visible => 1 ) ; $ie->get( 'http://localhost/image/myimage.php' ) ; while($ie->{agent}->Document->readyState !~ /complete/i){ sleep(0.1); +} $content = $ie->content; save_image($content); sub save_image { my ($content) = @_; open my $out_fh, ">", "image.png" or die $!; binmode $out_fh; print $out_fh $content; close $out_fh; }
<?php $my_img = imagecreate( 200, 80 ); $background = imagecolorallocate( $my_img, 0, 0, 255 ); $text_colour = imagecolorallocate( $my_img, 255, 255, 0 ); $line_colour = imagecolorallocate( $my_img, 128, 255, 0 ); imagestring( $my_img, 4, 30, 25, "test image", $text_colour ); imagesetthickness ( $my_img, 5 ); imageline( $my_img, 30, 45, 165, 45, $line_colour ); header( "Content-type: image/png" ); imagepng( $my_img ); imagecolordeallocate( $line_color ); imagecolordeallocate( $text_color ); imagecolordeallocate( $background ); imagedestroy( $my_img ); ?>
<img src="myimage.php" alt="Image created by a PHP script" width="200" + height="80">
<HTML><HEAD></HEAD> <BODY leftMargin=0 scroll=no topMargin=0><EMBED height="100%" type=ima +ge/x-png width="100%" src=http://localhost/image/myimage.php fullscre +en="yes"></BODY></HTML>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Save PHP-generated image with Win32 IE Mechanize
by Corion (Patriarch) on Feb 10, 2010 at 08:00 UTC | |
by casimo (Sexton) on Feb 11, 2010 at 03:17 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |