Merge branch 'master' into noglob

This commit is contained in:
origami11@yandex.ru 2022-11-18 16:07:32 +03:00
commit 7d35a8f3f0
27 changed files with 430 additions and 288 deletions

View file

@ -10,14 +10,14 @@ class TemplateImage
{
static $listfiles = array('jpg' => 'jpeg', 'gif' => 'gif', 'png' => 'png', 'bmp' => 'wbmp');
static $listfonts = array(
'georgia' => 'georgia.ttf',
'georgiabd' => 'georgiab.ttf',
'georgiaz' => 'georgiaz.ttf',
'times' => 'times.ttf',
'timesbd' => 'timesbd.ttf',
'arial' => 'arial.ttf',
'arialbd' => 'arialbd.ttf',
'tahoma' => 'tahoma.ttf',
'georgia' => 'georgia.ttf',
'georgiabd' => 'georgiab.ttf',
'georgiaz' => 'georgiaz.ttf',
'times' => 'times.ttf',
'timesbd' => 'timesbd.ttf',
'arial' => 'arial.ttf',
'arialbd' => 'arialbd.ttf',
'tahoma' => 'tahoma.ttf',
'calibri' => 'calibri.ttf',
'calibribd' => 'calibrib.ttf',
'calibrii' => 'calibrii.ttf',
@ -29,7 +29,7 @@ class TemplateImage
'miriad' => 'MyriadPro-Cond.ttf',
'miriadbd' => 'MyriadPro-BoldCond.ttf'
);
);
protected $src;
protected $context = array();
@ -38,6 +38,8 @@ class TemplateImage
protected $image;
protected $_prepare = true;
public $debug = false;
public $filename;
public $resource;
public $resource;
public $filename;
@ -63,14 +65,14 @@ class TemplateImage
/**
* Путь у шрифтам
*/
function fontPath($path)
function fontPath($path)
{
assert(is_string($path));
$this->base = $path;
}
function set($name, $value)
function set($name, $value)
{
assert(is_string($name));
@ -91,11 +93,11 @@ class TemplateImage
/**
* Создает изображение из файла
*/
function imagefromfile($file)
function imagefromfile($file)
{
assert(is_string($file));
$suffix = pathinfo($file, PATHINFO_EXTENSION);
$suffix = pathinfo($file, PATHINFO_EXTENSION);
if (array_key_exists($suffix, self::$listfiles)) {
return call_user_func('imagecreatefrom' . self::$listfiles[$suffix], $file);
}
@ -103,12 +105,12 @@ class TemplateImage
}
function getFontFile($name)
{
{
assert(is_string($name));
if(array_key_exists(strtolower($name), self::$listfonts)) {
return $this->base . self::$listfonts[$name];
}
}
return $this->base . 'arial.ttf';
}
@ -162,8 +164,8 @@ class TemplateImage
}
function setSize($new_width, $new_height)
{
$width = imagesx($this->image);
{
$width = imagesx($this->image);
$height = imagesy($this->image);
if ($new_height == null) {
$new_height = ceil($height * $new_width / $width);
@ -174,7 +176,7 @@ class TemplateImage
imagecopyresampled($image_p, $this->image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// imagecopyresized($image_p, $this->image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$this->image = $image_p;
}
}
function prepare() {
if($this->_prepare) {
@ -205,4 +207,3 @@ class TemplateImage
}
}
}