use image utils
This commit is contained in:
parent
6f8a9549f2
commit
2c158e6844
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
use \LAM\TYPES\TypeManager;
|
use \LAM\TYPES\TypeManager;
|
||||||
use LAM\TYPES\ConfiguredType;
|
use LAM\TYPES\ConfiguredType;
|
||||||
|
use LAM\ImageUtils\ImageManipulationFactory;
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||||
|
@ -1829,11 +1830,11 @@ class windowsUser extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
if (isset($_POST['form_subpage_' . get_class($this) . '_attributes_crop'])) {
|
if (isset($_POST['form_subpage_' . get_class($this) . '_attributes_crop'])) {
|
||||||
$messages = array();
|
$messages = array();
|
||||||
$image = new Imagick();
|
|
||||||
try {
|
try {
|
||||||
$image->readImageBlob($this->attributes['jpegPhoto'][0]);
|
include_once dirname(__FILE__) . '/../imageutils.inc';
|
||||||
$image->cropimage($_POST['croppingDataWidth'], $_POST['croppingDataHeight'], $_POST['croppingDataX'], $_POST['croppingDataY']);
|
$imageManipulator = ImageManipulationFactory::getImageManipulator($this->attributes['jpegPhoto'][0]);
|
||||||
$this->attributes['jpegPhoto'][0] = $image->getimageblob();
|
$imageManipulator->crop($_POST['croppingDataX'], $_POST['croppingDataY'], $_POST['croppingDataWidth'], $_POST['croppingDataHeight']);
|
||||||
|
$this->attributes['jpegPhoto'][0] = $imageManipulator->getImageData();
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$msg = $this->messages['file'][2];
|
$msg = $this->messages['file'][2];
|
||||||
|
@ -1864,18 +1865,17 @@ class windowsUser extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
// convert to JPG
|
// convert to JPG
|
||||||
$image = new Imagick();
|
|
||||||
try {
|
try {
|
||||||
$image->readImageBlob($data);
|
include_once dirname(__FILE__) . '/../imageutils.inc';
|
||||||
|
$imageManipulator = ImageManipulationFactory::getImageManipulator($data);
|
||||||
// resize if maximum values specified
|
// resize if maximum values specified
|
||||||
if (!empty($this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0]) || !empty($this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0])) {
|
if (!empty($this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0]) || !empty($this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0])) {
|
||||||
$maxWidth = empty($this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0]) ? $image->getimagewidth() : $this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0];
|
$maxWidth = empty($this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0]) ? $imageManipulator->getWidth() : $this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0];
|
||||||
$maxHeight = empty($this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0]) ? $image->getimageheight() : $this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0];
|
$maxHeight = empty($this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0]) ? $imageManipulator->getHeight() : $this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0];
|
||||||
$image->thumbnailimage($maxWidth, $maxHeight, true);
|
$imageManipulator->thumbnail($maxWidth, $maxHeight);
|
||||||
}
|
}
|
||||||
$image->setImageCompression(Imagick::COMPRESSION_JPEG);
|
$imageManipulator->convertToJpeg();
|
||||||
$image->setImageFormat('jpeg');
|
$data = $imageManipulator->getImageData();
|
||||||
$data = $image->getimageblob();
|
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$msg = $this->messages['file'][2];
|
$msg = $this->messages['file'][2];
|
||||||
|
|
Loading…
Reference in New Issue