summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a3ae805)
raw | patch | inline | side by side (parent: a3ae805)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 13 Sep 2010 07:10:22 +0000 (07:10 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 13 Sep 2010 07:10:22 +0000 (07:10 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19609 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-core/plugins/personal/generic/class_user.inc b/gosa-core/plugins/personal/generic/class_user.inc
index 3062a9a08a4ec9b0e495a9e9462d4f64d1356f14..c677268d0f5af813a001f606cb068e4963ada0f6 100644 (file)
} else {
- /* Fallback if there's no image magick inside PHP */
- if (function_exists("imagick_blob2image")){
-
- /* Load the new uploaded Photo */
- if(!$handle = imagick_blob2image($this->photoData)) {
- new log("debug","users/".get_class($this),$this->dn,array(),"Could not access uploaded image");
- }
-
- /* Resizing image to 147x200 and blur */
- if(!imagick_resize($handle,147,200,IMAGICK_FILTER_GAUSSIAN,0)){
- new log("debug","users/".get_class($this),$this->dn,array(),"Could not resize uploaded image");
- }
-
- /* Converting image to JPEG */
- if(!imagick_convert($handle,"JPEG")) {
- new log("debug","users/".get_class($this),$this->dn,array(),"Could not convert uploaded image to jepg");
- }
+ if(class_exists('Imagick')){
+
+ $im = new Imagick();
+ $im->readImageBlob($this->photoData);
+ $im->setImageOpacity(1.0);
+ $im->resizeImage(147,200,Imagick::FILTER_UNDEFINED,0.5,TRUE);
+ $im->setCompressionQuality(90);
+ $im->setImageFormat('jpeg');
+ $this->attrs["jpegPhoto"] = $im->getImageBlob();
+
+ }elseif (exec('convert')){
+ /* Get temporary file name for conversation */
+ $fname = tempnam (TEMP_DIR, "GOsa");
+
+ /* Open file and write out photoData */
+ $fp = fopen ($fname, "w");
+ fwrite ($fp, $this->photoData);
+ fclose ($fp);
+
+ /* Build conversation query. Filename is generated automatically, so
+ we do not need any special security checks. Exec command and save
+ output. For PHP safe mode, you'll need a configuration which respects
+ image magick as executable... */
+ $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
+ @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
+ $query, "Execute");
+
+ /* Read data written by convert */
+ $output= "";
+ $sh= popen($query, 'r');
+ while (!feof($sh)){
+ $output.= fread($sh, 4096);
+ }
+ pclose($sh);
- /* Creating binary Code for the Image */
- if(!$dump = imagick_image2blob($handle)){
- new log("debug","users/".get_class($this),$this->dn,array(),"Could not create new user image");
- }
+ unlink($fname);
- /* Sending Image */
- $output= $dump;
+ /* Save attribute */
+ $this->attrs["jpegPhoto"] = $output;
+ }else{
+ msg_dialog::display(_("Error"),
+ _("Cannot save user picture, GOsa requires the package 'imagemagick' or 'php5-imagick' to be installed!"),
+ ERROR_DIALOG);
- /* Save attribute */
- $this->attrs["jpegPhoto"] = $output;
- }elseif (exec('convert')){
- /* Get temporary file name for conversation */
- $fname = tempnam (TEMP_DIR, "GOsa");
-
- /* Open file and write out photoData */
- $fp = fopen ($fname, "w");
- fwrite ($fp, $this->photoData);
- fclose ($fp);
-
- /* Build conversation query. Filename is generated automatically, so
- we do not need any special security checks. Exec command and save
- output. For PHP safe mode, you'll need a configuration which respects
- image magick as executable... */
- $query= "convert -size 147x200 $fname -resize 147x200 +profile \"*\" -";
- @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
- $query, "Execute");
-
- /* Read data written by convert */
- $output= "";
- $sh= popen($query, 'r');
- while (!feof($sh)){
- $output.= fread($sh, 4096);
}
- pclose($sh);
-
- unlink($fname);
-
- /* Save attribute */
- $this->attrs["jpegPhoto"] = $output;
- }else{
- msg_dialog::display(_("Error"),
- _("Cannot save user picture, GOsa requires the package 'imagemagick' or 'php5-imagick' to be installed!"),
- ERROR_DIALOG);
-
- }
}
/* Save data. Using 'modify' implies that the entry is already present, use 'add' for
diff --git a/gosa-core/plugins/personal/generic/generic.tpl b/gosa-core/plugins/personal/generic/generic.tpl
index 56f2dbef4e5512f417502c1cda9ba3f86ea27a53..fffdffd031c7f943e0b2865e7b73821423707757 100644 (file)
{if !$userPicture_is_readable}
<img src="plugins/users/images/default.jpg" alt=''>
{else}
- <img src="getbin.php?rand={$rand}" alt='' style='width:147px; vertical-align: middle;' >
+ <img src="getbin.php?rand={$rand}" alt='' style='max-width:147px; max-height: 200px; vertical-align: middle;' >
{/if}
</td>
</tr>
diff --git a/gosa-core/plugins/personal/generic/generic_picture.tpl b/gosa-core/plugins/personal/generic/generic_picture.tpl
index a78630dab094aad9708dbd3d111090b61cddd712..0fcea1931d4923825ef6569a127d8eca94c34787 100644 (file)
<h3>{t}User picture{/t}</h3>
<table summary="{t}The users picture{/t}">
<tr>
- <td style='width:147px; height:200px; background-color:gray;'>
-
- <img src="getbin.php?rand={$rand}" alt='' style='width:147px;' >
+ <td style='width:147px; height:200px; background-color:gray; vertical-align: middle;'>
+ <img src="getbin.php?rand={$rand}" alt='' style='max-width:147px; max-height: 200px; vertical-align: middle;' >
</td>
</tr>
</table>