Donations accepted

Hosted on

class.upload.php changelog

v 0.32 15/01/2013

- add support for XMLHttpRequest uploads
- added image_pixelate
- added image_interlace
- added 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
- allowed and 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 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 file_max_size and jpeg_size
- added image_opacity to change picture opacity
- added image_border_opacity to allow semi-transparent borders
- added image_frame_opacity to allow semi-transparent frames
- added image_border_transparent to allow borders fading to transparent
- duplicated image_overlay_percent into image_overlay_opacity
- duplicated image_text_percent into image_text_opacity
- duplicated image_text_background_percent into image_text_background_opacity

v 0.30 05/09/2010

- implemented an unsharp mask, with alpha transparency support, activated if image_unsharp is true. added image_unsharp_amount, image_unsharp_radius, and image_unsharp_threshold
- added text/rtf MIME type, and no_script exception
- corrected bug when 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 image_ratio_fill top and left filling
- fixed alphablending issue when applying a transparent PNG watermark on a transparent PNG
- added image_watermark_no_zoom_in and 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 mime_fileinfo, mime_file, mime_magic and mime_getimagesize from the docs since they are used before 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 file_name_body_pre to prepend a string to the file name
- added mime_fileinfo, mime_file, mime_magic and 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, processed wasn't propagated properly

v 0.27 14/05/2009

- look for the language files directory from __FILE__
- deactivate file_auto_rename if 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 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 forbidden to set an array of forbidden MIME types
- implemented support for simple wildcards in allowed and 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 file_is_image to determine if the file is a supported image type
- the class now provides some information about the image, before calling process(). Available are image_src_x, image_src_y and the newly introduced image_src_bits, image_src_pixels and 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: image_max_width, image_max_height, image_max_pixels, image_max_ratio, image_min_width, image_min_height, image_min_pixels and image_min_ratio
- added image_ratio_pixels to resize an image to a number of pixels, keeping aspect ratio
- added image_is_palette and image_is_transparent and image_transparent_color for GIF images
- added image_default_color to define a fallback color for non alpha-transparent output formats, such as JPEG or BMP
- changed image_background_color, which now forces transparent areas to be painted
- improved reflections and color overlays so that it works with alpha transparent images
- image_reflection_color is now deprecated in favour of 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. preserve_transparency is deprecated
- transparent true color images can be saved as GIF while retaining transparency, semi transparent areas being merged with image_default_color
- transparent true color images can be saved as JPG/BMP with the semi transparent areas being merged with 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 argument, or no argument

v 0.24 25/05/2007

- added 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 image_ratio_fill in order to fit an image within some dimensions and color the remaining space. Very similar to 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 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 image_text_line_spacing which allow to set the space between several lines of text
- added image_text_alignment which allow to set the alignment when text has several lines
- image_text_font can now be set to the path of a GDF font to load external fonts
- added image_reflection_height to create a reflection of the source image, which height is in pixels or percentage
- added image_reflection_space to set the space in pixels between the source image and the reflection
- added image_reflection_color to set the reflection background color
- added image_reflection_opacity to set the initial level of opacity of the reflection

v 0.21 30/09/2006

- added image_ratio_crop which resizes within image_x and image_y, keeping ratio, but filling the space by cropping excedent of image
- added mime_check, which default is true, to set checks against allowed MIME list
- if MIME is empty, the class now triggers an error
- color #000000 is OK for image_text_color, and related text transparency bug fixed
- 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 image_brightness and image_contrast to be between -127 and 127.
- added dir_auto_create to automatically and recursively create destination directory if missing.
- added dir_auto_chmod to automatically chmod the destination directory if not writeable.
- added dir_chmod to set the default chmod to use.
- added image_crop to crop images.
- added image_negative to invert the colors on the image.
- added image_greyscale to turn the image into greyscale.
- added image_threshold to apply a threshold filter on the image.
- added image_bevel, image_bevel_color1 and image_bevel_color2 to add a bevel border.
- added image_border and image_border_color to add a single color border.
- added image_frame and 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).
- file_safe_name has been improved a bit.
- added image_brightness, image_contrast, image_tint_color, image_overlay_color and image_overlay_percent to do color manipulation on the images.
- added image_text and all derivated settings to add a text label on the image.
- added image_watermark and all derivated settings to add a watermark image on the image.
- added image_flip and image_rotate for more image manipulations
- added jpeg_size to calculate the JPG compression quality in order to fit within one filesize.

v 0.18 02/02/2006

- added no_script to turn dangerous scripts into text files.
- added mime_magic_check to set the class to use mime_magic.
- added preserve_transparency
- 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 image_convert.
- il is now possible to simply convert an image, with no resizing.
- sets the default 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 file_auto_rename automatic file renaming if the same filename already exists.
- added 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 image_ratio. Thanks Justin.
- added image_ratio_no_zoom_in and image_ratio_no_zoom_out

v 0.12 21/01/2005

- added 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())