use warnings; use strict; use Win32::Console qw(GENERIC_READ GENERIC_WRITE); use Data::Dump qw(dd); my $con_current = Win32::Console->new(GENERIC_READ | GENERIC_WRITE); $con_current or die 'new Win32::Console failed'; my ($left, $top, $right, $bottom) = $con_current->Window; print "Dimensions (left top right bottom):",qq($left, $top, $right, $bottom \n); my $rect = $con_current->ReadRect($left, $top, $right, $bottom); $rect or die 'read Win32::Console failed'; #$rect =~ s{ \0\a\0 } ''xmsg; #$rect =~ s{ [ ]+ \z } ''xmsg; #dd $rect; print qq{======\nBefore writing anything from Win32.:Console\n======\n}; $con_current->WriteRect($rect,$left, $top, $right, $bottom )or die 'write Win32::Console failed'; print "dd of \$rect: "; dd $rect; ###################################################################### use strict; use warnings; use GD; my $file = $ARGV[0]; die "Please feed a jpg file.." unless -e $file; my $orig_gd = GD::Image->new($file); my $photo_ratio = 0.3; my $small_w = int($orig_gd->width * $photo_ratio); my $small_h = int($orig_gd->height * $photo_ratio); draw_photo ($file); ################################################################################ sub draw_photo { my $file_path = shift; # create the resized but still empty GD image my $resized = GD::Image->new($small_w,$small_h); # copy from source into resized on $resized->copyResampled($orig_gd,0,0,0,0, $small_w, $small_h, $orig_gd->width, $orig_gd->height); # save open my $out, '>', time.'.jpg' or die "unable to open for write"; binmode $out; print $out $resized->jpeg or die "unable to write jpg data!"; close $out; }