文字

imagecrop

(PHP 5 >= 5.5.0, PHP 7)

imagecropCrop an image using the given coordinates and size, x, y, width and height

说明

resource imagecrop ( resource $image , array $rect )

Warning

本函数还未编写文档,仅有参数列表。

参数

image

由图象创建函数(例如 imagecreatetruecolor() )返回的图象资源。

rect

Array with keys "x", "y", "width" and "height".

返回值

Return cropped image resource on success 或者在失败时返回 FALSE .

用户评论:

[#1] nangomusic at gmail dot com [2014-07-10 22:38:52]

An example to crop an image stored in $filename:

<?php
// Create a blank image and add some text
$ini_filename 'test.JPG';
$im imagecreatefromjpeg($ini_filename );

$ini_x_size getimagesize($ini_filename )[0];
$ini_y_size getimagesize($ini_filename )[1];

//the minimum of xlength and ylength to crop.
$crop_measure min($ini_x_size$ini_y_size);

// Set the content type header - in this case image/jpeg
//header('Content-Type: image/jpeg');

$to_crop_array = array('x' =>'y' => 0'width' => $crop_measure'height'=> $crop_measure);
$thumb_im imagecrop($im$to_crop_array);

imagejpeg($thumb_im'thumb.jpeg'100);
?>

上一篇: 下一篇: