Overview

Packages

  • Ansel
  • None

Classes

  • Ansel
  • Ansel_Ajax_Application
  • Ansel_Ajax_Imple_EditCaption
  • Ansel_Ajax_Imple_EditFaces
  • Ansel_Ajax_Imple_EditGalleryFaces
  • Ansel_Ajax_Imple_Embed
  • Ansel_Ajax_Imple_GallerySlugCheck
  • Ansel_Ajax_Imple_ImageSaveGeotag
  • Ansel_Ajax_Imple_LocationAutoCompleter
  • Ansel_Ajax_Imple_MapLayerSelect
  • Ansel_Ajax_Imple_TagActions
  • Ansel_Ajax_Imple_ToggleGalleryActions
  • Ansel_Ajax_Imple_ToggleOtherGalleries
  • Ansel_Ajax_Imple_UploadNotification
  • Ansel_Api
  • Ansel_Exception
  • Ansel_Faces
  • Ansel_Faces_Base
  • Ansel_Faces_Facedetect
  • Ansel_Faces_User
  • Ansel_Factory_Faces
  • Ansel_Factory_Storage
  • Ansel_Factory_Styles
  • Ansel_Form_Ecard
  • Ansel_Form_Image
  • Ansel_Form_ImageDate
  • Ansel_Form_Upload
  • Ansel_Gallery
  • Ansel_Gallery_Decorator_Date
  • Ansel_GalleryMode_Base
  • Ansel_GalleryMode_Date
  • Ansel_GalleryMode_Normal
  • Ansel_Image
  • Ansel_ImageGenerator
  • Ansel_ImageGenerator_Mini
  • Ansel_ImageGenerator_PolaroidThumb
  • Ansel_ImageGenerator_PolaroidThumbStack
  • Ansel_ImageGenerator_RoundedThumb
  • Ansel_ImageGenerator_RoundedThumbStack
  • Ansel_ImageGenerator_Screen
  • Ansel_ImageGenerator_ShadowThumb
  • Ansel_ImageGenerator_ShadowThumbStack
  • Ansel_ImageGenerator_SquareThumb
  • Ansel_ImageGenerator_Thumb
  • Ansel_LoginTasks_SystemTask_Upgrade
  • Ansel_Report
  • Ansel_Report_letter
  • Ansel_Report_mail
  • Ansel_Report_tickets
  • Ansel_Search
  • Ansel_Search_exif
  • Ansel_Search_Tag
  • Ansel_Storage
  • Ansel_Style
  • Ansel_Tagger
  • Ansel_Test
  • Ansel_Tile_DateGallery
  • Ansel_Tile_Gallery
  • Ansel_Tile_Image
  • Ansel_View_Ansel
  • Ansel_View_Base
  • Ansel_View_EmbeddedRenderer_GalleryLink
  • Ansel_View_EmbeddedRenderer_Mini
  • Ansel_View_EmbeddedRenderer_Slideshow
  • Ansel_View_Gallery
  • Ansel_View_GalleryProperties
  • Ansel_View_GalleryRenderer_Base
  • Ansel_View_GalleryRenderer_Gallery
  • Ansel_View_GalleryRenderer_GalleryLightbox
  • Ansel_View_Image
  • Ansel_View_List
  • Ansel_View_Results
  • Ansel_View_Slideshow
  • Ansel_View_Upload
  • Ansel_Widget
  • Ansel_Widget_Actions
  • Ansel_Widget_Base
  • Ansel_Widget_GalleryFaces
  • Ansel_Widget_Geotag
  • Ansel_Widget_ImageFaces
  • Ansel_Widget_Links
  • Ansel_Widget_OtherGalleries
  • Ansel_Widget_OwnerFaces
  • Ansel_Widget_SimilarPhotos
  • Ansel_Widget_Tags
  • Ansel_XPPublisher
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * ImageGenerator to create a square thumbnail.
 4:  *
 5:  * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
 6:  *
 7:  * See the enclosed file COPYING for license information (GPL). If you
 8:  * did not receive this file, see http://www.horde.org/licenses/gpl.
 9:  *
10:  * @author Michael J. Rubinsky <mrubinsk@horde.org>
11:  * @package Ansel
12:  */
13: class Ansel_ImageGenerator_SquareThumb extends Ansel_ImageGenerator
14: {
15:     public function __construct($params)
16:     {
17:         parent::__construct($params);
18:         $this->title = _("Square Thumbnails");
19:         if (empty($this->_params['width'])) {
20:             $this->_params['width'] = $this->_style->width;
21:         }
22:         if (empty($this->_params['height'])) {
23:             $this->_params['height'] = $this->_style->height;
24:         }
25:     }
26: 
27:     /**
28:      *
29:      * @return Horde_Image
30:      */
31:     protected function _create()
32:     {
33:         // Take the largest requested dimension
34:         if (empty($this->_params['width'])) {
35:             $size = min($GLOBALS['conf']['thumbnail']['height'], $GLOBALS['conf']['thumbnail']['width']);
36:         } else {
37:             $size = min($this->_params['width'], $this->_params['height']);
38:         }
39: 
40:         // Use smartcrop algorithm if we have it, otherwise a plain center crop.
41:         if (Ansel::isAvailable('SmartCrop') && $GLOBALS['conf']['image']['smartcrop']) {
42:             $this->_image->addEffect('SmartCrop', array('width' => $size, 'height' => $size));
43:         } else {
44:             $this->_image->addEffect('CenterCrop', array('width' => $size, 'height' => $size));
45:         }
46:         $this->_image->applyEffects();
47: 
48:         if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
49:             try {
50:                 $this->_image->addEffect('Unsharpmask',
51:                                          array('radius' => $GLOBALS['conf']['thumbnail']['radius'],
52:                                                'threshold' => $GLOBALS['conf']['thumbnail']['threshold'],
53:                                                'amount' => $GLOBALS['conf']['thumbnail']['amount']));
54:                 $this->_image->applyEffects();
55:             } catch (Horde_Image_Exception $e) {
56:                 throw new Ansel_Exception($e);
57:             }
58:         }
59: 
60:         return $this->_image->getHordeImage();
61:     }
62: 
63: }
64: 
API documentation generated by ApiGen