summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2012-03-19 10:44:57 +0000
committeralecpl <alec@alec.pl>2012-03-19 10:44:57 +0000
commita71a97fa49fb1c7fbe5e042b2cf6239f7372acb4 (patch)
tree1a4ebc634607aae7da0858d490f0da4fd2c1cfda /program/steps
parentd1e3430bfa1338268315e7425d0fbab995f5e107 (diff)
- Image resize with GD extension (#1488383)
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/addressbook/upload_photo.inc18
1 files changed, 9 insertions, 9 deletions
diff --git a/program/steps/addressbook/upload_photo.inc b/program/steps/addressbook/upload_photo.inc
index 039a7b202..195bac563 100644
--- a/program/steps/addressbook/upload_photo.inc
+++ b/program/steps/addressbook/upload_photo.inc
@@ -31,20 +31,19 @@ $OUTPUT->reset();
if ($filepath = $_FILES['_photo']['tmp_name']) {
// check file type and resize image
- $imageprop = rcmail::imageprops($_FILES['_photo']['tmp_name']);
+ $image = new rcube_image($_FILES['_photo']['tmp_name']);
+ $imageprop = $image->props();
if (in_array(strtolower($imageprop['type']), $IMAGE_TYPES)
- && $imageprop['width'] && $imageprop['height']
+ && $imageprop['width'] && $imageprop['height']
) {
- $maxsize = intval($RCMAIL->config->get('contact_photo_size', 160));
- $tmpfname = tempnam($RCMAIL->config->get('temp_dir'), 'rcmImgConvert');
+ $maxsize = intval($RCMAIL->config->get('contact_photo_size', 160));
+ $tmpfname = tempnam($RCMAIL->config->get('temp_dir'), 'rcmImgConvert');
$save_hook = 'attachment_upload';
// scale image to a maximum size
- if (($imageprop['width'] > $maxsize || $imageprop['height'] > $maxsize) &&
- (rcmail::imageconvert(array('in' => $filepath, 'out' => $tmpfname,
- 'size' => $maxsize.'x'.$maxsize, 'type' => $imageprop['type'])) !== false)) {
- $filepath = $tmpfname;
+ if (($imageprop['width'] > $maxsize || $imageprop['height'] > $maxsize) && $image->resize($maxsize, $tmpfname)) {
+ $filepath = $tmpfname;
$save_hook = 'attachment_save';
}
@@ -57,8 +56,9 @@ if ($filepath = $_FILES['_photo']['tmp_name']) {
'group' => 'contact',
));
}
- else
+ else {
$attachment['error'] = rcube_label('invalidimageformat');
+ }
if ($attachment['status'] && !$attachment['abort']) {
$file_id = $attachment['id'];