I'm currently working on a pretty simple script which takes an image, and creates a thumbnail using GD2.

Despite my inexperience with GD, I've managed to get this far with the help of a tutorial.

However in addition to creating a thumbnail, I'd like to add a 1px black stroke (border) around the image.

This is the function I'm currently using to generate the image.

PHP Code:
// begin createthumb
function createthumb($name,$filename,$new_w,$new_h){ 
   
$system=explode(".",$name); 
    if (
preg_match("/jpg|jpeg/",$system[1])){ 
        
$src_img=imagecreatefromjpeg($name); 
    } 
    if (
preg_match("/png/",$system[1])){ 
        
$src_img=imagecreatefrompng($name); 
    } 
 
    
$old_x=imageSX($src_img); 
    
$old_y=imageSY($src_img); 
    
$thumb_w=$new_w
    
$thumb_h=$new_h
 
 
// below only works with gd2
    
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); 
    
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
 
 
// end gd2-only code
    
if (preg_match("/png/",$system[1])){ 
        
imagepng($dst_img,$filename); 
    } else { 
        
imagejpeg($dst_img,$filename); 
    } 
    
imagedestroy($dst_img); 
    
imagedestroy($src_img); 

Is there anyway this can be modified to add a 1px stroke to the image?

Many thanks