40000) { $mytime = time(); // set output jpeg quality $jpeg_quality = 90; // set thumbnail height to use $thumb_height = 120; // set thumbnail width to use $thumb_width = 120; // $size[0] = the width of input image : $size[1] = the height of input image $size = getimagesize($my_input_file); $cropStartX = 50; $cropStartY = 0; $cropW = 512; $cropH = 512; $quality = 90; // Cache the image until there's a new original to make a thumbnail of // This greatly reduces server load and page load time. if (filemtime($my_input_file) > filemtime($my_output_file)) { if ($size[0]==562) { sleep (1); // Create two images $origimg = imagecreatefromjpeg($my_input_file); $cropimg = imagecreatetruecolor($cropW,$cropH); // Crop imagecopyresized($cropimg, $origimg, 0, 0, $cropStartX, $cropStartY, $size[0], $size[1], $size[0], $size[1]); $white = imagecolorallocate ($cropimg, 255,255,255); putenv('TZ=US/Central'); $imagetime = date("g:i A"); imagestring($cropimg,FF_ARIAL,470,503,$imagetime,$white); imagejpeg($cropimg,$my_output_file2,$quality); // destroy the images imagedestroy($cropimg); imagedestroy($origimg); } $size = getimagesize($my_output_file2); // create image in memory $src_img = imagecreatefromjpeg($my_output_file2); $dst_img = imagecreatetruecolor($thumb_width,$thumb_height); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_width, $thumb_height, $size[0], $size[1]); // write output image imagejpeg($dst_img, $my_output_file, $jpeg_quality); // free memory used imagedestroy($src_img); imagedestroy($dst_img); } else if (filemtime($my_input_file) < $mytime - 1500) { $size = getimagesize($my_output_file2); sleep (1); // create image in memory $org_img = imagecreatefromjpeg($my_input_file); $src_img = imagecreatefromjpeg($my_output_file2); $dst_img = imagecreatetruecolor($thumb_width,$thumb_height); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_width, $thumb_height, $size[0], $size[1]); // If radar image is over 20 minutes old, add text that radar is down $white = imagecolorallocate ($dst_img, 255,255,255); imagestring($dst_img,2,20,50,"RADAR DOWN",$white); imagestring($src_img,2,230,280,"RADAR DOWN",$white); $Notupdated = "RADAR HAS NOT UPDATED IN LAST 25+ MINUTES"; imagestring($src_img,2,100,380,$Notupdated,$white); // write output image imagejpeg($dst_img, $my_output_file, $jpeg_quality); imagejpeg($org_img, $my_input_file, 100); imagejpeg($src_img, $my_output_file2, 100); // free memory used imagedestroy($org_img); imagedestroy($src_img); imagedestroy($dst_img); } else if ($Force==1) { if ($size[0]==562) { sleep (2); // Create two images $origimg = imagecreatefromjpeg($my_input_file); $cropimg = imagecreatetruecolor($cropW,$cropH); // Crop imagecopyresized($cropimg, $origimg, 0, 0, $cropStartX, $cropStartY, $size[0], $size[1], $size[0], $size[1]); $white = imagecolorallocate ($cropimg, 255,255,255); putenv('TZ=US/Central'); $imagetime = date("g:i A"); imagestring($cropimg,FF_ARIAL,470,503,$imagetime,$white); imagejpeg($cropimg,$my_output_file2,$quality); // destroy the images imagedestroy($cropimg); imagedestroy($origimg); } $size = getimagesize($my_output_file2); // create image in memory $src_img = imagecreatefromjpeg($my_output_file2); $dst_img = imagecreatetruecolor($thumb_width,$thumb_height); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_width, $thumb_height, $size[0], $size[1]); // write output image imagejpeg($dst_img, $my_output_file, $jpeg_quality); // free memory used imagedestroy($src_img); imagedestroy($dst_img); echo "done"; } } ?>