Move constant.

1.10.x
Julio Montoya 11 years ago
parent 74ca0d17bc
commit 1ac63713ef
  1. 2
      main/inc/lib/api.lib.php
  2. 55
      main/inc/lib/image.lib.php

@ -538,6 +538,8 @@ define ('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
define('SHORTCUTS_HORIZONTAL', 0);
define('SHORTCUTS_VERTICAL', 1);
// Image class
define('IMAGE_PROCESSOR', 'gd'); // 'imagick' or 'gd' strings
/**
* Inclusion of internationalization libraries

@ -1,21 +1,22 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Image class
* This class provides a layer to manage images
* @author Julio Montoya <gugli100@gmail.com>
* @package chamilo.include.image
* @todo move in a DB configuration setting
*/
define('IMAGE_PROCESSOR', 'gd'); // imagick or gd strings
/**
* Image class
* @package chamilo.include.image
*/
class Image
{
public $image_wrapper = null;
function __construct($path)
/**
* Image constructor.
* @param string $path
*/
public function __construct($path)
{
$path = preg_match(VALID_WEB_PATH, $path) ? (api_is_internal_path(
$path
@ -76,13 +77,13 @@ class Image
*/
abstract class ImageWrapper
{
var $debug = true;
var $path;
var $width;
var $height;
var $type;
var $allowed_extensions = array('jpeg', 'jpg', 'png', 'gif');
var $image_validated = false;
public $debug = true;
public $path;
public $width;
public $height;
public $type;
public $allowed_extensions = array('jpeg', 'jpg', 'png', 'gif');
public $image_validated = false;
public function __construct($path)
{
@ -118,13 +119,16 @@ abstract class ImageWrapper
*/
class ImagickWrapper extends ImageWrapper
{
var $image;
var $filter = Imagick::FILTER_LANCZOS;
public $image;
public $filter = Imagick::FILTER_LANCZOS;
public function __construct($path) {
public function __construct($path)
{
parent::__construct($path);
}
public function set_image_wrapper() {
public function set_image_wrapper()
{
if ($this->debug) error_log('Image::set_image_wrapper loaded');
try {
if (file_exists($this->path)) {
@ -141,7 +145,8 @@ class ImagickWrapper extends ImageWrapper
}
}
public function fill_image_info() {
public function fill_image_info()
{
$image_info = $this->image->identifyImage();
$this->width = $image_info['geometry']['width'];
@ -154,7 +159,8 @@ class ImagickWrapper extends ImageWrapper
}
}
public function get_image_size() {
public function get_image_size()
{
$imagesize = array('width'=>0,'height'=>0);
if ($this->image_validated) {
$imagesize = $this->image->getImageGeometry();
@ -163,7 +169,8 @@ class ImagickWrapper extends ImageWrapper
}
//@todo implement border logic case for Imagick
public function resize($thumbw, $thumbh, $border, $specific_size = false) {
public function resize($thumbw, $thumbh, $border, $specific_size = false)
{
if (!$this->image_validated) return false;
if ($specific_size) {
@ -179,7 +186,8 @@ class ImagickWrapper extends ImageWrapper
$this->height = $thumbh;
}
public function send_image($file = '', $compress = -1, $convert_file_to = null) {
public function send_image($file = '', $compress = -1, $convert_file_to = null)
{
if (!$this->image_validated) return false;
$type = $this->type;
if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) {
@ -223,7 +231,7 @@ class ImagickWrapper extends ImageWrapper
*/
class GDWrapper extends ImageWrapper
{
var $bg;
public $bg;
function __construct($path) {
parent::__construct($path);
@ -327,7 +335,8 @@ class GDWrapper extends ImageWrapper
@imagedestroy($src_img);
}
public function send_image($file = '', $compress = -1, $convert_file_to = null) {
public function send_image($file = '', $compress = -1, $convert_file_to = null)
{
if (!$this->image_validated) return false;
$compress = (int)$compress;
$type = $this->type;

Loading…
Cancel
Save