$cropped_image = ImageCreateTrueColor($crop_width, $crop_height); imagealphablending( $cropped_image, false ); imagesavealpha( $cropped_image, true ); $transparent = imagecolorallocatealpha($cropped_image, 0, 0, 0, 127); imagefill($cropped_image, 0, 0, $transparent); $original_image = ImageCreateFromPNG($image_to_crop); imagealphablending( $original_image, false ); imagesavealpha( $original_image, true ); ImageCopy($cropped_image, $original_image, 0, 0, $left, $top, $width, $height); ImagePNG($cropped_image, $save_path);Here $image is the cropped image. $width and $height are the width and height of the original image respectively. $left and $top are the left and top location of the rectangular portion of the original image which should be cropped. And $save_path is the location where the cropped image should be saved.
Hope this helps someone.