PHP Image Crop

umaxim
umaxim used Ask the Experts™
on
hi i need some crop system on php which will crop image to specific size. For example i have images 1200x500, 1320x720. So i want to crop it to 200x200. I want script to take center of it and crop side.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
JF0

Commented:
There are several examples on this page that will do what you want. Example 2 and 3 look especially good.

http://us2.php.net/manual/en/function.imagecopyresampled.php 

Author

Commented:
i know this example but i need some script wich will crop to perfect 200x200 pixels and cut long side out on left and right side or up and down.
Commented:
1200x500, 1320x720

(1200-200)/2=500
(500-200)/2=150

so

http://www.php.net/manual/en/function.imagick-cropimage.php
$x1=(1200-200)/2
$y1=(500-200)/2
$picture = new Imagick('animated_gif1.gif');
$picture->cropImage(200, 200, $x1, $y1);

$x2=(1320-200)/2
$y2=(720-200)/2
$picture = new Imagick('animated_gif2.gif');
$picture->cropImage(200, 200, $x2, $y2);

Open in new window

Perhaps these can be helpful for you :

http://www.phpimageeditor.se/

http://www.jpie.net/

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial