summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-04-22 01:50:46 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-04-22 01:50:46 +0200
commit651de1e5884dd6ce43fd9d1cfb37a2bb4fb5728e (patch)
treef200df07a3316eb10dfeefb0c04074042689a46c
parent9e3242d05ee666ef8d3ceaf038302e7254610f00 (diff)
downloadnextcloud-server-651de1e5884dd6ce43fd9d1cfb37a2bb4fb5728e.tar.gz
nextcloud-server-651de1e5884dd6ce43fd9d1cfb37a2bb4fb5728e.zip
Contacts: Fix error on photo crop.
-rw-r--r--apps/contacts/ajax/savecrop.php13
1 files changed, 6 insertions, 7 deletions
diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php
index 0df4e1998cb..73ac521e04b 100644
--- a/apps/contacts/ajax/savecrop.php
+++ b/apps/contacts/ajax/savecrop.php
@@ -44,19 +44,15 @@ function bailOut($msg) {
$image = null;
-$x1 = (isset($_POST['x1']) && $_POST['x1']) ? $_POST['x1'] : -1;
+$x1 = (isset($_POST['x1']) && $_POST['x1']) ? $_POST['x1'] : 0;
//$x2 = isset($_POST['x2']) ? $_POST['x2'] : -1;
-$y1 = (isset($_POST['y1']) && $_POST['y1']) ? $_POST['y1'] : -1;
+$y1 = (isset($_POST['y1']) && $_POST['y1']) ? $_POST['y1'] : 0;
//$y2 = isset($_POST['y2']) ? $_POST['y2'] : -1;
$w = (isset($_POST['w']) && $_POST['w']) ? $_POST['w'] : -1;
$h = (isset($_POST['h']) && $_POST['h']) ? $_POST['h'] : -1;
$tmp_path = isset($_POST['tmp_path']) ? $_POST['tmp_path'] : '';
$id = isset($_POST['id']) ? $_POST['id'] : '';
-if(in_array(-1, array($x1, $y1, $w, $h))) {
- bailOut('Wrong crop dimensions: '.implode(', ', array($x1, $y1, $w, $h)));
-}
-
if($tmp_path == '') {
bailOut('Missing path to temporary file.');
}
@@ -70,6 +66,9 @@ OC_Log::write('contacts','savecrop.php: files: '.$tmp_path.' exists: '.file_exi
if(file_exists($tmp_path)) {
$image = new OC_Image();
if($image->loadFromFile($tmp_path)) {
+ $w = ($w != -1 ? $w : $image->width());
+ $h = ($h != -1 ? $h : $image->height());
+ OC_Log::write('contacts','savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, OC_Log::DEBUG);
if($image->crop($x1, $y1, $w, $h)) {
if($image->resize(200)) {
$tmpfname = tempnam("/tmp", "occCropped"); // create a new file because of caching issues.
@@ -81,7 +80,7 @@ if(file_exists($tmp_path)) {
bailOut('Error getting contact object.');
}
if($card->__isset('PHOTO')) {
- OC_Log::write('contacts','savecrop.php: files: PHOTO property exists.', OC_Log::DEBUG);
+ OC_Log::write('contacts','savecrop.php: PHOTO property exists.', OC_Log::DEBUG);
$property = $card->__get('PHOTO');
if(!$property) {
unlink($tmpfname);