#!/usr/bin/perl use GD; use CGI::Carp qw/ fatalsToBrowser /; use warnings; print "Content-type: text/html\n\n"; #Master Image $code_image_file = '8_QB.jpg'; $file_code = "/BigExp/exp8/$code_image_file"; $image_code = GD::Image->newFromJpeg($file_code); #Creation of smaller image to be used as #repository for contents of smaller image contained #within Master image $ESP_code = new GD::Image(200,200); #Loop through specific pixel block in Master Image for ($y=0; $y<200; $y++) { for ($x=0;$x<200;$x++) { #Get pixel intensity data $index = $image_code->getPixel($x,$y); ($red,$green,$blue) = $image_code->rgb($index); $color = $ESP_code->colorAllocate($red,$green,$blue); $ESP_code->setPixel($x,$y,$color) } # End of Row cycle } ## End of Column cycle # Convert the image to JPEG and write it to a file. $image = $ESP_code->jpeg([50]); binmode STDOUT; #Write to file open ESP_IMAGE, ">image.jpg"; print ESP_IMAGE $image; close ESP_IMAGE; print "";