3
Stupid Image Utils - part of
4
ExtremeDating - a Hackathon 2013 project.
5
Copyright (C) 2013 Gustav Hartvigsson <gustav.hartvigsson@gmail.com>
7
This program is free software: you can redistribute it and/or modify
8
it under the terms of the GNU Lesser General Public License as
9
published by the Free Software Foundation, either version 3 of the
10
License, or (at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU Affero General Public License for more details.
17
You should have received a copy of the GNU Lesser General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
20
function stupid_rescale_and_crop (Imagick $image, $Height, $Width) {
22
$imageprops = $image->getImageGeometry();
23
if ($imageprops['height'] == $imageprops['width'] ) {
24
$image->resizeImage($Height, $Width, imagick::FILTER_LANCZOS, true, false);
25
} elseif ($imageprops['height'] > $imageprops['width'] ){
26
$image->resizeImage($Height,0 , imagick::FILTER_LANCZOS, true, false);
27
} elseif ($imageprops['height'] < $imageprops['width'] ){
28
$image->resizeImage(0, $Width, imagick::FILTER_LANCZOS, true, false);
30
$image->cropImage(280,280,0,0);
35
function stupid_convert_and_rescale (Imagick $image, $Height, $Width, $format ) {
36
$image = stupid_rescale_and_crop($image, $Height, $Width);
37
$image->setFormat($format);