0

嗨,目前我构建了从图像创建缩略图的功能,它确实这样做了,但是我希望它是一个圆形缩略图而不是一个矩形,我怎样才能在不使用任何外部库的情况下实现这一点,只是 php 内置的方法?谢谢你

 function createThumb( $imagepath, $thumbFile, $thumbWidth )
{
// load image and get image size
  $img = imagecreatefromjpeg( "$imagepath" );
  $width = imagesx( $img );
  $height = imagesy( $img );  
  // calculate thumbnail size
  $new_width = $thumbWidth;
  $new_height = floor( $height * ( $thumbWidth / $width ) );
  // create a new temporary image
  $tmp_img = imagecreatetruecolor( $new_width, $new_height );
  // copy and resize old image into new image
  imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, 
                $new_width, $new_height, $width, $height );
  // save thumbnail into a file in the temp directory below script or somewhere
  imagejpeg( $tmp_img, $thumbFile );
}
4

1 回答 1

0

实际上,CSS 是一种更好的方法。

.class-name {
   border-radius : 30px;
}
于 2013-07-16T05:14:13.903 回答