mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-02 11:29:23 +01:00
* scaling now addressbook images uploaded via CardDAV or SyncML to 60 pixel width like already done for web GUI
This commit is contained in:
parent
647ab3e449
commit
f45cb1b996
1927
addressbook/inc/class.addressbook_bo.inc.php
Executable file
1927
addressbook/inc/class.addressbook_bo.inc.php
Executable file
File diff suppressed because it is too large
Load Diff
@ -1220,9 +1220,11 @@ class addressbook_ui extends addressbook_bo
|
||||
case 'apply':
|
||||
if ($content['delete_photo']) $content['jpegphoto'] = null;
|
||||
if (is_array($content['upload_photo']) && !empty($content['upload_photo']['tmp_name']) &&
|
||||
$content['upload_photo']['tmp_name'] != 'none')
|
||||
$content['upload_photo']['tmp_name'] != 'none' &&
|
||||
($f = fopen($content['upload_photo']['tmp_name'],'r')))
|
||||
{
|
||||
$content['jpegphoto'] = $this->resize_photo($content['upload_photo']);
|
||||
$content['jpegphoto'] = $this->resize_photo($f);
|
||||
fclose($f);
|
||||
unset($content['upload_photo']);
|
||||
}
|
||||
$links = false;
|
||||
@ -1553,50 +1555,6 @@ class addressbook_ui extends addressbook_bo
|
||||
return $response->getXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* resizes the uploaded photo to 60*80 pixel and returns it
|
||||
*
|
||||
* @param array $file info uploaded file
|
||||
* @return string with resized jpeg photo
|
||||
*/
|
||||
function resize_photo($file)
|
||||
{
|
||||
switch($file['type'])
|
||||
{
|
||||
case 'image/gif':
|
||||
$upload = imagecreatefromgif($file['tmp_name']);
|
||||
break;
|
||||
case 'image/jpeg':
|
||||
case 'image/pjpeg':
|
||||
$upload = imagecreatefromjpeg($file['tmp_name']);
|
||||
break;
|
||||
case 'image/png':
|
||||
case 'image/x-png':
|
||||
$upload = imagecreatefrompng($file['tmp_name']);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
if (!$upload) return null;
|
||||
|
||||
list($src_w,$src_h) = getimagesize($file['tmp_name']);
|
||||
|
||||
// scale the image to a width of 60 and a height according to the proportion of the source image
|
||||
$photo = imagecreatetruecolor($dst_w = 60,$dst_h = round($src_h * 60 / $src_w));
|
||||
imagecopyresized($photo,$upload,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
|
||||
//echo "<p>imagecopyresized(\$photo,\$upload,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);</p>\n";
|
||||
|
||||
ob_start();
|
||||
imagejpeg($photo,'',90);
|
||||
$jpeg = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
imagedestroy($photo);
|
||||
imagedestroy($upload);
|
||||
|
||||
return $jpeg;
|
||||
}
|
||||
|
||||
function view($content=null)
|
||||
{
|
||||
if(is_array($content))
|
||||
|
Loading…
Reference in New Issue
Block a user