#!/usr/bin/perl use GD; use CGI::Carp qw/ fatalsToBrowser /; use warnings; print "Content-type: text/html\n\n"; $code_image_file = '8_QB.jpg'; $file_code = "$code_image_file"; $image_code = GD::Image->newFromJpeg($file_code); $ESP_code = new GD::Image(200,200); $ESP_code->copy($image_code,0,0,600,400,200,200); # Convert the image to JPEG and write it to a file. $image = $ESP_code->jpeg([50]); binmode STDOUT; #Write to file open ESP_IMAGE, ">filepath/image.jpg"; print ESP_IMAGE $image; close ESP_IMAGE; print "";