From 95257f2fe03781287d5b49d9e269b5a1ac148add Mon Sep 17 00:00:00 2001 From: Fotis Evangelou Date: Mon, 29 Jan 2018 17:27:02 +0200 Subject: [PATCH] Updated class.upload.php to latest release, added a default definitions URL, bumped version to 1.1.0 --- README.md | 8 +- .../components/com_jw_fillitup/config.xml | 2 +- .../components/com_jw_fillitup/controller.php | 2 +- .../components/com_jw_fillitup/css/style.css | 2 +- .../com_jw_fillitup/helpers/extension.php | 2 +- .../components/com_jw_fillitup/js/script.js | 2 +- .../com_jw_fillitup/jw_fillitup.php | 6 +- .../com_jw_fillitup/lib/class.upload.php | 1669 +++++++---------- .../views/default/tmpl/default.php | 4 +- .../views/default/tmpl/extension.php | 4 +- .../views/default/tmpl/popup.php | 4 +- .../views/default/view.html.php | 2 +- .../language/en-GB/en-GB.com_jw_fillitup.ini | 2 +- .../en-GB/en-GB.com_jw_fillitup.sys.ini | 2 +- jw_fillitup.xml | 6 +- plugins/fillitup/content/content.php | 2 +- plugins/fillitup/content/content.xml | 6 +- .../en-GB.plg_fillitup_content.sys.ini | 2 +- .../fillitup/k2/en-GB.plg_fillitup_k2.sys.ini | 2 +- plugins/fillitup/k2/fields/k2images.php | 2 +- plugins/fillitup/k2/k2.php | 2 +- plugins/fillitup/k2/k2.xml | 6 +- .../users/en-GB.plg_fillitup_users.sys.ini | 2 +- plugins/fillitup/users/users.php | 2 +- plugins/fillitup/users/users.xml | 6 +- script.fillitup.php | 2 +- 26 files changed, 726 insertions(+), 1025 deletions(-) diff --git a/README.md b/README.md index b40f75f..079b100 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Fill It Up (for Joomla) [v1.0.0] +# Fill It Up (for Joomla) [v1.1.0] *** Fill It Up for Joomla is a handy free extension to mass generate content & users in Joomla. @@ -32,7 +32,7 @@ In the future, we plan to release pre-built sets of definition files from other ## Use it -1. Get the latest build, ready to upload to Joomla: http://www.joomlaworks.net/downloads/?f=jw_fillitup_for_joomla-v1.0.0_j2.5-3.x.zip (please DO NOT use the zip file download provided by GitHub automatically) +1. Get the latest build, ready to upload to Joomla: http://www.joomlaworks.net/downloads/?f=jw_fillitup_for_joomla-v1.1.0_j3.x.zip (please DO NOT use the zip file download provided by GitHub automatically) 2. Edit the component's options and add this demo definition file: - If you already use HTTPS: https://cdn.joomlaworks.org/fillitup/demo/900x600.json - If you get any issues related to SSL (especially while testing Fill It Up locally), use this URL instead: http://cdn.joomlaworks.org/fillitup/demo/900x600_plain_http.json @@ -53,7 +53,7 @@ Just install the latest build on top of any previous installation. ## Requirements -Fill It Up for Joomla requires Joomla 2.5 or 3.x and K2 v2.6.x or newer if you wish to create dummy content for K2 specifically (obviously). +Fill It Up for Joomla requires Joomla 3.x and K2 v2.6.x or newer if you wish to create dummy content for K2 specifically (obviously). ***Enjoy and share it :)*** @@ -61,4 +61,4 @@ Fill It Up for Joomla requires Joomla 2.5 or 3.x and K2 v2.6.x or newer if you w === Fill It Up for Joomla is released under the GNU/GPL license. -Copyright (c) 2006 - 2016 [JoomlaWorks Ltd.](http://www.joomlaworks.net) +Copyright (c) 2006 - 2018 [JoomlaWorks Ltd.](https://www.joomlaworks.net) diff --git a/administrator/components/com_jw_fillitup/config.xml b/administrator/components/com_jw_fillitup/config.xml index 7b74b8a..251cfb3 100755 --- a/administrator/components/com_jw_fillitup/config.xml +++ b/administrator/components/com_jw_fillitup/config.xml @@ -1,7 +1,7 @@
- +
diff --git a/administrator/components/com_jw_fillitup/controller.php b/administrator/components/com_jw_fillitup/controller.php index 6a15123..8cf92ad 100755 --- a/administrator/components/com_jw_fillitup/controller.php +++ b/administrator/components/com_jw_fillitup/controller.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ diff --git a/administrator/components/com_jw_fillitup/css/style.css b/administrator/components/com_jw_fillitup/css/style.css index 5fa5387..64a271d 100755 --- a/administrator/components/com_jw_fillitup/css/style.css +++ b/administrator/components/com_jw_fillitup/css/style.css @@ -2,7 +2,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ diff --git a/administrator/components/com_jw_fillitup/helpers/extension.php b/administrator/components/com_jw_fillitup/helpers/extension.php index 82bf8f9..8519947 100755 --- a/administrator/components/com_jw_fillitup/helpers/extension.php +++ b/administrator/components/com_jw_fillitup/helpers/extension.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ diff --git a/administrator/components/com_jw_fillitup/js/script.js b/administrator/components/com_jw_fillitup/js/script.js index f2423a8..2515fbe 100755 --- a/administrator/components/com_jw_fillitup/js/script.js +++ b/administrator/components/com_jw_fillitup/js/script.js @@ -2,7 +2,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ diff --git a/administrator/components/com_jw_fillitup/jw_fillitup.php b/administrator/components/com_jw_fillitup/jw_fillitup.php index a41adc5..ebe3c9c 100755 --- a/administrator/components/com_jw_fillitup/jw_fillitup.php +++ b/administrator/components/com_jw_fillitup/jw_fillitup.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ @@ -27,7 +27,7 @@ require_once JPATH_COMPONENT.'/helpers/extension.php'; $document = JFactory::getDocument(); -$document->addStyleSheet(JURI::base(true).'/components/com_jw_fillitup/css/style.css?v=1.0.0'); +$document->addStyleSheet(JURI::base(true).'/components/com_jw_fillitup/css/style.css?v=1.1.0'); if (version_compare(JVERSION, '3.2', 'lt')) { $document->addScript('//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'); @@ -36,7 +36,7 @@ { JHtml::_('jquery.framework'); } -$document->addScript(JURI::base(true).'/components/com_jw_fillitup/js/script.js?v=1.0.0'); +$document->addScript(JURI::base(true).'/components/com_jw_fillitup/js/script.js?v=1.1.0'); $controller = JControllerLegacy::getInstance('FillItUp'); $controller->execute($application->input->get('task')); diff --git a/administrator/components/com_jw_fillitup/lib/class.upload.php b/administrator/components/com_jw_fillitup/lib/class.upload.php index b50bbc3..a1f881a 100755 --- a/administrator/components/com_jw_fillitup/lib/class.upload.php +++ b/administrator/components/com_jw_fillitup/lib/class.upload.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ @@ -14,8 +14,6 @@ // | class.upload.php | // +------------------------------------------------------------------------+ // | Copyright (c) Colin Verot 2003-2014. All rights reserved. | -// | Version 0.33dev | -// | Last modified 28/03/2014 | // | Email colin@verot.net | // | Web http://www.verot.net | // +------------------------------------------------------------------------+ @@ -37,589 +35,13 @@ // | of the script so other people can use them as well. | // | This script is free to use, don't abuse. | // +------------------------------------------------------------------------+ -// /** * Class upload * - * @version 0.33dev * @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) - *
    - *
  • {@link file_new_name_body} replaces the name body (default: null)
    - *
    $handle->file_new_name_body = 'new name';
  • - *
  • {@link file_name_body_add} appends to the name body (default: null)
    - *
    $handle->file_name_body_add = '_uploaded';
  • - *
  • {@link file_name_body_pre} prepends to the name body (default: null)
    - *
    $handle->file_name_body_pre = 'thumb_';
  • - *
  • {@link file_new_name_ext} replaces the file extension (default: null)
    - *
    $handle->file_new_name_ext = 'txt';
  • - *
  • {@link file_safe_name} formats the filename (spaces changed to _) (default: true)
    - *
    $handle->file_safe_name = true;
  • - *
  • {@link file_force_extension} forces an extension if there is't any (default: true)
    - *
    $handle->file_force_extension = true;
  • - *
  • {@link file_overwrite} sets behaviour if file already exists (default: false)
    - *
    $handle->file_overwrite = true;
  • - *
  • {@link file_auto_rename} automatically renames file if it already exists (default: true)
    - *
    $handle->file_auto_rename = true;
  • - *
  • {@link dir_auto_create} automatically creates destination directory if missing (default: true)
    - *
    $handle->auto_create_dir = true;
  • - *
  • {@link dir_auto_chmod} automatically attempts to chmod the destination directory if not writeable (default: true)
    - *
    $handle->dir_auto_chmod = true;
  • - *
  • {@link dir_chmod} chmod used when creating directory or if directory not writeable (default: 0777)
    - *
    $handle->dir_chmod = 0777;
  • - *
  • {@link file_max_size} sets maximum upload size (default: upload_max_filesize from php.ini)
    - *
    $handle->file_max_size = '1024'; // 1KB
  • - *
  • {@link mime_check} sets if the class check the MIME against the {@link allowed} list (default: true)
    - *
    $handle->mime_check = true;
  • - *
  • {@link no_script} sets if the class turns scripts into text files (default: true)
    - *
    $handle->no_script = false;
  • - *
  • {@link allowed} array of allowed mime-types (or one string). wildcard accepted, as in image/* (default: check {@link Init})
    - *
    $handle->allowed = array('application/pdf','application/msword', 'image/*');
  • - *
  • {@link forbidden} array of forbidden mime-types (or one string). wildcard accepted, as in image/* (default: check {@link Init})
    - *
    $handle->forbidden = array('application/*');
  • - *
- *
    - *
  • {@link image_convert} if set, image will be converted (possible values : ''|'png'|'jpeg'|'gif'|'bmp'; default: '')
    - *
    $handle->image_convert = 'jpg';
  • - *
  • {@link image_background_color} if set, will forcibly fill transparent areas with the color, in hexadecimal (default: null)
    - *
    $handle->image_background_color = '#FF00FF';
  • - *
  • {@link image_default_color} fallback color background color for non alpha-transparent output formats, such as JPEG or BMP, in hexadecimal (default: #FFFFFF)
    - *
    $handle->image_default_color = '#FF00FF';
  • - *
  • {@link png_compression} sets the compression level for PNG images, between 1 (fast but large files) and 9 (slow but smaller files) (default: null (Zlib default))
    - *
    $handle->png_compression = 9;
  • - *
  • {@link jpeg_quality} sets the compression quality for JPEG images (default: 85)
    - *
    $handle->jpeg_quality = 50;
  • - *
  • {@link jpeg_size} if set to a size in bytes, will approximate {@link jpeg_quality} so the output image fits within the size (default: null)
    - *
    $handle->jpeg_size = 3072;
  • - *
  • {@link image_interlace} if set to true, the image will be saved interlaced (default: false)
    - *
    $handle->image_interlace = true;
  • - *
- * 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) - *
    - *
  • {@link image_max_width} if set to a dimension in pixels, the upload will be invalid if the image width is greater (default: null)
    - *
    $handle->image_max_width = 200;
  • - *
  • {@link image_max_height} if set to a dimension in pixels, the upload will be invalid if the image height is greater (default: null)
    - *
    $handle->image_max_height = 100;
  • - *
  • {@link image_max_pixels} if set to a number of pixels, the upload will be invalid if the image number of pixels is greater (default: null)
    - *
    $handle->image_max_pixels = 50000;
  • - *
  • {@link image_max_ratio} if set to a aspect ratio (width/height), the upload will be invalid if the image apect ratio is greater (default: null)
    - *
    $handle->image_max_ratio = 1.5;
  • - *
  • {@link image_min_width} if set to a dimension in pixels, the upload will be invalid if the image width is lower (default: null)
    - *
    $handle->image_min_width = 100;
  • - *
  • {@link image_min_height} if set to a dimension in pixels, the upload will be invalid if the image height is lower (default: null)
    - *
    $handle->image_min_height = 500;
  • - *
  • {@link image_min_pixels} if set to a number of pixels, the upload will be invalid if the image number of pixels is lower (default: null)
    - *
    $handle->image_min_pixels = 20000;
  • - *
  • {@link image_min_ratio} if set to a aspect ratio (width/height), the upload will be invalid if the image apect ratio is lower (default: null)
    - *
    $handle->image_min_ratio = 0.5;
  • - *
- *
    - *
  • {@link image_resize} determines is an image will be resized (default: false)
    - *
    $handle->image_resize = true;
  • - *
- * The following variables are used only if {@link image_resize} == true - *
    - *
  • {@link image_x} destination image width (default: 150)
    - *
    $handle->image_x = 100;
  • - *
  • {@link image_y} destination image height (default: 150)
    - *
    $handle->image_y = 200;
  • - *
- * Use either one of the following - *
    - *
  • {@link image_ratio} if true, resize image conserving the original sizes ratio, using {@link image_x} AND {@link image_y} as max sizes if true (default: false)
    - *
    $handle->image_ratio = true;
  • - *
  • {@link image_ratio_crop} if true, resize image conserving the original sizes ratio, using {@link image_x} AND {@link image_y} as max sizes, and cropping excedent to fill the space. setting can also be a string, with one or more from 'TBLR', indicating which side of the image will be kept while cropping (default: false)
    - *
    $handle->image_ratio_crop = true;
  • - *
  • {@link image_ratio_fill} if true, resize image conserving the original sizes ratio, using {@link image_x} AND {@link image_y} as max sizes, fitting the image in the space and coloring the remaining space. setting can also be a string, with one or more from 'TBLR', indicating which side of the space the image will be in (default: false)
    - *
    $handle->image_ratio_fill = true;
  • - *
  • {@link image_ratio_no_zoom_in} same as {@link image_ratio}, but won't resize if the source image is smaller than {@link image_x} x {@link image_y} (default: false)
    - *
    $handle->image_ratio_no_zoom_in = true;
  • - *
  • {@link image_ratio_no_zoom_out} same as {@link image_ratio}, but won't resize if the source image is bigger than {@link image_x} x {@link image_y} (default: false)
    - *
    $handle->image_ratio_no_zoom_out = true;
  • - *
  • {@link image_ratio_x} if true, resize image, calculating {@link image_x} from {@link image_y} and conserving the original sizes ratio (default: false)
    - *
    $handle->image_ratio_x = true;
  • - *
  • {@link image_ratio_y} if true, resize image, calculating {@link image_y} from {@link image_x} and conserving the original sizes ratio (default: false)
    - *
    $handle->image_ratio_y = true;
  • - *
  • {@link image_ratio_pixels} if set to a long integer, resize image, calculating {@link image_y} and {@link image_x} to match a the number of pixels (default: false)
    - *
    $handle->image_ratio_pixels = 25000;
  • - *
- * The following image manipulations require GD2+ - *
    - *
  • {@link image_brightness} if set, corrects the brightness. value between -127 and 127 (default: null)
    - *
    $handle->image_brightness = 40;
  • - *
  • {@link image_contrast} if set, corrects the contrast. value between -127 and 127 (default: null)
    - *
    $handle->image_contrast = 50;
  • - *
  • {@link image_opacity} if set, changes the image opacity. value between 0 and 100 (default: null)
    - *
    $handle->image_opacity = 50;
  • - *
  • {@link image_tint_color} if set, will tint the image with a color, value as hexadecimal #FFFFFF (default: null)
    - *
    $handle->image_tint_color = '#FF0000';
  • - *
  • {@link image_overlay_color} if set, will add a colored overlay, value as hexadecimal #FFFFFF (default: null)
    - *
    $handle->image_overlay_color = '#FF0000';
  • - *
  • {@link image_overlay_opacity} used when {@link image_overlay_color} is set, determines the opacity (default: 50)
    - *
    $handle->image_overlay_opacity = 20;
  • - *
  • {@link image_negative} inverts the colors in the image (default: false)
    - *
    $handle->image_negative = true;
  • - *
  • {@link image_greyscale} transforms an image into greyscale (default: false)
    - *
    $handle->image_greyscale = true;
  • - *
  • {@link image_threshold} applies a threshold filter. value between -127 and 127 (default: null)
    - *
    $handle->image_threshold = 20;
  • - *
  • {@link image_pixelate} pixelate an image, value is block size (default: null)
    - *
    $handle->image_pixelate = 10;
  • - *
  • {@link image_unsharp} applies an unsharp mask, with alpha transparency support (default: false)
    - *
    $handle->image_unsharp = true;
  • - *
  • {@link image_unsharp_amount} unsharp mask amount, typically 50 - 200 (default: 80)
    - *
    $handle->image_unsharp_amount = 120;
  • - *
  • {@link image_unsharp_radius} unsharp mask radius, typically 0.5 - 1 (default: 0.5)
    - *
    $handle->image_unsharp_radius = 1;
  • - *
  • {@link image_unsharp_threshold} unsharp mask threshold, typically 0 - 5 (default: 1)
    - *
    $handle->image_unsharp_threshold = 0;
  • - *
- *
    - *
  • {@link image_text} creates a text label on the image, value is a string, with eventual replacement tokens (default: null)
    - *
    $handle->image_text = 'test';
  • - *
  • {@link image_text_direction} text label direction, either 'h' horizontal or 'v' vertical (default: 'h')
    - *
    $handle->image_text_direction = 'v';
  • - *
  • {@link image_text_color} text color for the text label, in hexadecimal (default: #FFFFFF)
    - *
    $handle->image_text_color = '#FF0000';
  • - *
  • {@link image_text_opacity} text opacity on the text label, integer between 0 and 100 (default: 100)
    - *
    $handle->image_text_opacity = 50;
  • - *
  • {@link image_text_background} text label background color, in hexadecimal (default: null)
    - *
    $handle->image_text_background = '#FFFFFF';
  • - *
  • {@link image_text_background_opacity} text label background opacity, integer between 0 and 100 (default: 100)
    - *
    $handle->image_text_background_opacity = 50;
  • - *
  • {@link image_text_font} built-in font for the text label, from 1 to 5. 1 is the smallest (default: 5)
    - *
    $handle->image_text_font = 4;
  • - *
  • {@link image_text_x} absolute text label position, in pixels from the left border. can be negative (default: null)
    - *
    $handle->image_text_x = 5;
  • - *
  • {@link image_text_y} absolute text label position, in pixels from the top border. can be negative (default: null)
    - *
    $handle->image_text_y = 5;
  • - *
  • {@link image_text_position} text label position withing the image, a combination of one or two from 'TBLR': top, bottom, left, right (default: null)
    - *
    $handle->image_text_position = 'LR';
  • - *
  • {@link image_text_padding} text label padding, in pixels. can be overridden by {@link image_text_padding_x} and {@link image_text_padding_y} (default: 0)
    - *
    $handle->image_text_padding = 5;
  • - *
  • {@link image_text_padding_x} text label horizontal padding (default: null)
    - *
    $handle->image_text_padding_x = 2;
  • - *
  • {@link image_text_padding_y} text label vertical padding (default: null)
    - *
    $handle->image_text_padding_y = 10;
  • - *
  • {@link image_text_alignment} text alignment when text has multiple lines, either 'L', 'C' or 'R' (default: 'C')
    - *
    $handle->image_text_alignment = 'R';
  • - *
  • {@link image_text_line_spacing} space between lines in pixels, when text has multiple lines (default: 0)
    - *
    $handle->image_text_line_spacing = 3;
  • - *
- *
    - *
  • {@link image_flip} flips image, wither 'h' horizontal or 'v' vertical (default: null)
    - *
    $handle->image_flip = 'h';
  • - *
  • {@link image_rotate} rotates image. possible values are 90, 180 and 270 (default: null)
    - *
    $handle->image_rotate = 90;
  • - *
  • {@link image_crop} crops image. accepts 4, 2 or 1 values as 'T R B L' or 'TB LR' or 'TBLR'. dimension can be 20, or 20px or 20% (default: null)
    - *
    $handle->image_crop = array(50,40,30,20); OR '-20 20%'...
  • - *
  • {@link image_precrop} crops image, before an eventual resizing. accepts 4, 2 or 1 values as 'T R B L' or 'TB LR' or 'TBLR'. dimension can be 20, or 20px or 20% (default: null)
    - *
    $handle->image_precrop = array(50,40,30,20); OR '-20 20%'...
  • - *
- *
    - *
  • {@link image_bevel} adds a bevel border to the image. value is thickness in pixels (default: null)
    - *
    $handle->image_bevel = 20;
  • - *
  • {@link image_bevel_color1} top and left bevel color, in hexadecimal (default: #FFFFFF)
    - *
    $handle->image_bevel_color1 = '#FFFFFF';
  • - *
  • {@link image_bevel_color2} bottom and right bevel color, in hexadecimal (default: #000000)
    - *
    $handle->image_bevel_color2 = '#000000';
  • - *
  • {@link image_border} adds a unicolor border to the image. accepts 4, 2 or 1 values as 'T R B L' or 'TB LR' or 'TBLR'. dimension can be 20, or 20px or 20% (default: null)
    - *
    $handle->image_border = '3px'; OR '-20 20%' OR array(3,2)...
  • - *
  • {@link image_border_color} border color, in hexadecimal (default: #FFFFFF)
    - *
    $handle->image_border_color = '#FFFFFF';
  • - *
  • {@link image_border_opacity} border opacity, integer between 0 and 100 (default: 100)
    - *
    $handle->image_border_opacity = 50;
  • - *
  • {@link image_border_transparent} adds a fading-to-transparent border to the image. accepts 4, 2 or 1 values as 'T R B L' or 'TB LR' or 'TBLR'. dimension can be 20, or 20px or 20% (default: null)
    - *
    $handle->image_border_transparent = '3px'; OR '-20 20%' OR array(3,2)...
  • - *
  • {@link image_frame} type of frame: 1=flat 2=crossed (default: null)
    - *
    $handle->image_frame = 2;
  • - *
  • {@link image_frame_colors} list of hex colors, in an array or a space separated string (default: '#FFFFFF #999999 #666666 #000000')
    - *
    $handle->image_frame_colors = array('#999999',  '#FF0000', '#666666', '#333333', '#000000');
  • - *
  • {@link image_frame_opacity} frame opacity, integer between 0 and 100 (default: 100)
    - *
    $handle->image_frame_opacity = 50;
  • - *
- *
    - *
  • {@link image_watermark} adds a watermark on the image, value is a local filename. accepted files are GIF, JPG, BMP, PNG and PNG alpha (default: null)
    - *
    $handle->image_watermark = 'watermark.png';
  • - *
  • {@link image_watermark_x} absolute watermark position, in pixels from the left border. can be negative (default: null)
    - *
    $handle->image_watermark_x = 5;
  • - *
  • {@link image_watermark_y} absolute watermark position, in pixels from the top border. can be negative (default: null)
    - *
    $handle->image_watermark_y = 5;
  • - *
  • {@link image_watermark_position} watermark position withing the image, a combination of one or two from 'TBLR': top, bottom, left, right (default: null)
    - *
    $handle->image_watermark_position = 'LR';
  • - *
  • {@link image_watermark_no_zoom_in} prevents the watermark to be resized up if it is smaller than the image (default: true)
    - *
    $handle->image_watermark_no_zoom_in = false;
  • - *
  • {@link image_watermark_no_zoom_out} prevents the watermark to be resized down if it is bigger than the image (default: false)
    - *
    $handle->image_watermark_no_zoom_out = true;
  • - *
- *
    - *
  • {@link image_reflection_height} if set, a reflection will be added. Format is either in pixels or percentage, such as 40, '40', '40px' or '40%' (default: null)
    - *
    $handle->image_reflection_height = '25%';
  • - *
  • {@link image_reflection_space} space in pixels between the source image and the reflection, can be negative (default: null)
    - *
    $handle->image_reflection_space = 3;
  • - *
  • {@link image_reflection_color} reflection background color, in hexadecimal. Now deprecated in favor of {@link image_default_color} (default: #FFFFFF)
    - *
    $handle->image_default_color = '#000000';
  • - *
  • {@link image_reflection_opacity} opacity level at which the reflection starts, integer between 0 and 100 (default: 60)
    - *
    $handle->image_reflection_opacity = 60;
  • - *
- * - * Values that can be read before calling {@link process}() - *
    - *
  • {@link file_src_name} Source file name
  • - *
  • {@link file_src_name_body} Source file name body
  • - *
  • {@link file_src_name_ext} Source file extension
  • - *
  • {@link file_src_pathname} Source file complete path and name
  • - *
  • {@link file_src_mime} Source file mime type
  • - *
  • {@link file_src_size} Source file size in bytes
  • - *
  • {@link file_src_error} Upload error code
  • - *
  • {@link file_is_image} Boolean flag, true if the file is a supported image type
  • - *
- * If the file is a supported image type (and open_basedir restrictions allow it) - *
    - *
  • {@link image_src_x} Source file width in pixels
  • - *
  • {@link image_src_y} Source file height in pixels
  • - *
  • {@link image_src_pixels} Source file number of pixels
  • - *
  • {@link image_src_type} Source file type (png, jpg, gif or bmp)
  • - *
  • {@link image_src_bits} Source file color depth
  • - *
- * - * Values that can be read after calling {@link process}() - *
    - *
  • {@link file_dst_path} Destination file path
  • - *
  • {@link file_dst_name_body} Destination file name body
  • - *
  • {@link file_dst_name_ext} Destination file extension
  • - *
  • {@link file_dst_name} Destination file name
  • - *
  • {@link file_dst_pathname} Destination file complete path and name
  • - *
- * If the file is a supported image type - *
    - *
  • {@link image_dst_type} Destination file type (png, jpg, gif or bmp)
  • - *
  • {@link image_dst_x} Destination file width
  • - *
  • {@link image_dst_y} Destination file height
  • - *
- * - * Requirements - * - * Most of the image operations require GD. GD2 is greatly recommended - * - * The class requires PHP 4.3+, and is compatible with PHP5 - * - * Changelog - *
    - *
  • v 0.33dev 28/03/2014
    - * - added {@link image_dst_type}
    - * - fixed filesize when using XMLHttpRequest
    - * - added Hungarian translation
    - * - fixed Turkish translation
    - * - updated regex rules for MIME detection
    - * - added composer.json
  • - *
  • v 0.32 15/01/2013
    - * - add support for XMLHttpRequest uploads
    - * - added {@link image_pixelate}
    - * - added {@link image_interlace}
    - * - added {@link png_compression} to change PNG compressoin level
    - * - deactivate exec() if Suhosin is enabled
    - * - add more extension to dangerous scripts detection
    - * - imagejpeg takes null as second argument since PHP 5.4
    - * - default PECL Fileinfo MAGIC path to null
    - * - set gd.jpeg_ignore_warning to true by default
    - * - fixed file name normalization
  • - *
  • v 0.31 11/04/2011
    - * - added application/x-rar MIME type
    - * - make sure exec() and ini_get_all()function are not disabled if we want to use them
    - * - make sure that we don't divide by zero when calculating JPEG size
    - * - {@link allowed} and {@link forbidden} can now accept strings
    - * - try to guess the file extension from the MIME type if there is no file extension
    - * - better class properties when changing the file extension
    - * - added {@link file_force_extension} to allow extension-less files if needed
    - * - better file safe conversion of the filename
    - * - allow shorthand byte values, such as 1K, 2M, 3G for {@link file_max_size} and {@link jpeg_size}
    - * - added {@link image_opacity} to change picture opacity
    - * - added {@link image_border_opacity} to allow semi-transparent borders
    - * - added {@link image_frame_opacity} to allow semi-transparent frames
    - * - added {@link image_border_transparent} to allow borders fading to transparent
    - * - duplicated {@link image_overlay_percent} into {@link image_overlay_opacity}
    - * - duplicated {@link image_text_percent} into {@link image_text_opacity}
    - * - duplicated {@link image_text_background_percent} into {@link image_text_background_opacity}
  • - *
  • v 0.30 05/09/2010
    - * - implemented an unsharp mask, with alpha transparency support, activated if {@link image_unsharp} is true. added {@link image_unsharp_amount}, {@link image_unsharp_radius}, and {@link image_unsharp_threshold}
    - * - added text/rtf MIME type, and no_script exception
    - * - corrected bug when {@link no_script} is activated and several process() are called
    - * - better error handling for finfo
    - * - display upload_max_filesize information from php.ini in the log
    - * - automatic extension for extension-less images
    - * - fixed {@link image_ratio_fill} top and left filling
    - * - fixed alphablending issue when applying a transparent PNG watermark on a transparent PNG
    - * - added {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to allow the watermark to be resized down (or up) to fit in the image. By default, the watermark may be resized down, but not up.
  • - *
  • v 0.29 03/02/2010
    - * - added protection against malicious images
    - * - added zip and torrent MIME type
    - * - replaced split() with explode()
    - * - initialise image_dst_x/y with image_src_x/y
    - * - removed {@link mime_fileinfo}, {@link mime_file}, {@link mime_magic} and {@link mime_getimagesize} from the docs since they are used before {@link process}
    - * - added more extensions and MIME types
    - * - improved MIME type validation
    - * - improved logging
  • - *
  • v 0.28 10/08/2009
    - * - replaced ereg functions to be compatible with PHP 5.3
    - * - added flv MIME type
    - * - improved MIME type detection
    - * - added {@link file_name_body_pre} to prepend a string to the file name
    - * - added {@link mime_fileinfo}, {@link mime_file}, {@link mime_magic} and {@link mime_getimagesize} so that it is possible to deactivate some MIME type checking method
    - * - use exec() rather than shell_exec(), to play better with safe mode
    - * - added some error messages
    - * - fix bug when checking on conditions, {@link processed} wasn't propagated properly
  • - *
  • v 0.27 14/05/2009
    - * - look for the language files directory from __FILE__
    - * - deactivate {@link file_auto_rename} if {@link file_overwrite} is set
    - * - improved transparency replacement for true color images
    - * - fixed calls to newer version of UNIX file utility
    - * - fixed error when using PECL Fileinfo extension in SAFE MODE, and when using the finfo class
    - * - added {@link image_precrop} to crop the image before an eventual resizing
  • - *
  • v 0.26 13/11/2008
    - * - rewrote conversion from palette to true color to handle transparency better
    - * - fixed imagecopymergealpha() when the overlayed image is of wrong dimensions
    - * - fixed imagecreatenew() when the image to create have less than 1 pixels width or height
    - * - rewrote MIME type detection to be more secure and not rely on browser information; now using Fileinfo PECL extension, UNIX file() command, MIME magic, and getimagesize(), in that order
    - * - added support for Flash uploaders
    - * - some bug fixing and error handling
  • - *
  • v 0.25 17/11/2007
    - * - added translation files and mechanism to instantiate the class with a language different from English
    - * - added {@link forbidden} to set an array of forbidden MIME types
    - * - implemented support for simple wildcards in {@link allowed} and {@link forbidden}, such as image/*
    - * - preset the file extension to the desired conversion format when converting an image
    - * - added read and write support for BMP images
    - * - added a flag {@link file_is_image} to determine if the file is a supported image type
    - * - the class now provides some information about the image, before calling {@link process}(). Available are {@link image_src_x}, {@link image_src_y} and the newly introduced {@link image_src_bits}, {@link image_src_pixels} and {@link image_src_type}. Note that this will not work if open_basedir restrictions are in place
    - * - improved logging; now provides useful system information
    - * - added some more pre-processing checks for files that are images: {@link image_max_width}, {@link image_max_height}, {@link image_max_pixels}, {@link image_max_ratio}, {@link image_min_width}, {@link image_min_height}, {@link image_min_pixels} and {@link image_min_ratio}
    - * - added {@link image_ratio_pixels} to resize an image to a number of pixels, keeping aspect ratio
    - * - added {@link image_is_palette} and {@link image_is_transparent} and {@link image_transparent_color} for GIF images
    - * - added {@link image_default_color} to define a fallback color for non alpha-transparent output formats, such as JPEG or BMP
    - * - changed {@link image_background_color}, which now forces transparent areas to be painted
    - * - improved reflections and color overlays so that it works with alpha transparent images
    - * - {@link image_reflection_color} is now deprecated in favour of {@link image_default_color}
    - * - transparent PNGs are now processed in true color, and fully preserving the alpha channel when doing merges
    - * - transparent GIFs are now automatically detected. {@link preserve_transparency} is deprecated
    - * - transparent true color images can be saved as GIF while retaining transparency, semi transparent areas being merged with {@link image_default_color}
    - * - transparent true color images can be saved as JPG/BMP with the semi transparent areas being merged with {@link image_default_color}
    - * - fixed conversion of images to true color
    - * - the class can now output the uploaded files content as the return value of process() if the function is called with an empty or null argumenti, or no argument
  • - *
  • v 0.24 25/05/2007
    - * - added {@link image_background_color}, to set the default background color of an image
    - * - added possibility of using replacement tokens in text labels
    - * - changed default JPEG quality to 85
    - * - fixed a small bug when using greyscale filter and associated filters
    - * - added {@link image_ratio_fill} in order to fit an image within some dimensions and color the remaining space. Very similar to {@link image_ratio_crop}
    - * - improved the recursive creation of directories
    - * - the class now converts palette based images to true colors before doing graphic manipulations
  • - *
  • v 0.23 23/12/2006
    - * - fixed a bug when processing more than once the same uploaded file. If there is an open_basedir restriction, the class now creates a temporary file for the first call to process(). This file will be used for subsequent processes, and will be deleted upon calling clean()
  • - *
  • v 0.22 16/12/2006
    - * - added automatic creation of a temporary file if the upload directory is not within open_basedir
    - * - fixed a bug which was preventing to work on a local file by overwriting it with its processed copy
    - * - added MIME types video/x-ms-wmv and image/x-png and fixed PNG support for IE weird MIME types
    - * - modified {@link image_ratio_crop} so it can accept one or more from string 'TBLR', determining which side of the image is kept while cropping
    - * - added support for multiple lines in the text, using "\n" as a line break
    - * - added {@link image_text_line_spacing} which allow to set the space between several lines of text
    - * - added {@link image_text_alignment} which allow to set the alignment when text has several lines
    - * - {@link image_text_font} can now be set to the path of a GDF font to load external fonts
    - * - added {@link image_reflection_height} to create a reflection of the source image, which height is in pixels or percentage
    - * - added {@link image_reflection_space} to set the space in pixels between the source image and the reflection
    - * - added {@link image_reflection_color} to set the reflection background color
    - * - added {@link image_reflection_opacity} to set the initial level of opacity of the reflection
  • - *
  • v 0.21 30/09/2006
    - * - added {@link image_ratio_crop} which resizes within {@link image_x} and {@link image_y}, keeping ratio, but filling the space by cropping excedent of image
    - * - added {@link mime_check}, which default is true, to set checks against {@link allowed} MIME list
    - * - if MIME is empty, the class now triggers an error
    - * - color #000000 is OK for {@link image_text_color}, and related text transparency bug fixed
    - * - {@link gd_version}() now uses gd_info(), or else phpinfo()
    - * - fixed path issue when the destination path has no trailing slash on Windows systems
    - * - removed inline functions to be fully PHP5 compatible
  • - *
  • v 0.20 11/08/2006
    - * - added some more error checking and messages (GD presence, permissions...)
    - * - fix when uploading files without extension
    - * - changed values for {@link image_brightness} and {@link image_contrast} to be between -127 and 127
    - * - added {@link dir_auto_create} to automatically and recursively create destination directory if missing.
    - * - added {@link dir_auto_chmod} to automatically chmod the destination directory if not writeable.
    - * - added {@link dir_chmod} to set the default chmod to use.
    - * - added {@link image_crop} to crop images
    - * - added {@link image_negative} to invert the colors on the image
    - * - added {@link image_greyscale} to turn the image into greyscale
    - * - added {@link image_threshold} to apply a threshold filter on the image
    - * - added {@link image_bevel}, {@link image_bevel_color1} and {@link image_bevel_color2} to add a bevel border
    - * - added {@link image_border} and {@link image_border_color} to add a single color border
    - * - added {@link image_frame} and {@link image_frame_colors} to add a multicolored frame
  • - *
  • v 0.19 29/03/2006
    - * - class is now compatible i18n (thanks Sylwester).
    - * - the class can mow manipulate local files, not only uploaded files (instanciate the class with a local filename).
    - * - {@link file_safe_name} has been improved a bit.
    - * - added {@link image_brightness}, {@link image_contrast}, {@link image_tint_color}, {@link image_overlay_color} and {@link image_overlay_percent} to do color manipulation on the images.
    - * - added {@link image_text} and all derivated settings to add a text label on the image.
    - * - added {@link image_watermark} and all derivated settings to add a watermark image on the image.
    - * - added {@link image_flip} and {@link image_rotate} for more image manipulations
    - * - added {@link jpeg_size} to calculate the JPG compression quality in order to fit within one filesize.
  • - *
  • v 0.18 02/02/2006
    - * - added {@link no_script} to turn dangerous scripts into text files.
    - * - added {@link mime_magic_check} to set the class to use mime_magic.
    - * - added {@link preserve_transparency} *experimental*. Thanks Gregor.
    - * - fixed size and mime checking, wasn't working :/ Thanks Willem.
    - * - fixed memory leak when resizing images.
    - * - when resizing, it is not necessary anymore to set {@link image_convert}.
    - * - il is now possible to simply convert an image, with no resizing.
    - * - sets the default {@link file_max_size} to upload_max_filesize from php.ini. Thanks Edward
  • - *
  • v 0.17 28/05/2005
    - * - the class can be used with any version of GD.
    - * - added security check on the file with a list of mime-types.
    - * - changed the license to GPL v2 only
  • - *
  • v 0.16 19/05/2005
    - * - added {@link file_auto_rename} automatic file renaming if the same filename already exists.
    - * - added {@link file_safe_name} safe formatting of the filename (spaces to _underscores so far).
    - * - added some more error reporting to avoid crash if GD is not present
  • - *
  • v 0.15 16/04/2005
    - * - added JPEG compression quality setting. Thanks Vad
  • - *
  • v 0.14 14/03/2005
    - * - reworked the class file to allow parsing with phpDocumentor
  • - *
  • v 0.13 07/03/2005
    - * - fixed a bug with {@link image_ratio}. Thanks Justin.
    - * - added {@link image_ratio_no_zoom_in} and {@link image_ratio_no_zoom_out}
  • - *
  • v 0.12 21/01/2005
    - * - added {@link image_ratio} to resize within max values, keeping image ratio
  • - *
  • v 0.11 22/08/2003
    - * - update for GD2 (changed imageresized() into imagecopyresampled() and imagecreate() into imagecreatetruecolor())
  • - *
- * - * @package cmf - * @subpackage external */ class upload { @@ -933,7 +355,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. * @@ -950,7 +372,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 @@ -961,7 +383,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, @@ -975,7 +397,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() @@ -1061,7 +483,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 @@ -1171,9 +593,31 @@ class upload { var $image_ratio_pixels; /** - * Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}, + * Set this variable to calculate {@link image_x} automatically , using {@link image_y} and conserving ratio + * + * Default value is false + * + * @access public + * @var bool + */ + var $image_ratio_x; + + /** + * Set this variable to calculate {@link image_y} automatically , using {@link image_x} and conserving ratio + * + * Default value is false + * + * @access public + * @var bool + */ + var $image_ratio_y; + + /** + * (deprecated) Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}, * but only if original image is bigger * + * This setting is soon to be deprecated. Instead, use {@link image_ratio} and {@link image_no_enlarging} + * * Default value is false * * @access public @@ -1182,35 +626,37 @@ class upload { var $image_ratio_no_zoom_in; /** - * Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}, + * (deprecated) Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}, * but only if original image is smaller * * Default value is false * + * This setting is soon to be deprecated. Instead, use {@link image_ratio} and {@link image_no_shrinking} + * * @access public * @var bool */ var $image_ratio_no_zoom_out; /** - * Set this variable to calculate {@link image_x} automatically , using {@link image_y} and conserving ratio + * Cancel resizing if the resized image is bigger than the original image, to prevent enlarging * * Default value is false * * @access public * @var bool */ - var $image_ratio_x; + var $image_no_enlarging; /** - * Set this variable to calculate {@link image_y} automatically , using {@link image_x} and conserving ratio + * Cancel resizing if the resized image is smaller than the original image, to prevent shrinking * * Default value is false * * @access public * @var bool */ - var $image_ratio_y; + var $image_no_shrinking; /** * Set this variable to set a maximum image width, above which the upload will be invalid @@ -1298,7 +744,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) @@ -1324,7 +770,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) @@ -1344,17 +790,6 @@ class upload { */ var $image_interlace; - /** - * Preserve transparency when resizing or converting an image (deprecated) - * - * Default value is automatically set to true for transparent GIFs - * This setting is now deprecated - * - * @access public - * @var integer - */ - var $preserve_transparency; - /** * Flag set to true when the image is transparent * @@ -1502,14 +937,6 @@ class upload { */ var $image_overlay_opacity; - /** - * Soon to be deprecated old form of {@link image_overlay_opacity} - * - * @access public - * @var integer - */ - var $image_overlay_percent; - /** * Inverts the color of an image * @@ -1567,7 +994,7 @@ class upload { * @var integer */ var $image_unsharp_amount; - + /** * Sets the unsharp mask radius * @@ -1584,7 +1011,7 @@ class upload { * @var integer */ var $image_unsharp_radius; - + /** * Sets the unsharp mask threshold * @@ -1630,6 +1057,8 @@ class upload { * * Value is either 'h' or 'v', as in horizontal and vertical * + * Note that if you use a TrueType font, you can use {@link image_text_angle} instead + * * Default value is h (horizontal) * * @access public @@ -1661,14 +1090,6 @@ class upload { */ var $image_text_opacity; - /** - * Soon to be deprecated old form of {@link image_text_opacity} - * - * @access public - * @var integer - */ - var $image_text_percent; - /** * Sets the text background color for the text label * @@ -1693,19 +1114,11 @@ class upload { */ var $image_text_background_opacity; - /** - * Soon to be deprecated old form of {@link image_text_background_opacity} - * - * @access public - * @var integer - */ - var $image_text_background_percent; - /** * Sets the text font in the text label * * Value is a an integer between 1 and 5 for GD built-in fonts. 1 is the smallest font, 5 the biggest - * Value can also be a string, which represents the path to a GDF font. The font will be loaded into GD, and used as a built-in font. + * Value can also be a string, which represents the path to a GDF or TTF font (TrueType). * * Default value is 5 * @@ -1714,6 +1127,35 @@ class upload { */ var $image_text_font; + /** + * Sets the text font size for TrueType fonts + * + * Value is a an integer, and represents the font size in pixels (GD1) or points (GD1) + * + * Note that this setting is only applicable to TrueType fonts, and has no effects with GD fonts + * + * Default value is 16 + * + * @access public + * @var integer; + */ + var $image_text_size; + + /** + * Sets the text angle for TrueType fonts + * + * Value is a an integer between 0 and 360, in degrees, with 0 degrees being left-to-right reading text. + * + * Note that this setting is only applicable to TrueType fonts, and has no effects with GD fonts + * For GD fonts, you can use {@link image_text_direction} instead + * + * Default value is null (so it is determined by the value of {@link image_text_direction}) + * + * @access public + * @var integer; + */ + var $image_text_angle; + /** * Sets the text label position within the image * @@ -1812,6 +1254,8 @@ class upload { * * This setting is relevant only if the text has several lines. * + * Note that this setting is only applicable to GD fonts, and has no effects with TrueType fonts + * * @access public * @var string; */ @@ -1826,6 +1270,8 @@ class upload { * * This setting is relevant only if the text has several lines. * + * Note that this setting is only applicable to GD fonts, and has no effects with TrueType fonts + * * @access public * @var integer */ @@ -1858,22 +1304,6 @@ class upload { */ var $image_reflection_space; - /** - * Sets the color of the reflection background (deprecated) - * - * Value is an hexadecimal color, such as #FFFFFF - * - * Default value is #FFFFFF - * - * This setting is relevant only if {@link image_reflection_height} is set - * - * This setting is now deprecated in favor of {@link image_default_color} - * - * @access public - * @var string; - */ - var $image_reflection_color; - /** * Sets the initial opacity of the reflection * @@ -1889,6 +1319,16 @@ class upload { */ var $image_reflection_opacity; + /** + * Automatically rotates the image according to EXIF data (JPEG only) + * + * Default value is true + * + * @access public + * @var boolean; + */ + var $image_auto_rotate; + /** * Flips the image vertically or horizontally * @@ -2193,7 +1633,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) @@ -2202,7 +1642,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 @@ -2264,7 +1704,7 @@ class upload { * @access public * @var array */ - var $language; + var $lang; /** * Init or re-init all the processing variables to their default values @@ -2311,15 +1751,17 @@ function init() { $this->image_ratio_crop = false; // keeps aspect ratio with x and y dimensions, filling the space $this->image_ratio_fill = false; // keeps aspect ratio with x and y dimensions, fitting the image in the space, and coloring the rest $this->image_ratio_pixels = false; // keeps aspect ratio, calculating x and y so that the image is approx the set number of pixels - $this->image_ratio_no_zoom_in = false; - $this->image_ratio_no_zoom_out = false; $this->image_ratio_x = false; // calculate the $image_x if true $this->image_ratio_y = false; // calculate the $image_y if true + $this->image_ratio_no_zoom_in = false; + $this->image_ratio_no_zoom_out = false; + $this->image_no_enlarging = false; + $this->image_no_shrinking = false; + $this->png_compression = null; $this->jpeg_quality = 85; $this->jpeg_size = null; $this->image_interlace = false; - $this->preserve_transparency = false; $this->image_is_transparent = false; $this->image_transparent_color = null; $this->image_background_color = null; @@ -2342,7 +1784,6 @@ function init() { $this->image_tint_color = null; $this->image_overlay_color = null; $this->image_overlay_opacity = null; - $this->image_overlay_percent = null; $this->image_negative = false; $this->image_greyscale = false; $this->image_pixelate = null; @@ -2355,11 +1796,11 @@ function init() { $this->image_text_direction = null; $this->image_text_color = '#FFFFFF'; $this->image_text_opacity = 100; - $this->image_text_percent = 100; $this->image_text_background = null; $this->image_text_background_opacity = 100; - $this->image_text_background_percent = 100; $this->image_text_font = 5; + $this->image_text_size = 16; + $this->image_text_angle = null; $this->image_text_x = null; $this->image_text_y = null; $this->image_text_position = null; @@ -2371,7 +1812,6 @@ function init() { $this->image_reflection_height = null; $this->image_reflection_space = 2; - $this->image_reflection_color = '#ffffff'; $this->image_reflection_opacity = 60; $this->image_watermark = null; @@ -2382,6 +1822,7 @@ function init() { $this->image_watermark_no_zoom_out = false; $this->image_flip = null; + $this->image_auto_rotate = true; $this->image_rotate = null; $this->image_crop = null; $this->image_precrop = null; @@ -2482,7 +1923,8 @@ function init() { 'text/rtf', 'text/richtext', 'text/xml', - 'video/*' + 'video/*', + 'text/csv' ); $this->mime_types = array( @@ -2492,6 +1934,7 @@ function init() { 'gif' => 'image/gif', 'png' => 'image/png', 'bmp' => 'image/bmp', + 'flif' => 'image/flif', 'flv' => 'video/x-flv', 'js' => 'application/x-javascript', 'json' => 'application/json', @@ -2499,7 +1942,6 @@ function init() { 'css' => 'text/css', 'xml' => 'application/xml', 'doc' => 'application/msword', - 'docx' => 'application/msword', 'xls' => 'application/vnd.ms-excel', 'xlt' => 'application/vnd.ms-excel', 'xlm' => 'application/vnd.ms-excel', @@ -2568,12 +2010,20 @@ function init() { 'onetoc2' => 'application/onenote', 'onetmp' => 'application/onenote', 'onepkg' => 'application/onenote', + 'csv' => 'text/csv', ); } /** - * Constructor. Checks if the file has been uploaded + * Constructor, for PHP5+ + */ + function __construct($file, $lang = 'en_GB') { + $this->upload($file, $lang); + } + + /** + * Constructor, for PHP4. Checks if the file has been uploaded * * The constructor takes $_FILES['form_field'] array as argument * where form_field is the form field name @@ -2598,7 +2048,7 @@ function init() { */ function upload($file, $lang = 'en_GB') { - $this->version = '0.33dev'; + $this->version = '0.34dev'; $this->file_src_name = ''; $this->file_src_name_body = ''; @@ -2626,7 +2076,7 @@ function upload($file, $lang = 'en_GB') { $this->uploaded = true; $this->no_upload_check = false; - $this->processed = true; + $this->processed = false; $this->error = ''; $this->log = ''; $this->allowed = array(); @@ -2722,7 +2172,7 @@ function upload($file, $lang = 'en_GB') { // display some system information if (empty($this->log)) { $this->log .= 'system information
'; - if (function_exists('ini_get_all')) { + if ($this->function_enabled('ini_get_all')) { $inis = ini_get_all(); $open_basedir = (array_key_exists('open_basedir', $inis) && array_key_exists('local_value', $inis['open_basedir']) && !empty($inis['open_basedir']['local_value'])) ? $inis['open_basedir']['local_value'] : false; } else { @@ -2751,24 +2201,56 @@ function upload($file, $lang = 'en_GB') { $this->uploaded = false; $this->error = $this->translate('file_error'); } else { - if (substr($file, 0, 4) == 'php:') { - // this is a local filename, i.e.not uploaded - $file = preg_replace('/^php:(.*)/i', '$1', $file); - if (!$file) $file = $_SERVER['HTTP_X_FILE_NAME']; - 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'))) { - $this->file_src_pathname = $hash; - $this->log .= ' file created
'; - $this->log .= '    temp file is: ' . $this->file_src_pathname . '
'; - } else { - $this->log .= ' failed
'; + if (substr($file, 0, 4) == 'php:' || substr($file, 0, 5) == 'data:' || substr($file, 0, 7) == 'base64:') { + $data = null; + + // this is a PHP stream, i.e.not uploaded + if (substr($file, 0, 4) == 'php:') { + $file = preg_replace('/^php:(.*)/i', '$1', $file); + if (!$file) $file = $_SERVER['HTTP_X_FILE_NAME']; + if (!$file) $file = 'unknown'; + $data = file_get_contents('php://input'); + $this->log .= 'source is a PHP stream ' . $file . ' of length ' . strlen($data) . '
'; + + // this is the raw file data, base64-encoded, i.e.not uploaded + } else if (substr($file, 0, 7) == 'base64:') { + $data = base64_decode(preg_replace('/^base64:(.*)/i', '$1', $file)); + $file = 'base64'; + $this->log .= 'source is a base64 string of length ' . strlen($data) . '
'; + + // this is the raw file data, base64-encoded, i.e.not uploaded + } else if (substr($file, 0, 5) == 'data:' && strpos($file, 'base64,') !== false) { + $data = base64_decode(preg_replace('/^data:.*base64,(.*)/i', '$1', $file)); + $file = 'base64'; + $this->log .= 'source is a base64 data string of length ' . strlen($data) . '
'; + + // this is the raw file data, i.e.not uploaded + } else if (substr($file, 0, 5) == 'data:') { + $data = preg_replace('/^data:(.*)/i', '$1', $file); + $file = 'data'; + $this->log .= 'source is a data string of length ' . strlen($data) . '
'; + } + + if (!$data) { + $this->log .= '- source is empty!
'; $this->uploaded = false; - $this->error = $this->translate('temp_file'); + $this->error = $this->translate('source_invalid'); + } + + $this->no_upload_check = TRUE; + + if ($this->uploaded) { + $this->log .= '- requires a temp file ... '; + $hash = $this->temp_dir() . md5($file . rand(1, 1000)); + if ($data && file_put_contents($hash, $data)) { + $this->file_src_pathname = $hash; + $this->log .= ' file created
'; + $this->log .= '    temp file is: ' . $this->file_src_pathname . '
'; + } else { + $this->log .= ' failed
'; + $this->uploaded = false; + $this->error = $this->translate('temp_file'); + } } if ($this->uploaded) { @@ -2788,7 +2270,7 @@ function upload($file, $lang = 'en_GB') { } else { // this is a local filename, i.e.not uploaded - $this->log .= '' . $this->translate("source is a local file") . ' ' . $file . '
'; + $this->log .= 'source is a local file ' . $file . '
'; $this->no_upload_check = TRUE; if ($this->uploaded && !file_exists($file)) { @@ -2800,7 +2282,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); @@ -2815,7 +2297,7 @@ function upload($file, $lang = 'en_GB') { } $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 { @@ -2894,13 +2376,13 @@ function upload($file, $lang = 'en_GB') { if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) { if ($this->mime_fileinfo) { $this->log .= '- Checking MIME type with Fileinfo PECL extension
'; - if (function_exists('finfo_open')) { + if ($this->function_enabled('finfo_open')) { $path = null; if ($this->mime_fileinfo !== '') { if ($this->mime_fileinfo === true) { if (getenv('MAGIC') === FALSE) { if (substr(PHP_OS, 0, 3) == 'WIN') { - $path = realpath(ini_get('extension_dir') . '/../') . 'extras/magic'; + $path = realpath(ini_get('extension_dir') . '/../') . '/extras/magic'; $this->log .= '    MAGIC path defaults to ' . $path . '
'; } } else { @@ -2923,8 +2405,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; @@ -2932,13 +2414,13 @@ function upload($file, $lang = 'en_GB') { } else { $this->log .= '    Fileinfo PECL extension failed (finfo_open)
'; } - } elseif (@class_exists('finfo')) { + } elseif (@class_exists('finfo', false)) { $f = new finfo( FILEINFO_MIME ); 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; @@ -2959,12 +2441,12 @@ function upload($file, $lang = 'en_GB') { if ($this->mime_file) { $this->log .= '- Checking MIME type with UNIX file() command
'; if (substr(PHP_OS, 0, 3) != 'WIN') { - if (function_exists('exec') && function_exists('escapeshellarg') && !extension_loaded('suhosin')) { + if ($this->function_enabled('exec') && $this->function_enabled('escapeshellarg')) { 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; @@ -2987,11 +2469,11 @@ function upload($file, $lang = 'en_GB') { if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) { if ($this->mime_magic) { $this->log .= '- Checking MIME type with mime.magic file (mime_content_type())
'; - if (function_exists('mime_content_type')) { + if ($this->function_enabled('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; @@ -3017,8 +2499,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; @@ -3035,8 +2517,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; @@ -3121,7 +2603,7 @@ function gdversion($full = false) { static $gd_version = null; static $gd_full_version = null; if ($gd_version === null) { - if (function_exists('gd_info')) { + if ($this->function_enabled('gd_info')) { $gd = gd_info(); $gd = $gd["GD Version"]; $regex = "/([\d\.]+)/i"; @@ -3147,6 +2629,24 @@ function gdversion($full = false) { } } + /** + * Checks if a function is available + * + * @access private + * @param string $func Function name + * @return boolean Success + */ + function function_enabled($func) { + // cache the list of disabled functions + static $disabled = null; + if ($disabled === null) $disabled = array_map('trim', array_map('strtolower', explode(',', ini_get('disable_functions')))); + // cache the list of functions blacklisted by suhosin + static $blacklist = null; + if ($blacklist === null) $blacklist = extension_loaded('suhosin') ? array_map('trim', array_map('strtolower', explode(',', ini_get(' suhosin.executor.func.blacklist')))) : array(); + // checks if the function is really enabled + return (function_exists($func) && !in_array($func, $disabled) && !in_array($func, $blacklist)); + } + /** * Creates directories recursively * @@ -3196,7 +2696,7 @@ function translate($str, $tokens = array()) { */ function temp_dir() { $dir = ''; - if (function_exists('sys_get_temp_dir')) $dir = sys_get_temp_dir(); + if ($this->function_enabled('sys_get_temp_dir')) $dir = sys_get_temp_dir(); if (!$dir && $tmp=getenv('TMP')) $dir = $tmp; if (!$dir && $tmp=getenv('TEMP')) $dir = $tmp; if (!$dir && $tmp=getenv('TMPDIR')) $dir = $tmp; @@ -3238,7 +2738,9 @@ function getcolors($color) { * @return integer Size in bytes */ function getsize($size) { + if ($size === null) return null; $last = strtolower($size{strlen($size)-1}); + $size = (int) $size; switch($last) { case 'g': $size *= 1024; @@ -3279,13 +2781,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; @@ -3456,10 +2958,6 @@ function process($server_path = null) { // clean up some parameters $this->file_max_size = $this->getsize($this->file_max_size); $this->jpeg_size = $this->getsize($this->jpeg_size); - // some parameters are being deprecated, and replaced with others - if (is_null($this->image_overlay_opacity)) $this->image_overlay_opacity = $this->image_overlay_percent; - if ($this->image_text_opacity == 100) $this->image_text_opacity = $this->image_text_percent; - if ($this->image_text_background_opacity == 100) $this->image_text_background_opacity = $this->image_text_background_percent; // copy some variables as we need to keep them clean $file_src_name = $this->file_src_name; @@ -3489,7 +2987,7 @@ function process($server_path = null) { // checks file max size if ($this->file_src_size > $this->file_max_size) { $this->processed = false; - $this->error = $this->translate('file_too_big'); + $this->error = $this->translate('file_too_big') . ' : ' . $this->file_src_size . ' > ' . $this->file_max_size; } else { $this->log .= '- file size OK
'; } @@ -3627,8 +3125,8 @@ function process($server_path = null) { $this->log .= '- file name body prepend : ' . $this->file_name_body_pre . '
'; } if ($this->file_safe_name) { // formats the name - $this->file_dst_name_body = utf8_encode(strtr(utf8_decode($this->file_dst_name_body), utf8_decode('ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝà áâãäåçèéêëìíîïñòóôõöøùúûüýÿ'), 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy')); - $this->file_dst_name_body = strtr($this->file_dst_name_body, array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Å’' => 'OE', 'Å“' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u')); + $this->file_dst_name_body = utf8_encode(strtr(utf8_decode($this->file_dst_name_body), utf8_decode('ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ'), 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy')); + $this->file_dst_name_body = strtr($this->file_dst_name_body, array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u')); $this->file_dst_name_body = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $this->file_dst_name_body); $this->log .= '- file name safe format
'; } @@ -3642,33 +3140,6 @@ function process($server_path = null) { $this->log .= '    file_dst_name_body : ' . $this->file_dst_name_body . '
'; $this->log .= '    file_dst_name_ext : ' . $this->file_dst_name_ext . '
'; - // 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)); - // 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 : ''); @@ -3810,6 +3281,92 @@ function process($server_path = null) { if ($this->processed) { + // check if we need to autorotate, to automatically pre-rotates the image according to EXIF data (JPEG only) + $auto_flip = false; + $auto_rotate = 0; + if ($this->file_is_image && $this->image_auto_rotate && $this->image_src_type == 'jpg' && $this->function_enabled('exif_read_data')) { + $exif = @exif_read_data($this->file_src_pathname); + if (is_array($exif) && isset($exif['Orientation'])) { + $orientation = $exif['Orientation']; + switch($orientation) { + case 1: + $this->log .= '- EXIF orientation = 1 : default
'; + break; + case 2: + $auto_flip = 'v'; + $this->log .= '- EXIF orientation = 2 : vertical flip
'; + break; + case 3: + $auto_rotate = 180; + $this->log .= '- EXIF orientation = 3 : 180 rotate left
'; + break; + case 4: + $auto_flip = 'h'; + $this->log .= '- EXIF orientation = 4 : horizontal flip
'; + break; + case 5: + $auto_flip = 'h'; + $auto_rotate = 90; + $this->log .= '- EXIF orientation = 5 : horizontal flip + 90 rotate right
'; + break; + case 6: + $auto_rotate = 90; + $this->log .= '- EXIF orientation = 6 : 90 rotate right
'; + break; + case 7: + $auto_flip = 'v'; + $auto_rotate = 90; + $this->log .= '- EXIF orientation = 7 : vertical flip + 90 rotate right
'; + break; + case 8: + $auto_rotate = 270; + $this->log .= '- EXIF orientation = 8 : 90 rotate left
'; + break; + default: + $this->log .= '- EXIF orientation = '.$orientation.' : unknown
'; + break; + } + } else { + $this->log .= '- EXIF data is invalid or missing
'; + } + } else { + if (!$this->image_auto_rotate) { + $this->log .= '- auto-rotate deactivated
'; + } else if (!$this->image_src_type == 'jpg') { + $this->log .= '- auto-rotate applies only to JPEG images
'; + } else if (!$this->function_enabled('exif_read_data')) { + $this->log .= '- auto-rotate requires function exif_read_data to be enabled
'; + } + } + + // 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) + || $auto_rotate || $auto_flip + || 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)); + // we do a quick check to ensure the file is really an image // we can do this only now, as it would have failed before in case of open_basedir if ($image_manipulation && !@getimagesize($this->file_src_pathname)) { @@ -3835,7 +3392,7 @@ function process($server_path = null) { if ($this->gdversion()) { switch($this->image_src_type) { case 'jpg': - if (!function_exists('imagecreatefromjpeg')) { + if (!$this->function_enabled('imagecreatefromjpeg')) { $this->processed = false; $this->error = $this->translate('no_create_support', array('JPEG')); } else { @@ -3849,7 +3406,7 @@ function process($server_path = null) { } break; case 'png': - if (!function_exists('imagecreatefrompng')) { + if (!$this->function_enabled('imagecreatefrompng')) { $this->processed = false; $this->error = $this->translate('no_create_support', array('PNG')); } else { @@ -3863,7 +3420,7 @@ function process($server_path = null) { } break; case 'gif': - if (!function_exists('imagecreatefromgif')) { + if (!$this->function_enabled('imagecreatefromgif')) { $this->processed = false; $this->error = $this->translate('no_create_support', array('GIF')); } else { @@ -3950,9 +3507,58 @@ function process($server_path = null) { $this->image_is_palette = false; } - $image_dst = & $image_src; + // auto-flip image, according to EXIF data (JPEG only) + if ($gd_version >= 2 && !empty($auto_flip)) { + $this->log .= '- auto-flip image : ' . ($auto_flip == 'v' ? 'vertical' : 'horizontal') . '
'; + $tmp = $this->imagecreatenew($this->image_src_x, $this->image_src_y); + for ($x = 0; $x < $this->image_src_x; $x++) { + for ($y = 0; $y < $this->image_src_y; $y++){ + if (strpos($auto_flip, 'v') !== false) { + imagecopy($tmp, $image_dst, $this->image_src_x - $x - 1, $y, $x, $y, 1, 1); + } else { + imagecopy($tmp, $image_dst, $x, $this->image_src_y - $y - 1, $x, $y, 1, 1); + } + } + } + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + + // auto-rotate image, according to EXIF data (JPEG only) + if ($gd_version >= 2 && is_numeric($auto_rotate)) { + if (!in_array($auto_rotate, array(0, 90, 180, 270))) $auto_rotate = 0; + if ($auto_rotate != 0) { + if ($auto_rotate == 90 || $auto_rotate == 270) { + $tmp = $this->imagecreatenew($this->image_src_y, $this->image_src_x); + } else { + $tmp = $this->imagecreatenew($this->image_src_x, $this->image_src_y); + } + $this->log .= '- auto-rotate image : ' . $auto_rotate . '
'; + for ($x = 0; $x < $this->image_src_x; $x++) { + for ($y = 0; $y < $this->image_src_y; $y++){ + if ($auto_rotate == 90) { + imagecopy($tmp, $image_dst, $y, $x, $x, $this->image_src_y - $y - 1, 1, 1); + } else if ($auto_rotate == 180) { + imagecopy($tmp, $image_dst, $x, $y, $this->image_src_x - $x - 1, $this->image_src_y - $y - 1, 1, 1); + } else if ($auto_rotate == 270) { + imagecopy($tmp, $image_dst, $y, $x, $this->image_src_x - $x - 1, $y, 1, 1); + } else { + imagecopy($tmp, $image_dst, $x, $y, $x, $y, 1, 1); + } + } + } + if ($auto_rotate == 90 || $auto_rotate == 270) { + $t = $this->image_src_y; + $this->image_src_y = $this->image_src_x; + $this->image_src_x = $t; + } + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + } + // pre-crop image, before resizing if ((!empty($this->image_precrop))) { list($ct, $cr, $cb, $cl) = $this->getoffsets($this->image_precrop, $this->image_src_x, $this->image_src_y, true, true); @@ -3989,118 +3595,129 @@ function process($server_path = null) { // resize image (and move image_src_x, image_src_y dimensions into image_dst_x, image_dst_y) if ($this->image_resize) { $this->log .= '- resizing...
'; + $this->image_dst_x = $this->image_x; + $this->image_dst_y = $this->image_y; + + // backward compatibility for soon to be deprecated settings + if ($this->image_ratio_no_zoom_in) { + $this->image_ratio = true; + $this->image_no_enlarging = true; + } else if ($this->image_ratio_no_zoom_out) { + $this->image_ratio = true; + $this->image_no_shrinking = true; + } + // keeps aspect ratio with x calculated from y if ($this->image_ratio_x) { $this->log .= '    calculate x size
'; $this->image_dst_x = round(($this->image_src_x * $this->image_y) / $this->image_src_y); $this->image_dst_y = $this->image_y; + + // keeps aspect ratio with y calculated from x } else if ($this->image_ratio_y) { $this->log .= '    calculate y size
'; $this->image_dst_x = $this->image_x; $this->image_dst_y = round(($this->image_src_y * $this->image_x) / $this->image_src_x); + + // keeps aspect ratio, calculating x and y so that the image is approx the set number of pixels } else if (is_numeric($this->image_ratio_pixels)) { $this->log .= '    calculate x/y size to match a number of pixels
'; $pixels = $this->image_src_y * $this->image_src_x; $diff = sqrt($this->image_ratio_pixels / $pixels); $this->image_dst_x = round($this->image_src_x * $diff); $this->image_dst_y = round($this->image_src_y * $diff); - } 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)) { + + // keeps aspect ratio with x and y dimensions, filling the space + } else if ($this->image_ratio_crop) { + if (!is_string($this->image_ratio_crop)) $this->image_ratio_crop = ''; + $this->image_ratio_crop = strtolower($this->image_ratio_crop); + if (($this->image_src_x/$this->image_x) > ($this->image_src_y/$this->image_y)) { + $this->image_dst_y = $this->image_y; + $this->image_dst_x = intval($this->image_src_x*($this->image_y / $this->image_src_y)); + $ratio_crop = array(); + $ratio_crop['x'] = $this->image_dst_x - $this->image_x; + if (strpos($this->image_ratio_crop, 'l') !== false) { + $ratio_crop['l'] = 0; + $ratio_crop['r'] = $ratio_crop['x']; + } else if (strpos($this->image_ratio_crop, 'r') !== false) { + $ratio_crop['l'] = $ratio_crop['x']; + $ratio_crop['r'] = 0; + } else { + $ratio_crop['l'] = round($ratio_crop['x']/2); + $ratio_crop['r'] = $ratio_crop['x'] - $ratio_crop['l']; + } + $this->log .= '    ratio_crop_x : ' . $ratio_crop['x'] . ' (' . $ratio_crop['l'] . ';' . $ratio_crop['r'] . ')
'; + if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); + } else { $this->image_dst_x = $this->image_x; + $this->image_dst_y = intval($this->image_src_y*($this->image_x / $this->image_src_x)); + $ratio_crop = array(); + $ratio_crop['y'] = $this->image_dst_y - $this->image_y; + if (strpos($this->image_ratio_crop, 't') !== false) { + $ratio_crop['t'] = 0; + $ratio_crop['b'] = $ratio_crop['y']; + } else if (strpos($this->image_ratio_crop, 'b') !== false) { + $ratio_crop['t'] = $ratio_crop['y']; + $ratio_crop['b'] = 0; + } else { + $ratio_crop['t'] = round($ratio_crop['y']/2); + $ratio_crop['b'] = $ratio_crop['y'] - $ratio_crop['t']; + } + $this->log .= '    ratio_crop_y : ' . $ratio_crop['y'] . ' (' . $ratio_crop['t'] . ';' . $ratio_crop['b'] . ')
'; + if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); + } + + // keeps aspect ratio with x and y dimensions, fitting the image in the space, and coloring the rest + } else if ($this->image_ratio_fill) { + if (!is_string($this->image_ratio_fill)) $this->image_ratio_fill = ''; + $this->image_ratio_fill = strtolower($this->image_ratio_fill); + if (($this->image_src_x/$this->image_x) < ($this->image_src_y/$this->image_y)) { $this->image_dst_y = $this->image_y; - if ($this->image_ratio_crop) { - if (!is_string($this->image_ratio_crop)) $this->image_ratio_crop = ''; - $this->image_ratio_crop = strtolower($this->image_ratio_crop); - if (($this->image_src_x/$this->image_x) > ($this->image_src_y/$this->image_y)) { - $this->image_dst_y = $this->image_y; - $this->image_dst_x = intval($this->image_src_x*($this->image_y / $this->image_src_y)); - $ratio_crop = array(); - $ratio_crop['x'] = $this->image_dst_x - $this->image_x; - if (strpos($this->image_ratio_crop, 'l') !== false) { - $ratio_crop['l'] = 0; - $ratio_crop['r'] = $ratio_crop['x']; - } else if (strpos($this->image_ratio_crop, 'r') !== false) { - $ratio_crop['l'] = $ratio_crop['x']; - $ratio_crop['r'] = 0; - } else { - $ratio_crop['l'] = round($ratio_crop['x']/2); - $ratio_crop['r'] = $ratio_crop['x'] - $ratio_crop['l']; - } - $this->log .= '    ratio_crop_x : ' . $ratio_crop['x'] . ' (' . $ratio_crop['l'] . ';' . $ratio_crop['r'] . ')
'; - if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); - } else { - $this->image_dst_x = $this->image_x; - $this->image_dst_y = intval($this->image_src_y*($this->image_x / $this->image_src_x)); - $ratio_crop = array(); - $ratio_crop['y'] = $this->image_dst_y - $this->image_y; - if (strpos($this->image_ratio_crop, 't') !== false) { - $ratio_crop['t'] = 0; - $ratio_crop['b'] = $ratio_crop['y']; - } else if (strpos($this->image_ratio_crop, 'b') !== false) { - $ratio_crop['t'] = $ratio_crop['y']; - $ratio_crop['b'] = 0; - } else { - $ratio_crop['t'] = round($ratio_crop['y']/2); - $ratio_crop['b'] = $ratio_crop['y'] - $ratio_crop['t']; - } - $this->log .= '    ratio_crop_y : ' . $ratio_crop['y'] . ' (' . $ratio_crop['t'] . ';' . $ratio_crop['b'] . ')
'; - if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); - } - } else if ($this->image_ratio_fill) { - if (!is_string($this->image_ratio_fill)) $this->image_ratio_fill = ''; - $this->image_ratio_fill = strtolower($this->image_ratio_fill); - if (($this->image_src_x/$this->image_x) < ($this->image_src_y/$this->image_y)) { - $this->image_dst_y = $this->image_y; - $this->image_dst_x = intval($this->image_src_x*($this->image_y / $this->image_src_y)); - $ratio_crop = array(); - $ratio_crop['x'] = $this->image_dst_x - $this->image_x; - if (strpos($this->image_ratio_fill, 'l') !== false) { - $ratio_crop['l'] = 0; - $ratio_crop['r'] = $ratio_crop['x']; - } else if (strpos($this->image_ratio_fill, 'r') !== false) { - $ratio_crop['l'] = $ratio_crop['x']; - $ratio_crop['r'] = 0; - } else { - $ratio_crop['l'] = round($ratio_crop['x']/2); - $ratio_crop['r'] = $ratio_crop['x'] - $ratio_crop['l']; - } - $this->log .= '    ratio_fill_x : ' . $ratio_crop['x'] . ' (' . $ratio_crop['l'] . ';' . $ratio_crop['r'] . ')
'; - if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); - } else { - $this->image_dst_x = $this->image_x; - $this->image_dst_y = intval($this->image_src_y*($this->image_x / $this->image_src_x)); - $ratio_crop = array(); - $ratio_crop['y'] = $this->image_dst_y - $this->image_y; - if (strpos($this->image_ratio_fill, 't') !== false) { - $ratio_crop['t'] = 0; - $ratio_crop['b'] = $ratio_crop['y']; - } else if (strpos($this->image_ratio_fill, 'b') !== false) { - $ratio_crop['t'] = $ratio_crop['y']; - $ratio_crop['b'] = 0; - } else { - $ratio_crop['t'] = round($ratio_crop['y']/2); - $ratio_crop['b'] = $ratio_crop['y'] - $ratio_crop['t']; - } - $this->log .= '    ratio_fill_y : ' . $ratio_crop['y'] . ' (' . $ratio_crop['t'] . ';' . $ratio_crop['b'] . ')
'; - if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); - } + $this->image_dst_x = intval($this->image_src_x*($this->image_y / $this->image_src_y)); + $ratio_crop = array(); + $ratio_crop['x'] = $this->image_dst_x - $this->image_x; + if (strpos($this->image_ratio_fill, 'l') !== false) { + $ratio_crop['l'] = 0; + $ratio_crop['r'] = $ratio_crop['x']; + } else if (strpos($this->image_ratio_fill, 'r') !== false) { + $ratio_crop['l'] = $ratio_crop['x']; + $ratio_crop['r'] = 0; } else { - if (($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 = intval($this->image_src_y*($this->image_x / $this->image_src_x)); - } else { - $this->image_dst_y = $this->image_y; - $this->image_dst_x = intval($this->image_src_x*($this->image_y / $this->image_src_y)); - } + $ratio_crop['l'] = round($ratio_crop['x']/2); + $ratio_crop['r'] = $ratio_crop['x'] - $ratio_crop['l']; + } + $this->log .= '    ratio_fill_x : ' . $ratio_crop['x'] . ' (' . $ratio_crop['l'] . ';' . $ratio_crop['r'] . ')
'; + if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); + } else { + $this->image_dst_x = $this->image_x; + $this->image_dst_y = intval($this->image_src_y*($this->image_x / $this->image_src_x)); + $ratio_crop = array(); + $ratio_crop['y'] = $this->image_dst_y - $this->image_y; + if (strpos($this->image_ratio_fill, 't') !== false) { + $ratio_crop['t'] = 0; + $ratio_crop['b'] = $ratio_crop['y']; + } else if (strpos($this->image_ratio_fill, 'b') !== false) { + $ratio_crop['t'] = $ratio_crop['y']; + $ratio_crop['b'] = 0; + } else { + $ratio_crop['t'] = round($ratio_crop['y']/2); + $ratio_crop['b'] = $ratio_crop['y'] - $ratio_crop['t']; } + $this->log .= '    ratio_fill_y : ' . $ratio_crop['y'] . ' (' . $ratio_crop['t'] . ';' . $ratio_crop['b'] . ')
'; + if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); + } + + // keeps aspect ratio with x and y dimensions + } else if ($this->image_ratio) { + if (($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 = intval($this->image_src_y*($this->image_x / $this->image_src_x)); } else { - $this->log .= '    doesn\'t calculate x/y sizes
'; - $this->image_dst_x = $this->image_src_x; - $this->image_dst_y = $this->image_src_y; + $this->image_dst_y = $this->image_y; + $this->image_dst_x = intval($this->image_src_x*($this->image_y / $this->image_src_y)); } + + // resize to provided exact dimensions } else { $this->log .= '    use plain sizes
'; $this->image_dst_x = $this->image_x; @@ -4109,19 +3726,39 @@ function process($server_path = null) { if ($this->image_dst_x < 1) $this->image_dst_x = 1; if ($this->image_dst_y < 1) $this->image_dst_y = 1; - $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + $this->log .= '    image_src_x y : ' . $this->image_src_x . ' x ' . $this->image_src_y . '
'; + $this->log .= '    image_dst_x y : ' . $this->image_dst_x . ' x ' . $this->image_dst_y . '
'; - if ($gd_version >= 2) { - $res = imagecopyresampled($tmp, $image_src, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_src_x, $this->image_src_y); - } else { - $res = imagecopyresized($tmp, $image_src, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_src_x, $this->image_src_y); + // make sure we don't enlarge the image if we don't want to + if ($this->image_no_enlarging && ($this->image_src_x < $this->image_dst_x || $this->image_src_y < $this->image_dst_y)) { + $this->log .= '    cancel resizing, as it would enlarge the image!
'; + $this->image_dst_x = $this->image_src_x; + $this->image_dst_y = $this->image_src_y; + $ratio_crop = null; } - $this->log .= '    resized image object created
'; - $this->log .= '    image_src_x y : ' . $this->image_src_x . ' x ' . $this->image_src_y . '
'; - $this->log .= '    image_dst_x y : ' . $this->image_dst_x . ' x ' . $this->image_dst_y . '
'; - // we transfert tmp into image_dst - $image_dst = $this->imagetransfer($tmp, $image_dst); + // make sure we don't shrink the image if we don't want to + if ($this->image_no_shrinking && ($this->image_src_x > $this->image_dst_x || $this->image_src_y > $this->image_dst_y)) { + $this->log .= '    cancel resizing, as it would shrink the image!
'; + $this->image_dst_x = $this->image_src_x; + $this->image_dst_y = $this->image_src_y; + $ratio_crop = null; + } + + // resize the image + if ($this->image_dst_x != $this->image_src_x && $this->image_dst_y != $this->image_src_y) { + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + + if ($gd_version >= 2) { + $res = imagecopyresampled($tmp, $image_src, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_src_x, $this->image_src_y); + } else { + $res = imagecopyresized($tmp, $image_src, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_src_x, $this->image_src_y); + } + + $this->log .= '    resized image object created
'; + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } } else { $this->image_dst_x = $this->image_src_x; @@ -4138,34 +3775,36 @@ function process($server_path = null) { if (array_key_exists('b', $ratio_crop)) $cb += $ratio_crop['b']; if (array_key_exists('l', $ratio_crop)) $cl += $ratio_crop['l']; } - $this->log .= '- crop image : ' . $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 ($this->image_dst_x < 1) $this->image_dst_x = 1; - if ($this->image_dst_y < 1) $this->image_dst_y = 1; - $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); - - // we copy the image into the recieving image - imagecopy($tmp, $image_dst, 0, 0, $cl, $ct, $this->image_dst_x, $this->image_dst_y); - - // if we crop with negative margins, we have to make sure the extra bits are the right color, or transparent - if ($ct < 0 || $cr < 0 || $cb < 0 || $cl < 0 ) { - // use the background color if present - if (!empty($this->image_background_color)) { - list($red, $green, $blue) = $this->getcolors($this->image_background_color); - $fill = imagecolorallocate($tmp, $red, $green, $blue); - } else { - $fill = imagecolorallocatealpha($tmp, 0, 0, 0, 127); + if ($ct != 0 || $cr != 0 || $cb != 0 || $cl != 0) { + $this->log .= '- crop image : ' . $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 ($this->image_dst_x < 1) $this->image_dst_x = 1; + if ($this->image_dst_y < 1) $this->image_dst_y = 1; + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + + // we copy the image into the recieving image + imagecopy($tmp, $image_dst, 0, 0, $cl, $ct, $this->image_dst_x, $this->image_dst_y); + + // if we crop with negative margins, we have to make sure the extra bits are the right color, or transparent + if ($ct < 0 || $cr < 0 || $cb < 0 || $cl < 0 ) { + // use the background color if present + if (!empty($this->image_background_color)) { + list($red, $green, $blue) = $this->getcolors($this->image_background_color); + $fill = imagecolorallocate($tmp, $red, $green, $blue); + } else { + $fill = imagecolorallocatealpha($tmp, 0, 0, 0, 127); + } + // fills eventual negative margins + if ($ct < 0) imagefilledrectangle($tmp, 0, 0, $this->image_dst_x, -$ct-1, $fill); + if ($cr < 0) imagefilledrectangle($tmp, $this->image_dst_x + $cr, 0, $this->image_dst_x, $this->image_dst_y, $fill); + if ($cb < 0) imagefilledrectangle($tmp, 0, $this->image_dst_y + $cb, $this->image_dst_x, $this->image_dst_y, $fill); + if ($cl < 0) imagefilledrectangle($tmp, 0, 0, -$cl-1, $this->image_dst_y, $fill); } - // fills eventual negative margins - if ($ct < 0) imagefilledrectangle($tmp, 0, 0, $this->image_dst_x, -$ct-1, $fill); - if ($cr < 0) imagefilledrectangle($tmp, $this->image_dst_x + $cr, 0, $this->image_dst_x, $this->image_dst_y, $fill); - if ($cb < 0) imagefilledrectangle($tmp, 0, $this->image_dst_y + $cb, $this->image_dst_x, $this->image_dst_y, $fill); - if ($cl < 0) imagefilledrectangle($tmp, 0, 0, -$cl-1, $this->image_dst_y, $fill); - } - // we transfert tmp into image_dst - $image_dst = $this->imagetransfer($tmp, $image_dst); + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } } // flip image @@ -4232,70 +3871,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 ($this->function_enabled('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); } } @@ -4378,10 +4017,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 @@ -4394,8 +4033,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 @@ -4480,7 +4119,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); @@ -4530,7 +4169,7 @@ function process($server_path = null) { $watermark_type = (array_key_exists(2, $watermark_info) ? $watermark_info[2] : null); // 1 = GIF, 2 = JPG, 3 = PNG $watermark_checked = false; if ($watermark_type == IMAGETYPE_GIF) { - if (!function_exists('imagecreatefromgif')) { + if (!$this->function_enabled('imagecreatefromgif')) { $this->error = $this->translate('watermark_no_create_support', array('GIF')); } else { $filter = @imagecreatefromgif($this->image_watermark); @@ -4542,7 +4181,7 @@ function process($server_path = null) { } } } else if ($watermark_type == IMAGETYPE_JPEG) { - if (!function_exists('imagecreatefromjpeg')) { + if (!$this->function_enabled('imagecreatefromjpeg')) { $this->error = $this->translate('watermark_no_create_support', array('JPEG')); } else { $filter = @imagecreatefromjpeg($this->image_watermark); @@ -4554,7 +4193,7 @@ function process($server_path = null) { } } } else if ($watermark_type == IMAGETYPE_PNG) { - if (!function_exists('imagecreatefrompng')) { + if (!$this->function_enabled('imagecreatefrompng')) { $this->error = $this->translate('watermark_no_create_support', array('PNG')); } else { $filter = @imagecreatefrompng($this->image_watermark); @@ -4588,7 +4227,7 @@ function process($server_path = null) { 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)) { $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)); @@ -4714,8 +4353,11 @@ function process($server_path = null) { $this->image_text_direction = strtolower($this->image_text_direction); $this->image_text_alignment = strtolower($this->image_text_alignment); - // if the font is a string, we assume that we might want to load a font + $font_type = 'gd'; + + // if the font is a string with a GDF font path, we assume that we might want to load a font if (!is_numeric($this->image_text_font) && strlen($this->image_text_font) > 4 && substr(strtolower($this->image_text_font), -4) == '.gdf') { + if (strpos($this->image_text_font, '/') === false) $this->image_text_font = "./" . $this->image_text_font; $this->log .= '    try to load font ' . $this->image_text_font . '... '; if ($this->image_text_font = @imageloadfont($this->image_text_font)) { $this->log .= 'success
'; @@ -4725,29 +4367,66 @@ function process($server_path = null) { } } - $text = explode("\n", $this->image_text); - $char_width = imagefontwidth($this->image_text_font); - $char_height = imagefontheight($this->image_text_font); - $text_height = 0; - $text_width = 0; - $line_height = 0; - $line_width = 0; - - foreach ($text as $k => $v) { - if ($this->image_text_direction == 'v') { - $h = ($char_width * strlen($v)); - if ($h > $text_height) $text_height = $h; - $line_width = $char_height; - $text_width += $line_width + ($k < (sizeof($text)-1) ? $this->image_text_line_spacing : 0); + // if the font is a string with a TTF font path, we check if we can access the font file + if (!is_numeric($this->image_text_font) && strlen($this->image_text_font) > 4 && substr(strtolower($this->image_text_font), -4) == '.ttf') { + $this->log .= '    try to load font ' . $this->image_text_font . '... '; + if (strpos($this->image_text_font, '/') === false) $this->image_text_font = "./" . $this->image_text_font; + if (file_exists($this->image_text_font) && is_readable($this->image_text_font)) { + $this->log .= 'success
'; + $font_type = 'tt'; } else { - $w = ($char_width * strlen($v)); - if ($w > $text_width) $text_width = $w; - $line_height = $char_height; - $text_height += $line_height + ($k < (sizeof($text)-1) ? $this->image_text_line_spacing : 0); + $this->log .= 'error
'; + $this->image_text_font = 5; } } - $text_width += (2 * $this->image_text_padding_x); - $text_height += (2 * $this->image_text_padding_y); + + // get the text bounding box (GD fonts) + if ($font_type == 'gd') { + $text = explode("\n", $this->image_text); + $char_width = imagefontwidth($this->image_text_font); + $char_height = imagefontheight($this->image_text_font); + $text_height = 0; + $text_width = 0; + $line_height = 0; + $line_width = 0; + foreach ($text as $k => $v) { + if ($this->image_text_direction == 'v') { + $h = ($char_width * strlen($v)); + if ($h > $text_height) $text_height = $h; + $line_width = $char_height; + $text_width += $line_width + ($k < (sizeof($text)-1) ? $this->image_text_line_spacing : 0); + } else { + $w = ($char_width * strlen($v)); + if ($w > $text_width) $text_width = $w; + $line_height = $char_height; + $text_height += $line_height + ($k < (sizeof($text)-1) ? $this->image_text_line_spacing : 0); + } + } + $text_width += (2 * $this->image_text_padding_x); + $text_height += (2 * $this->image_text_padding_y); + + // get the text bounding box (TrueType fonts) + } else if ($font_type == 'tt') { + $text = $this->image_text; + if (!$this->image_text_angle) $this->image_text_angle = $this->image_text_direction == 'v' ? 90 : 0; + $text_height = 0; + $text_width = 0; + $text_offset_x = 0; + $text_offset_y = 0; + $rect = imagettfbbox($this->image_text_size, $this->image_text_angle, $this->image_text_font, $text ); + if ($rect) { + $minX = min(array($rect[0],$rect[2],$rect[4],$rect[6])); + $maxX = max(array($rect[0],$rect[2],$rect[4],$rect[6])); + $minY = min(array($rect[1],$rect[3],$rect[5],$rect[7])); + $maxY = max(array($rect[1],$rect[3],$rect[5],$rect[7])); + $text_offset_x = abs($minX) - 1; + $text_offset_y = abs($minY) - 1; + $text_width = $maxX - $minX + (2 * $this->image_text_padding_x); + $text_height = $maxY - $minY + (2 * $this->image_text_padding_y); + } + } + + // position the text block $text_x = 0; $text_y = 0; if (is_numeric($this->image_text_x)) { @@ -4809,44 +4488,66 @@ function process($server_path = null) { $filter = $this->imagecreatenew($t_width, $t_height, false, true); $text_color = imagecolorallocate($filter ,$red, $green, $blue); - 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); - } 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); + if ($font_type == 'gd') { + 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); + } 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); + } } + } else if ($font_type == 'tt') { + imagettftext($filter, + $this->image_text_size, + $this->image_text_angle, + $text_offset_x, + $text_offset_y, + $text_color, + $this->image_text_font, + $text); } $this->imagecopymergealpha($image_dst, $filter, $text_x, $text_y, 0, 0, $t_width, $t_height, $this->image_text_opacity); imagedestroy($filter); } else { - $text_color = imageColorAllocate($image_dst ,$red, $green, $blue); - 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); - } 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); + $text_color = imagecolorallocate($image_dst ,$red, $green, $blue); + if ($font_type == 'gd') { + 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); + } 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); + } } + } else if ($font_type == 'tt') { + imagettftext($image_dst, + $this->image_text_size, + $this->image_text_angle, + $text_offset_x + ($this->image_dst_x / 2) - ($text_width / 2) + $this->image_text_padding_x, + $text_offset_y + ($this->image_dst_y / 2) - ($text_height / 2) + $this->image_text_padding_y, + $text_color, + $this->image_text_font, + $text); } } } @@ -4927,7 +4628,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 diff --git a/administrator/components/com_jw_fillitup/views/default/tmpl/default.php b/administrator/components/com_jw_fillitup/views/default/tmpl/default.php index be089ab..49a56b2 100755 --- a/administrator/components/com_jw_fillitup/views/default/tmpl/default.php +++ b/administrator/components/com_jw_fillitup/views/default/tmpl/default.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ @@ -93,5 +93,5 @@
- Fill It Up v1.0.0 | Copyright © 2006- JoomlaWorks Ltd. + Fill It Up v1.1.0 | Copyright © 2006- JoomlaWorks Ltd.
diff --git a/administrator/components/com_jw_fillitup/views/default/tmpl/extension.php b/administrator/components/com_jw_fillitup/views/default/tmpl/extension.php index 1cda6cb..63a79b5 100755 --- a/administrator/components/com_jw_fillitup/views/default/tmpl/extension.php +++ b/administrator/components/com_jw_fillitup/views/default/tmpl/extension.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ @@ -64,5 +64,5 @@
- Fill It Up v1.0.0 | Copyright © 2006- JoomlaWorks Ltd. + Fill It Up v1.1.0 | Copyright © 2006- JoomlaWorks Ltd.
diff --git a/administrator/components/com_jw_fillitup/views/default/tmpl/popup.php b/administrator/components/com_jw_fillitup/views/default/tmpl/popup.php index ff03e44..858f82e 100755 --- a/administrator/components/com_jw_fillitup/views/default/tmpl/popup.php +++ b/administrator/components/com_jw_fillitup/views/default/tmpl/popup.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ @@ -67,5 +67,5 @@ function generate() {
- Fill It Up v1.0.0 | Copyright © 2006- JoomlaWorks Ltd. + Fill It Up v1.1.0 | Copyright © 2006- JoomlaWorks Ltd.
diff --git a/administrator/components/com_jw_fillitup/views/default/view.html.php b/administrator/components/com_jw_fillitup/views/default/view.html.php index c610e4d..9ef1526 100755 --- a/administrator/components/com_jw_fillitup/views/default/view.html.php +++ b/administrator/components/com_jw_fillitup/views/default/view.html.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ diff --git a/administrator/language/en-GB/en-GB.com_jw_fillitup.ini b/administrator/language/en-GB/en-GB.com_jw_fillitup.ini index e5170e3..3dc76b2 100755 --- a/administrator/language/en-GB/en-GB.com_jw_fillitup.ini +++ b/administrator/language/en-GB/en-GB.com_jw_fillitup.ini @@ -2,7 +2,7 @@ ; * @version 1.x ; * @package Fill It Up ; * @author JoomlaWorks http://www.joomlaworks.net -; * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. +; * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. ; * @license http://www.joomlaworks.net/license ; */ diff --git a/administrator/language/en-GB/en-GB.com_jw_fillitup.sys.ini b/administrator/language/en-GB/en-GB.com_jw_fillitup.sys.ini index 8ccf0f3..b793a7b 100755 --- a/administrator/language/en-GB/en-GB.com_jw_fillitup.sys.ini +++ b/administrator/language/en-GB/en-GB.com_jw_fillitup.sys.ini @@ -2,7 +2,7 @@ ; * @version 1.x ; * @package Fill It Up ; * @author JoomlaWorks http://www.joomlaworks.net -; * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. +; * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. ; * @license http://www.joomlaworks.net/license ; */ diff --git a/jw_fillitup.xml b/jw_fillitup.xml index 05c4561..95c504e 100755 --- a/jw_fillitup.xml +++ b/jw_fillitup.xml @@ -2,11 +2,11 @@ com_jw_fillitup JoomlaWorks - March 29th, 2016 - Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + January 29th, 2018 + Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. please-use-the-contact-form@joomlaworks.net www.joomlaworks.net - 1.0.0 + 1.1.0 http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL script.fillitup.php diff --git a/plugins/fillitup/content/content.php b/plugins/fillitup/content/content.php index 192e449..bdd3bd8 100755 --- a/plugins/fillitup/content/content.php +++ b/plugins/fillitup/content/content.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ diff --git a/plugins/fillitup/content/content.xml b/plugins/fillitup/content/content.xml index 6759cb2..b2fefd6 100755 --- a/plugins/fillitup/content/content.xml +++ b/plugins/fillitup/content/content.xml @@ -2,11 +2,11 @@ plg_fillitup_content JoomlaWorks - March 29th, 2016 - Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + January 29th, 2018 + Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. please-use-the-contact-form@joomlaworks.net www.joomlaworks.net - 1.0.0 + 1.1.0 http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL diff --git a/plugins/fillitup/content/en-GB.plg_fillitup_content.sys.ini b/plugins/fillitup/content/en-GB.plg_fillitup_content.sys.ini index f95cec1..afe8266 100755 --- a/plugins/fillitup/content/en-GB.plg_fillitup_content.sys.ini +++ b/plugins/fillitup/content/en-GB.plg_fillitup_content.sys.ini @@ -2,7 +2,7 @@ ; * @version 1.x ; * @package Fill It Up ; * @author JoomlaWorks http://www.joomlaworks.net -; * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. +; * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. ; * @license http://www.joomlaworks.net/license ; */ diff --git a/plugins/fillitup/k2/en-GB.plg_fillitup_k2.sys.ini b/plugins/fillitup/k2/en-GB.plg_fillitup_k2.sys.ini index f2b26fa..526d927 100755 --- a/plugins/fillitup/k2/en-GB.plg_fillitup_k2.sys.ini +++ b/plugins/fillitup/k2/en-GB.plg_fillitup_k2.sys.ini @@ -2,7 +2,7 @@ ; * @version 1.x ; * @package Fill It Up ; * @author JoomlaWorks http://www.joomlaworks.net -; * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. +; * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. ; * @license http://www.joomlaworks.net/license ; */ diff --git a/plugins/fillitup/k2/fields/k2images.php b/plugins/fillitup/k2/fields/k2images.php index 9651610..ac77d66 100755 --- a/plugins/fillitup/k2/fields/k2images.php +++ b/plugins/fillitup/k2/fields/k2images.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ diff --git a/plugins/fillitup/k2/k2.php b/plugins/fillitup/k2/k2.php index 58f09c8..418b772 100755 --- a/plugins/fillitup/k2/k2.php +++ b/plugins/fillitup/k2/k2.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ diff --git a/plugins/fillitup/k2/k2.xml b/plugins/fillitup/k2/k2.xml index cb0b58a..e346e00 100755 --- a/plugins/fillitup/k2/k2.xml +++ b/plugins/fillitup/k2/k2.xml @@ -2,11 +2,11 @@ plg_fillitup_k2 JoomlaWorks - March 29th, 2016 - Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + January 29th, 2018 + Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. please-use-the-contact-form@joomlaworks.net www.joomlaworks.net - 1.0.0 + 1.1.0 http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL diff --git a/plugins/fillitup/users/en-GB.plg_fillitup_users.sys.ini b/plugins/fillitup/users/en-GB.plg_fillitup_users.sys.ini index e5b8ae6..8b957de 100755 --- a/plugins/fillitup/users/en-GB.plg_fillitup_users.sys.ini +++ b/plugins/fillitup/users/en-GB.plg_fillitup_users.sys.ini @@ -2,7 +2,7 @@ ; * @version 1.x ; * @package Fill It Up ; * @author JoomlaWorks http://www.joomlaworks.net -; * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. +; * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. ; * @license http://www.joomlaworks.net/license ; */ diff --git a/plugins/fillitup/users/users.php b/plugins/fillitup/users/users.php index a67d756..14ffb59 100755 --- a/plugins/fillitup/users/users.php +++ b/plugins/fillitup/users/users.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */ diff --git a/plugins/fillitup/users/users.xml b/plugins/fillitup/users/users.xml index 6502274..cdb8d3c 100755 --- a/plugins/fillitup/users/users.xml +++ b/plugins/fillitup/users/users.xml @@ -2,11 +2,11 @@ plg_fillitup_users JoomlaWorks - March 29th, 2016 - Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + January 29th, 2018 + Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. please-use-the-contact-form@joomlaworks.net www.joomlaworks.net - 1.0.0 + 1.1.0 http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL diff --git a/script.fillitup.php b/script.fillitup.php index bd61c9c..c9cf8d8 100755 --- a/script.fillitup.php +++ b/script.fillitup.php @@ -3,7 +3,7 @@ * @version 1.x * @package Fill It Up * @author JoomlaWorks http://www.joomlaworks.net - * @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved. + * @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved. * @license http://www.joomlaworks.net/license */