PHP 5.6.24 is released

imagecrop

(PHP 5 >= 5.5.0, PHP 7)

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

Açıklama

resource imagecrop ( resource $image , array $rect )

Uyarı

Bu işlev hala belgelendirilmemiştir; sadece değiştirge listesi mevcuttur.

Değiştirgeler

resim

imagecreatetruecolor() gibi bir resim oluşturma işlevinden dönen bir resim verisi.

rect

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

Dönen Değerler

Return cropped image resource on success başarısızlık durumunda FALSE döner.

add a note add a note

User Contributed Notes 2 notes

up
1
robert at woodst dot com
24 days ago
It appears that imagecrop() will output a black line along the bottom the resulting image until version 5.6.12. Your only choices are to upgrade PHP or use imagecopyresampled().

http://php.net/ChangeLog-5.php#5.6.12 (bug #67447)
up
-63
nangomusic at gmail dot com
2 years ago
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' =>0 , 'y' => 0, 'width' => $crop_measure, 'height'=> $crop_measure);
$thumb_im = imagecrop($im, $to_crop_array);

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