From 4f94a433309a1264ddea82173ff8d06c3abea18d Mon Sep 17 00:00:00 2001 From: Alex Bond Date: Fri, 30 Jan 2015 19:28:19 -0800 Subject: [PATCH] Update of class.upload.php to latest version --- lang/class.upload.ca_CA.php | 0 lang/class.upload.cs_CS.php | 0 lang/class.upload.de_DE.php | 0 lang/class.upload.el_GR.php | 0 lang/class.upload.es_ES.php | 0 lang/class.upload.et_EE.php | 0 lang/class.upload.fr_FR.php | 0 lang/class.upload.he_IL.php | 0 lang/class.upload.hr_HR.php | 0 lang/class.upload.id_ID.php | 0 lang/class.upload.it_IT.php | 0 lang/class.upload.nl_NL.php | 0 lang/class.upload.no_NO.php | 0 lang/class.upload.pl_PL.php | 0 lang/class.upload.pt_BR.php | 0 lang/class.upload.ro_RO.php | 0 lang/class.upload.ru_RU.php | 0 lang/class.upload.ru_RU.windows-1251.php | 0 lang/class.upload.sk_SK.php | 0 lang/class.upload.sv_SE.php | 0 lang/class.upload.tr_TR.php | 0 lang/class.upload.uk_UA.php | 0 lang/class.upload.uk_UA.windows-1251.php | 0 lang/class.upload.vn_VN.php | 0 lang/class.upload.xx_XX.php | 0 lang/class.upload.zh_CN.gb-2312.php | 0 lang/class.upload.zh_CN.php | 0 lang/class.upload.zh_TW.php | 0 upload.php | 986 +++++------------------ 29 files changed, 213 insertions(+), 773 deletions(-) mode change 100644 => 100755 lang/class.upload.ca_CA.php mode change 100644 => 100755 lang/class.upload.cs_CS.php mode change 100644 => 100755 lang/class.upload.de_DE.php mode change 100644 => 100755 lang/class.upload.el_GR.php mode change 100644 => 100755 lang/class.upload.es_ES.php mode change 100644 => 100755 lang/class.upload.et_EE.php mode change 100644 => 100755 lang/class.upload.fr_FR.php mode change 100644 => 100755 lang/class.upload.he_IL.php mode change 100644 => 100755 lang/class.upload.hr_HR.php mode change 100644 => 100755 lang/class.upload.id_ID.php mode change 100644 => 100755 lang/class.upload.it_IT.php mode change 100644 => 100755 lang/class.upload.nl_NL.php mode change 100644 => 100755 lang/class.upload.no_NO.php mode change 100644 => 100755 lang/class.upload.pl_PL.php mode change 100644 => 100755 lang/class.upload.pt_BR.php mode change 100644 => 100755 lang/class.upload.ro_RO.php mode change 100644 => 100755 lang/class.upload.ru_RU.php mode change 100644 => 100755 lang/class.upload.ru_RU.windows-1251.php mode change 100644 => 100755 lang/class.upload.sk_SK.php mode change 100644 => 100755 lang/class.upload.sv_SE.php mode change 100644 => 100755 lang/class.upload.tr_TR.php mode change 100644 => 100755 lang/class.upload.uk_UA.php mode change 100644 => 100755 lang/class.upload.uk_UA.windows-1251.php mode change 100644 => 100755 lang/class.upload.vn_VN.php mode change 100644 => 100755 lang/class.upload.xx_XX.php mode change 100644 => 100755 lang/class.upload.zh_CN.gb-2312.php mode change 100644 => 100755 lang/class.upload.zh_CN.php mode change 100644 => 100755 lang/class.upload.zh_TW.php diff --git a/lang/class.upload.ca_CA.php b/lang/class.upload.ca_CA.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.cs_CS.php b/lang/class.upload.cs_CS.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.de_DE.php b/lang/class.upload.de_DE.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.el_GR.php b/lang/class.upload.el_GR.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.es_ES.php b/lang/class.upload.es_ES.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.et_EE.php b/lang/class.upload.et_EE.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.fr_FR.php b/lang/class.upload.fr_FR.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.he_IL.php b/lang/class.upload.he_IL.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.hr_HR.php b/lang/class.upload.hr_HR.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.id_ID.php b/lang/class.upload.id_ID.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.it_IT.php b/lang/class.upload.it_IT.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.nl_NL.php b/lang/class.upload.nl_NL.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.no_NO.php b/lang/class.upload.no_NO.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.pl_PL.php b/lang/class.upload.pl_PL.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.pt_BR.php b/lang/class.upload.pt_BR.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.ro_RO.php b/lang/class.upload.ro_RO.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.ru_RU.php b/lang/class.upload.ru_RU.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.ru_RU.windows-1251.php b/lang/class.upload.ru_RU.windows-1251.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.sk_SK.php b/lang/class.upload.sk_SK.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.sv_SE.php b/lang/class.upload.sv_SE.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.tr_TR.php b/lang/class.upload.tr_TR.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.uk_UA.php b/lang/class.upload.uk_UA.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.uk_UA.windows-1251.php b/lang/class.upload.uk_UA.windows-1251.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.vn_VN.php b/lang/class.upload.vn_VN.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.xx_XX.php b/lang/class.upload.xx_XX.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.zh_CN.gb-2312.php b/lang/class.upload.zh_CN.gb-2312.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.zh_CN.php b/lang/class.upload.zh_CN.php old mode 100644 new mode 100755 diff --git a/lang/class.upload.zh_TW.php b/lang/class.upload.zh_TW.php old mode 100644 new mode 100755 diff --git a/upload.php b/upload.php index aa4d488..0aca595 100644 --- a/upload.php +++ b/upload.php @@ -2,9 +2,7 @@ // +------------------------------------------------------------------------+ // | class.upload.php | // +------------------------------------------------------------------------+ -// | Copyright (c) Colin Verot 2003-2010. All rights reserved. | -// | Version 0.32 | -// | Last modified 15/01/2013 | +// | Copyright (c) Colin Verot 2003-2014. All rights reserved. | // | Email colin@verot.net | // | Web http://www.verot.net | // +------------------------------------------------------------------------+ @@ -26,582 +24,14 @@ // | of the script so other people can use them as well. | // | This script is free to use, don't abuse. | // +------------------------------------------------------------------------+ -// + /** * Class upload * - * @version 0.32 * @author Colin Verot * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @copyright Colin Verot - * @package cmf - * @subpackage external - */ - -/** - * Class upload - * - * What does it do? - * - * It manages file uploads for you. In short, it manages the uploaded file, - * and allows you to do whatever you want with the file, especially if it - * is an image, and as many times as you want. - * - * It is the ideal class to quickly integrate file upload in your site. - * If the file is an image, you can convert, resize, crop it in many ways. - * You can also apply filters, add borders, text, watermarks, etc... - * That's all you need for a gallery script for instance. Supported formats - * are PNG, JPG, GIF and BMP. - * - * You can also use the class to work on local files, which is especially - * useful to use the image manipulation features. The class also supports - * Flash uploaders. - * - * The class works with PHP 4 and 5, and its error messages can - * be localized at will. - * - * How does it work? - * - * You instanciate the class with the $_FILES['my_field'] array - * where my_field is the field name from your upload form. - * The class will check if the original file has been uploaded - * to its temporary location (alternatively, you can instanciate - * the class with a local filename). - * - * You can then set a number of processing variables to act on the file. - * For instance, you can rename the file, and if it is an image, - * convert and resize it in many ways. - * You can also set what will the class do if the file already exists. - * - * Then you call the function {@link process} to actually perform the actions - * according to the processing parameters you set above. - * It will create new instances of the original file, - * so the original file remains the same between each process. - * The file will be manipulated, and copied to the given location. - * The processing variables will be reset once it is done. - * - * You can repeat setting up a new set of processing variables, - * and calling {@link process} again as many times as you want. - * When you have finished, you can call {@link clean} to delete - * the original uploaded file. - * - * If you don't set any processing parameters and call {@link process} - * just after instanciating the class. The uploaded file will be simply - * copied to the given location without any alteration or checks. - * - * Don't forget to add enctype="multipart/form-data" in your form - * tag
if you want your form to upload the file. - * - * How to use it?
- * Create a simple HTML file, with a form such as: - *
- * 
- *   
- *   
- * 
- * 
- * Create a file called upload.php: - *
- *  $handle = new upload($_FILES['image_field']);
- *  if ($handle->uploaded) {
- *      $handle->file_new_name_body   = 'image_resized';
- *      $handle->image_resize         = true;
- *      $handle->image_x              = 100;
- *      $handle->image_ratio_y        = true;
- *      $handle->process('/home/user/files/');
- *      if ($handle->processed) {
- *          echo 'image resized';
- *          $handle->clean();
- *      } else {
- *          echo 'error : ' . $handle->error;
- *      }
- *  }
- * 
- * - * How to process a file uploaded via XMLHttpRequest?
- * Use the class as following, the rest being the same as above: - *
- *  $handle = new upload('php:'.$_SERVER['HTTP_X_FILE_NAME']);
- * 
- * Prefixing the argument with "php:" tells the class to retrieve the uploaded data - * in php://input, and the rest is the stream's filename, which is generally in - * $_SERVER['HTTP_X_FILE_NAME']. But you can use any other name you see fit: - *
- *  $handle = new upload('php:mycustomname.ext');
- * 
- * - * How to process local files?
- * Use the class as following, the rest being the same as above: - *
- *  $handle = new upload('/home/user/myfile.jpg');
- * 
- * - * How to set the language?
- * Instantiate the class with a second argument being the language code: - *
- *  $handle = new upload($_FILES['image_field'], 'fr_FR');
- *  $handle = new upload('/home/user/myfile.jpg', 'fr_FR');
- * 
- * - * How to output the resulting file or picture directly to the browser?
- * Simply call {@link process}() without an argument (or with null as first argument): - *
- *  $handle = new upload($_FILES['image_field']);
- *  header('Content-type: ' . $handle->file_src_mime);
- *  echo $handle->Process();
- *  die();
- * 
- * Or if you want to force the download of the file: - *
- *  $handle = new upload($_FILES['image_field']);
- *  header('Content-type: ' . $handle->file_src_mime);
- *  header("Content-Disposition: attachment; filename=".rawurlencode($handle->file_src_name).";");
- *  echo $handle->Process();
- *  die();
- * 
- * - * Processing parameters (reset after each process) - * - * - * The following eight settings can be used to invalidate an upload if the file is an image (note that open_basedir restrictions prevent the use of these settings) - * - * - * The following variables are used only if {@link image_resize} == true - * - * Use either one of the following - * - * The following image manipulations require GD2+ - * - * - * - * - * - * - * - * Values that can be read before calling {@link process}() - * - * If the file is a supported image type (and open_basedir restrictions allow it) - * - * - * Values that can be read after calling {@link process}() - * - * If the file is a supported image type - * - * - * Requirements - * - * Most of the image operations require GD. GD2 is greatly recommended - * - * The class requires PHP 4.3+, and is compatible with PHP5 - * - * Changelog - * - * - * @package cmf - * @subpackage external */ class upload { @@ -774,6 +204,14 @@ class upload { */ var $image_dst_y; + /** + * Destination image type (png, gif, jpg or bmp) + * + * @access public + * @var integer + */ + var $image_dst_type; + /** * Supported image formats * @@ -907,7 +345,7 @@ class upload { var $mime_check; /** - * Set this variable to false in the init() function if you don't want to check the MIME + * Set this variable to false in the init() function if you don't want to check the MIME * with Fileinfo PECL extension. On some systems, Fileinfo is known to be buggy, and you * may want to deactivate it in the class code directly. * @@ -924,7 +362,7 @@ class upload { var $mime_fileinfo; /** - * Set this variable to false in the init() function if you don't want to check the MIME + * Set this variable to false in the init() function if you don't want to check the MIME * with UNIX file() command * * This variable is set to true by default for security reason @@ -935,7 +373,7 @@ class upload { var $mime_file; /** - * Set this variable to false in the init() function if you don't want to check the MIME + * Set this variable to false in the init() function if you don't want to check the MIME * with the magic.mime file * * The function mime_content_type() will be deprecated, @@ -949,7 +387,7 @@ class upload { var $mime_magic; /** - * Set this variable to false in the init() function if you don't want to check the MIME + * Set this variable to false in the init() function if you don't want to check the MIME * with getimagesize() * * The class tries to get a MIME type from getimagesize() @@ -1035,7 +473,7 @@ class upload { * * Default value is the value upload_max_filesize from php.ini * - * Value in bytes (integer) or shorthand byte values (string) is allowed. + * Value in bytes (integer) or shorthand byte values (string) is allowed. * The available options are K (for Kilobytes), M (for Megabytes) and G (for Gigabytes) * * @access public @@ -1272,7 +710,7 @@ class upload { /** * Compression level for PNG images - * + * * Between 1 (fast but large files) and 9 (slow but smaller files) * * Default value is null (Zlib default) @@ -1298,7 +736,7 @@ class upload { * The JPG quality will be set between 1 and 100% * The calculations are approximations. * - * Value in bytes (integer) or shorthand byte values (string) is allowed. + * Value in bytes (integer) or shorthand byte values (string) is allowed. * The available options are K (for Kilobytes), M (for Megabytes) and G (for Gigabytes) * * Default value is null (no calculations) @@ -1541,7 +979,7 @@ class upload { * @var integer */ var $image_unsharp_amount; - + /** * Sets the unsharp mask radius * @@ -1558,7 +996,7 @@ class upload { * @var integer */ var $image_unsharp_radius; - + /** * Sets the unsharp mask threshold * @@ -2167,7 +1605,7 @@ class upload { var $image_watermark_no_zoom_in; /** - * Prevents the watermark to be resized down if it is bigger than the image + * Prevents the watermark to be resized down if it is bigger than the image * * If the watermark if bigger than the destination image, taking in account the desired watermark position * then it will be resized down to fit in the image (minus the {@link image_watermark_x} or {@link image_watermark_y} values) @@ -2176,7 +1614,7 @@ class upload { * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to true * If you want your watermark to be resized up or doan to fill in the image better, then * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to false - * + * * Default value is false (so the watermark may be shrinked to fit in the image) * * @access public @@ -2238,7 +1676,7 @@ class upload { * @access public * @var array */ - var $language; + var $lang; /** * Init or re-init all the processing variables to their default values @@ -2596,6 +2034,7 @@ function upload($file, $lang = 'en_GB') { $this->image_src_pixels = null; $this->image_dst_x = 0; $this->image_dst_y = 0; + $this->image_dst_type = ''; $this->uploaded = true; $this->no_upload_check = false; @@ -2731,7 +2170,7 @@ function upload($file, $lang = 'en_GB') { if (!$file) $file = 'unknown'; $this->log .= '' . $this->translate("source is a PHP stream") . ' ' . $file . '
'; $this->no_upload_check = TRUE; - + $this->log .= '- this is a PHP stream, requires a temp file ... '; $hash = $this->temp_dir() . md5($file . rand(1, 1000)); if (file_put_contents($hash, file_get_contents('php://input'))) { @@ -2755,7 +2194,7 @@ function upload($file, $lang = 'en_GB') { $this->file_src_name_ext = ''; $this->file_src_name_body = $this->file_src_name; } - $this->file_src_size = (file_exists($file) ? filesize($file) : 0); + $this->file_src_size = (file_exists($this->file_src_pathname) ? filesize($this->file_src_pathname) : 0); } $this->file_src_error = 0; @@ -2773,7 +2212,7 @@ function upload($file, $lang = 'en_GB') { $this->uploaded = false; $this->error = $this->translate('local_file_not_readable'); } - + if ($this->uploaded) { $this->file_src_pathname = $file; $this->file_src_name = basename($file); @@ -2786,9 +2225,9 @@ function upload($file, $lang = 'en_GB') { $this->file_src_name_ext = ''; $this->file_src_name_body = $this->file_src_name; } - $this->file_src_size = (file_exists($file) ? filesize($file) : 0); + $this->file_src_size = (file_exists($this->file_src_pathname) ? filesize($this->file_src_pathname) : 0); } - $this->file_src_error = 0; + $this->file_src_error = 0; } } } else { @@ -2896,8 +2335,8 @@ function upload($file, $lang = 'en_GB') { finfo_close($f); $this->file_src_mime = $mime; $this->log .= '    MIME type detected as ' . $this->file_src_mime . ' by Fileinfo PECL extension
'; - if (preg_match("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", $this->file_src_mime)) { - $this->file_src_mime = preg_replace("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); + if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; } else { $this->file_src_mime = null; @@ -2910,8 +2349,8 @@ function upload($file, $lang = 'en_GB') { if ($f) { $this->file_src_mime = $f->file(realpath($this->file_src_pathname)); $this->log .= '- MIME type detected as ' . $this->file_src_mime . ' by Fileinfo PECL extension
'; - if (preg_match("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", $this->file_src_mime)) { - $this->file_src_mime = preg_replace("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); + if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; } else { $this->file_src_mime = null; @@ -2936,8 +2375,8 @@ function upload($file, $lang = 'en_GB') { if (strlen($mime = @exec("file -bi ".escapeshellarg($this->file_src_pathname))) != 0) { $this->file_src_mime = trim($mime); $this->log .= '    MIME type detected as ' . $this->file_src_mime . ' by UNIX file() command
'; - if (preg_match("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", $this->file_src_mime)) { - $this->file_src_mime = preg_replace("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); + if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; } else { $this->file_src_mime = null; @@ -2963,8 +2402,8 @@ function upload($file, $lang = 'en_GB') { if (function_exists('mime_content_type')) { $this->file_src_mime = mime_content_type($this->file_src_pathname); $this->log .= '    MIME type detected as ' . $this->file_src_mime . ' by mime_content_type()
'; - if (preg_match("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", $this->file_src_mime)) { - $this->file_src_mime = preg_replace("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); + if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; } else { $this->file_src_mime = null; @@ -2990,8 +2429,8 @@ function upload($file, $lang = 'en_GB') { $this->file_src_mime = ($mime==IMAGETYPE_GIF ? 'image/gif' : ($mime==IMAGETYPE_JPEG ? 'image/jpeg' : ($mime==IMAGETYPE_PNG ? 'image/png' : ($mime==IMAGETYPE_BMP ? 'image/bmp' : null)))); } $this->log .= '    MIME type detected as ' . $this->file_src_mime . ' by PHP getimagesize() function
'; - if (preg_match("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", $this->file_src_mime)) { - $this->file_src_mime = preg_replace("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); + if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; } else { $this->file_src_mime = null; @@ -3008,8 +2447,8 @@ function upload($file, $lang = 'en_GB') { if (!empty($mime_from_browser) && !$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime)) { $this->file_src_mime =$mime_from_browser; $this->log .= '- MIME type detected as ' . $this->file_src_mime . ' by browser
'; - if (preg_match("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", $this->file_src_mime)) { - $this->file_src_mime = preg_replace("/^([\.-\w]+)\/([\.-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); + if (preg_match("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; } else { $this->file_src_mime = null; @@ -3237,7 +2676,7 @@ function getsize($size) { function getoffsets($offsets, $x, $y, $round = true, $negative = true) { if (!is_array($offsets)) $offsets = explode(' ', $offsets); if (sizeof($offsets) == 4) { - $ct = $offsets[0]; $cr = $offsets[1]; $cb = $offsets[2]; $cl = $offsets[3]; + $ct = $offsets[0]; $cr = $offsets[1]; $cb = $offsets[2]; $cl = $offsets[3]; } else if (sizeof($offsets) == 2) { $ct = $offsets[0]; $cr = $offsets[1]; $cb = $offsets[0]; $cl = $offsets[1]; } else { @@ -3252,13 +2691,13 @@ function getoffsets($offsets, $x, $y, $round = true, $negative = true) { if (strpos($cb, 'px')>0) $cb = str_replace('px','',$cb); if (strpos($cl, 'px')>0) $cl = str_replace('px','',$cl); $ct = (int) $ct; $cr = (int) $cr; $cb = (int) $cb; $cl = (int) $cl; - if ($round) { - $ct = round($ct); - $cr = round($cr); - $cb = round($cb); - $cl = round($cl); + if ($round) { + $ct = round($ct); + $cr = round($cr); + $cb = round($cb); + $cl = round($cl); } - if (!$negative) { + if (!$negative) { if ($ct < 0) $ct = 0; if ($cr < 0) $cr = 0; if ($cb < 0) $cb = 0; @@ -3352,7 +2791,7 @@ function imagecopymergealpha(&$dst_im, &$src_im, $dst_x, $dst_y, $src_x, $src_y, for ($x = $src_x; $x < $src_w; $x++) { if ($x + $dst_x >= 0 && $x + $dst_x < $dst_w && $x + $src_x >= 0 && $x + $src_x < $src_w - && $y + $dst_y >= 0 && $y + $dst_y < $dst_h && $y + $src_y >= 0 && $y + $src_y < $src_h) { + && $y + $dst_y >= 0 && $y + $dst_y < $dst_h && $y + $src_y >= 0 && $y + $src_y < $src_h) { $dst_pixel = imagecolorsforindex($dst_im, imagecolorat($dst_im, $x + $dst_x, $y + $dst_y)); $src_pixel = imagecolorsforindex($src_im, imagecolorat($src_im, $x + $src_x, $y + $src_y)); @@ -3617,30 +3056,30 @@ function process($server_path = null) { // do we do some image manipulation? $image_manipulation = ($this->file_is_image && ( - $this->image_resize - || $this->image_convert != '' - || is_numeric($this->image_brightness) - || is_numeric($this->image_contrast) - || is_numeric($this->image_opacity) - || is_numeric($this->image_threshold) - || !empty($this->image_tint_color) - || !empty($this->image_overlay_color) - || $this->image_pixelate - || $this->image_unsharp - || !empty($this->image_text) - || $this->image_greyscale - || $this->image_negative - || !empty($this->image_watermark) - || is_numeric($this->image_rotate) - || is_numeric($this->jpeg_size) - || !empty($this->image_flip) - || !empty($this->image_crop) - || !empty($this->image_precrop) - || !empty($this->image_border) - || !empty($this->image_border_transparent) - || $this->image_frame > 0 - || $this->image_bevel > 0 - || $this->image_reflection_height)); + $this->image_resize + || $this->image_convert != '' + || is_numeric($this->image_brightness) + || is_numeric($this->image_contrast) + || is_numeric($this->image_opacity) + || is_numeric($this->image_threshold) + || !empty($this->image_tint_color) + || !empty($this->image_overlay_color) + || $this->image_pixelate + || $this->image_unsharp + || !empty($this->image_text) + || $this->image_greyscale + || $this->image_negative + || !empty($this->image_watermark) + || is_numeric($this->image_rotate) + || is_numeric($this->jpeg_size) + || !empty($this->image_flip) + || !empty($this->image_crop) + || !empty($this->image_precrop) + || !empty($this->image_border) + || !empty($this->image_border_transparent) + || $this->image_frame > 0 + || $this->image_bevel > 0 + || $this->image_reflection_height)); // set the destination file name $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''); @@ -3676,7 +3115,7 @@ function process($server_path = null) { $this->log .= '    file_dst_pathname : ' . $this->file_dst_pathname . '
'; if ($this->file_overwrite) { - $this->log .= '- no overwrite checking
'; + $this->log .= '- no overwrite checking
'; } else { if (@file_exists($this->file_dst_pathname)) { $this->processed = false; @@ -3697,13 +3136,13 @@ function process($server_path = null) { $this->processed = false; $this->error = $this->translate('temp_file_missing'); } - // if we haven't a temp file, and that we do check on uploads, we use is_uploaded_file() + // if we haven't a temp file, and that we do check on uploads, we use is_uploaded_file() } else if (!$this->no_upload_check) { if (!is_uploaded_file($this->file_src_pathname)) { $this->processed = false; $this->error = $this->translate('source_missing'); } - // otherwise, if we don't check on uploaded files (local file for instance), we use file_exists() + // otherwise, if we don't check on uploaded files (local file for instance), we use file_exists() } else { if (!file_exists($this->file_src_pathname)) { $this->processed = false; @@ -3793,7 +3232,7 @@ function process($server_path = null) { if ($image_manipulation) { // make sure GD doesn't complain too much - ini_set("gd.jpeg_ignore_warning", 1); + @ini_set("gd.jpeg_ignore_warning", 1); // checks if the source file is readable if ($this->processed && !($f = @fopen($this->file_src_pathname, 'r'))) { @@ -3980,8 +3419,8 @@ function process($server_path = null) { } else if ($this->image_ratio || $this->image_ratio_crop || $this->image_ratio_fill || $this->image_ratio_no_zoom_in || $this->image_ratio_no_zoom_out) { $this->log .= '    check x/y sizes
'; if ((!$this->image_ratio_no_zoom_in && !$this->image_ratio_no_zoom_out) - || ($this->image_ratio_no_zoom_in && ($this->image_src_x > $this->image_x || $this->image_src_y > $this->image_y)) - || ($this->image_ratio_no_zoom_out && $this->image_src_x < $this->image_x && $this->image_src_y < $this->image_y)) { + || ($this->image_ratio_no_zoom_in && ($this->image_src_x > $this->image_x || $this->image_src_y > $this->image_y)) + || ($this->image_ratio_no_zoom_out && $this->image_src_x < $this->image_x && $this->image_src_y < $this->image_y)) { $this->image_dst_x = $this->image_x; $this->image_dst_y = $this->image_y; if ($this->image_ratio_crop) { @@ -4205,70 +3644,70 @@ function process($server_path = null) { } imagedestroy($filter); } - + // unsharp mask if ($gd_version >= 2 && $this->image_unsharp && is_numeric($this->image_unsharp_amount) && is_numeric($this->image_unsharp_radius) && is_numeric($this->image_unsharp_threshold)) { // Unsharp Mask for PHP - version 2.1.1 - // Unsharp mask algorithm by Torstein Hønsi 2003-07. + // Unsharp mask algorithm by Torstein Hønsi 2003-07. // Used with permission // Modified to support alpha transparency - if ($this->image_unsharp_amount > 500) $this->image_unsharp_amount = 500; - $this->image_unsharp_amount = $this->image_unsharp_amount * 0.016; - if ($this->image_unsharp_radius > 50) $this->image_unsharp_radius = 50; - $this->image_unsharp_radius = $this->image_unsharp_radius * 2; - if ($this->image_unsharp_threshold > 255) $this->image_unsharp_threshold = 255; + if ($this->image_unsharp_amount > 500) $this->image_unsharp_amount = 500; + $this->image_unsharp_amount = $this->image_unsharp_amount * 0.016; + if ($this->image_unsharp_radius > 50) $this->image_unsharp_radius = 50; + $this->image_unsharp_radius = $this->image_unsharp_radius * 2; + if ($this->image_unsharp_threshold > 255) $this->image_unsharp_threshold = 255; $this->image_unsharp_radius = abs(round($this->image_unsharp_radius)); - if ($this->image_unsharp_radius != 0) { - $this->image_dst_x = imagesx($image_dst); $this->image_dst_y = imagesy($image_dst); - $canvas = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y, false, true); - $blur = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y, false, true); - if (function_exists('imageconvolution')) { // PHP >= 5.1 - $matrix = array(array( 1, 2, 1 ), array( 2, 4, 2 ), array( 1, 2, 1 )); - imagecopy($blur, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); - imageconvolution($blur, $matrix, 16, 0); - } else { - for ($i = 0; $i < $this->image_unsharp_radius; $i++) { - imagecopy($blur, $image_dst, 0, 0, 1, 0, $this->image_dst_x - 1, $this->image_dst_y); // left - $this->imagecopymergealpha($blur, $image_dst, 1, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, 50); // right - $this->imagecopymergealpha($blur, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, 50); // center - imagecopy($canvas, $blur, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); - $this->imagecopymergealpha($blur, $canvas, 0, 0, 0, 1, $this->image_dst_x, $this->image_dst_y - 1, 33.33333 ); // up - $this->imagecopymergealpha($blur, $canvas, 0, 1, 0, 0, $this->image_dst_x, $this->image_dst_y, 25); // down - } - } + if ($this->image_unsharp_radius != 0) { + $this->image_dst_x = imagesx($image_dst); $this->image_dst_y = imagesy($image_dst); + $canvas = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y, false, true); + $blur = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y, false, true); + if (function_exists('imageconvolution')) { // PHP >= 5.1 + $matrix = array(array( 1, 2, 1 ), array( 2, 4, 2 ), array( 1, 2, 1 )); + imagecopy($blur, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); + imageconvolution($blur, $matrix, 16, 0); + } else { + for ($i = 0; $i < $this->image_unsharp_radius; $i++) { + imagecopy($blur, $image_dst, 0, 0, 1, 0, $this->image_dst_x - 1, $this->image_dst_y); // left + $this->imagecopymergealpha($blur, $image_dst, 1, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, 50); // right + $this->imagecopymergealpha($blur, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, 50); // center + imagecopy($canvas, $blur, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); + $this->imagecopymergealpha($blur, $canvas, 0, 0, 0, 1, $this->image_dst_x, $this->image_dst_y - 1, 33.33333 ); // up + $this->imagecopymergealpha($blur, $canvas, 0, 1, 0, 0, $this->image_dst_x, $this->image_dst_y, 25); // down + } + } $p_new = array(); - if($this->image_unsharp_threshold>0) { - for ($x = 0; $x < $this->image_dst_x-1; $x++) { + if($this->image_unsharp_threshold>0) { + for ($x = 0; $x < $this->image_dst_x-1; $x++) { for ($y = 0; $y < $this->image_dst_y; $y++) { $p_orig = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); $p_blur = imagecolorsforindex($blur, imagecolorat($blur, $x, $y)); - $p_new['red'] = (abs($p_orig['red'] - $p_blur['red']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['red'] - $p_blur['red'])) + $p_orig['red'])) : $p_orig['red']; - $p_new['green'] = (abs($p_orig['green'] - $p_blur['green']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['green'] - $p_blur['green'])) + $p_orig['green'])) : $p_orig['green']; - $p_new['blue'] = (abs($p_orig['blue'] - $p_blur['blue']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['blue'] - $p_blur['blue'])) + $p_orig['blue'])) : $p_orig['blue']; - if (($p_orig['red'] != $p_new['red']) || ($p_orig['green'] != $p_new['green']) || ($p_orig['blue'] != $p_new['blue'])) { + $p_new['red'] = (abs($p_orig['red'] - $p_blur['red']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['red'] - $p_blur['red'])) + $p_orig['red'])) : $p_orig['red']; + $p_new['green'] = (abs($p_orig['green'] - $p_blur['green']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['green'] - $p_blur['green'])) + $p_orig['green'])) : $p_orig['green']; + $p_new['blue'] = (abs($p_orig['blue'] - $p_blur['blue']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['blue'] - $p_blur['blue'])) + $p_orig['blue'])) : $p_orig['blue']; + if (($p_orig['red'] != $p_new['red']) || ($p_orig['green'] != $p_new['green']) || ($p_orig['blue'] != $p_new['blue'])) { $color = imagecolorallocatealpha($image_dst, $p_new['red'], $p_new['green'], $p_new['blue'], $p_orig['alpha']); - imagesetpixel($image_dst, $x, $y, $color); - } - } - } - } else { + imagesetpixel($image_dst, $x, $y, $color); + } + } + } + } else { for ($x = 0; $x < $this->image_dst_x; $x++) { for ($y = 0; $y < $this->image_dst_y; $y++) { $p_orig = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); $p_blur = imagecolorsforindex($blur, imagecolorat($blur, $x, $y)); - $p_new['red'] = ($this->image_unsharp_amount * ($p_orig['red'] - $p_blur['red'])) + $p_orig['red']; - if ($p_new['red']>255) { $p_new['red']=255; } elseif ($p_new['red']<0) { $p_new['red']=0; } - $p_new['green'] = ($this->image_unsharp_amount * ($p_orig['green'] - $p_blur['green'])) + $p_orig['green']; - if ($p_new['green']>255) { $p_new['green']=255; } elseif ($p_new['green']<0) { $p_new['green']=0; } - $p_new['blue'] = ($this->image_unsharp_amount * ($p_orig['blue'] - $p_blur['blue'])) + $p_orig['blue']; - if ($p_new['blue']>255) { $p_new['blue']=255; } elseif ($p_new['blue']<0) { $p_new['blue']=0; } + $p_new['red'] = ($this->image_unsharp_amount * ($p_orig['red'] - $p_blur['red'])) + $p_orig['red']; + if ($p_new['red']>255) { $p_new['red']=255; } elseif ($p_new['red']<0) { $p_new['red']=0; } + $p_new['green'] = ($this->image_unsharp_amount * ($p_orig['green'] - $p_blur['green'])) + $p_orig['green']; + if ($p_new['green']>255) { $p_new['green']=255; } elseif ($p_new['green']<0) { $p_new['green']=0; } + $p_new['blue'] = ($this->image_unsharp_amount * ($p_orig['blue'] - $p_blur['blue'])) + $p_orig['blue']; + if ($p_new['blue']>255) { $p_new['blue']=255; } elseif ($p_new['blue']<0) { $p_new['blue']=0; } $color = imagecolorallocatealpha($image_dst, $p_new['red'], $p_new['green'], $p_new['blue'], $p_orig['alpha']); - imagesetpixel($image_dst, $x, $y, $color); - } - } - } - imagedestroy($canvas); - imagedestroy($blur); + imagesetpixel($image_dst, $x, $y, $color); + } + } + } + imagedestroy($canvas); + imagedestroy($blur); } } @@ -4351,10 +3790,10 @@ function process($server_path = null) { $this->log .= '- add border : ' . $ct . ' ' . $cr . ' ' . $cb . ' ' . $cl . '
'; $this->image_dst_x = $this->image_dst_x + $cl + $cr; $this->image_dst_y = $this->image_dst_y + $ct + $cb; - if (!empty($this->image_border_color)) list($red, $green, $blue) = $this->getcolors($this->image_border_color); - $opacity = (is_numeric($this->image_border_opacity) ? (int) (127 - $this->image_border_opacity / 100 * 127): 0); - // we now create an image, that we fill with the border color - $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + if (!empty($this->image_border_color)) list($red, $green, $blue) = $this->getcolors($this->image_border_color); + $opacity = (is_numeric($this->image_border_opacity) ? (int) (127 - $this->image_border_opacity / 100 * 127): 0); + // we now create an image, that we fill with the border color + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); $background = imagecolorallocatealpha($tmp, $red, $green, $blue, $opacity); imagefilledrectangle($tmp, 0, 0, $this->image_dst_x, $this->image_dst_y, $background); // we then copy the source image into the new image, without merging so that only the border is actually kept @@ -4367,8 +3806,8 @@ function process($server_path = null) { if ($gd_version >= 2 && !empty($this->image_border_transparent)) { list($ct, $cr, $cb, $cl) = $this->getoffsets($this->image_border_transparent, $this->image_dst_x, $this->image_dst_y, true, false); $this->log .= '- add transparent border : ' . $ct . ' ' . $cr . ' ' . $cb . ' ' . $cl . '
'; - // we now create an image, that we fill with the border color - $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + // we now create an image, that we fill with the border color + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); // we then copy the source image into the new image, without the borders imagecopy($tmp, $image_dst, $cl, $ct, $cl, $ct, $this->image_dst_x - $cr - $cl, $this->image_dst_y - $cb - $ct); // we now add the top border @@ -4453,7 +3892,7 @@ function process($server_path = null) { $this->image_dst_y = $this->image_dst_y + ($nb * 2); $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); imagecopy($tmp, $image_dst, $nb, $nb, 0, 0, $this->image_dst_x - ($nb * 2), $this->image_dst_y - ($nb * 2)); - $opacity = (is_numeric($this->image_frame_opacity) ? (int) (127 - $this->image_frame_opacity / 100 * 127): 0); + $opacity = (is_numeric($this->image_frame_opacity) ? (int) (127 - $this->image_frame_opacity / 100 * 127): 0); for ($i=0; $i<$nb; $i++) { list($red, $green, $blue) = $this->getcolors($vars[$i]); $c = imagecolorallocatealpha($tmp, $red, $green, $blue, $opacity); @@ -4559,9 +3998,9 @@ function process($server_path = null) { // if watermark is too large/tall, resize it first if ((!$this->image_watermark_no_zoom_out && ($watermark_dst_width > $this->image_dst_x || $watermark_dst_height > $this->image_dst_y)) - || (!$this->image_watermark_no_zoom_in && $watermark_dst_width < $this->image_dst_x && $watermark_dst_height < $this->image_dst_y)) { + || (!$this->image_watermark_no_zoom_in && $watermark_dst_width < $this->image_dst_x && $watermark_dst_height < $this->image_dst_y)) { $canvas_width = $this->image_dst_x - abs($this->image_watermark_x); - $canvas_height = $this->image_dst_y - abs($this->image_watermark_y); + $canvas_height = $this->image_dst_y - abs($this->image_watermark_y); if (($watermark_src_width/$canvas_width) > ($watermark_src_height/$canvas_height)) { $watermark_dst_width = $canvas_width; $watermark_dst_height = intval($watermark_src_height*($canvas_width / $watermark_src_width)); @@ -4624,59 +4063,59 @@ function process($server_path = null) { $this->image_text = str_replace( array('[src_name]', - '[src_name_body]', - '[src_name_ext]', - '[src_pathname]', - '[src_mime]', - '[src_size]', - '[src_size_kb]', - '[src_size_mb]', - '[src_size_human]', - '[src_x]', - '[src_y]', - '[src_pixels]', - '[src_type]', - '[src_bits]', - '[dst_path]', - '[dst_name_body]', - '[dst_name_ext]', - '[dst_name]', - '[dst_pathname]', - '[dst_x]', - '[dst_y]', - '[date]', - '[time]', - '[host]', - '[server]', - '[ip]', - '[gd_version]'), + '[src_name_body]', + '[src_name_ext]', + '[src_pathname]', + '[src_mime]', + '[src_size]', + '[src_size_kb]', + '[src_size_mb]', + '[src_size_human]', + '[src_x]', + '[src_y]', + '[src_pixels]', + '[src_type]', + '[src_bits]', + '[dst_path]', + '[dst_name_body]', + '[dst_name_ext]', + '[dst_name]', + '[dst_pathname]', + '[dst_x]', + '[dst_y]', + '[date]', + '[time]', + '[host]', + '[server]', + '[ip]', + '[gd_version]'), array($this->file_src_name, - $this->file_src_name_body, - $this->file_src_name_ext, - $this->file_src_pathname, - $this->file_src_mime, - $this->file_src_size, - $src_size_kb, - $src_size_mb, - $src_size_human, - $this->image_src_x, - $this->image_src_y, - $this->image_src_pixels, - $this->image_src_type, - $this->image_src_bits, - $this->file_dst_path, - $this->file_dst_name_body, - $this->file_dst_name_ext, - $this->file_dst_name, - $this->file_dst_pathname, - $this->image_dst_x, - $this->image_dst_y, - date('Y-m-d'), - date('H:i:s'), - (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'n/a'), - (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'n/a'), - (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'n/a'), - $this->gdversion(true)), + $this->file_src_name_body, + $this->file_src_name_ext, + $this->file_src_pathname, + $this->file_src_mime, + $this->file_src_size, + $src_size_kb, + $src_size_mb, + $src_size_human, + $this->image_src_x, + $this->image_src_y, + $this->image_src_pixels, + $this->image_src_type, + $this->image_src_bits, + $this->file_dst_path, + $this->file_dst_name_body, + $this->file_dst_name_ext, + $this->file_dst_name, + $this->file_dst_pathname, + $this->image_dst_x, + $this->image_dst_y, + date('Y-m-d'), + date('H:i:s'), + (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'n/a'), + (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'n/a'), + (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'n/a'), + $this->gdversion(true)), $this->image_text); if (!is_numeric($this->image_text_padding)) $this->image_text_padding = 0; @@ -4785,18 +4224,18 @@ function process($server_path = null) { foreach ($text as $k => $v) { if ($this->image_text_direction == 'v') { imagestringup($filter, - $this->image_text_font, - $k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), - $text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))) , - $v, - $text_color); + $this->image_text_font, + $k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), + $text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))) , + $v, + $text_color); } else { imagestring($filter, - $this->image_text_font, - ($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), - $k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), - $v, - $text_color); + $this->image_text_font, + ($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), + $k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), + $v, + $text_color); } } $this->imagecopymergealpha($image_dst, $filter, $text_x, $text_y, 0, 0, $t_width, $t_height, $this->image_text_opacity); @@ -4807,18 +4246,18 @@ function process($server_path = null) { foreach ($text as $k => $v) { if ($this->image_text_direction == 'v') { imagestringup($image_dst, - $this->image_text_font, - $text_x + $k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), - $text_y + $text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), - $v, - $text_color); + $this->image_text_font, + $text_x + $k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), + $text_y + $text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), + $v, + $text_color); } else { imagestring($image_dst, - $this->image_text_font, - $text_x + ($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), - $text_y + $k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), - $v, - $text_color); + $this->image_text_font, + $text_x + ($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), + $text_y + $k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), + $v, + $text_color); } } } @@ -4900,7 +4339,7 @@ function process($server_path = null) { // copy the resulting image into the destination image $image_dst = $this->imagetransfer($tmp, $image_dst); } - + // reduce the JPEG image to a set desired size if (is_numeric($this->jpeg_size) && $this->jpeg_size > 0 && ($this->image_convert == 'jpeg' || $this->image_convert == 'jpg')) { // inspired by: JPEGReducer class version 1, 25 November 2004, Author: Huda M ElMatsani, justhuda at netscape dot net @@ -4937,6 +4376,7 @@ function process($server_path = null) { // converts image from true color, and fix transparency if needed $this->log .= '- converting...
'; + $this->image_dst_type = $this->image_convert; switch($this->image_convert) { case 'gif': // if the image is true color, we convert it to a palette @@ -4995,9 +4435,9 @@ function process($server_path = null) { if (imageistruecolor($image_dst)) { $rgba = imagecolorat($image_dst, $x, $y); $pixel = array('red' => ($rgba >> 16) & 0xFF, - 'green' => ($rgba >> 8) & 0xFF, - 'blue' => $rgba & 0xFF, - 'alpha' => ($rgba & 0x7F000000) >> 24); + 'green' => ($rgba >> 8) & 0xFF, + 'blue' => $rgba & 0xFF, + 'alpha' => ($rgba & 0x7F000000) >> 24); } else { $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); } @@ -5296,4 +4736,4 @@ function imagebmp(&$im, $filename = "") { } } -?> +?> \ No newline at end of file