In GD Looking for a way to increase total image size while having image preserved as same size

39 views Asked by At

So I need have an image uploaded with a background. I would like the actual image to stay approximately 120px in the middle of a black background of 168px as a 12px border. So far I wrote this with php/GD, but it doesn't quite give me the effect I needed:

    
    
    //set the dimensions for the pinkynail
    $pinky_width = $width*0.72;
    $pinky_height = $height*0.72;
    $pinky_borderw = $width*0.14;
    $pinky_borderh = $height*0.14;

    //create the pinkynail
    $pinky = imagecreatetruecolor($pinky_width, $pinky_height);
    imagecopyresampled($pinky, $image, $pinky_borderw, $pinky_borderh, 0, 0, $pinky_width, $pinky_height,
        $width, $height);
    imagejpeg($pinky, $pinkydir . '/' . $image_id . '.jpg', 100);
    imagedestroy($pinky);




Am I even on the right track?

I was expecting a border all around the image, but it cuts off the bottom right and shifts it left and from the top with a black background.

0

There are 0 answers