From 622bf0eb90d21de4653f8fe0a12b10d1e1332cf9 Mon Sep 17 00:00:00 2001 From: dleffler Date: Sat, 27 Aug 2016 17:08:31 -0400 Subject: [PATCH] update phpThumb to v1.7.14-201608101311 --- external/phpThumb/docs/phpthumb.changelog.txt | 1500 +++++++++++++++++ external/phpThumb/docs/phpthumb.faq.txt | 372 ++++ .../docs/phpthumb.license.commercial.txt | 27 + external/phpThumb/docs/phpthumb.license.txt | 340 ++++ external/phpThumb/docs/phpthumb.readme.txt | 673 ++++++++ external/phpThumb/phpThumb.config.php | 37 +- external/phpThumb/phpThumb.php | 137 +- external/phpThumb/phpthumb.bmp.php | 56 +- external/phpThumb/phpthumb.class.php | 561 +++--- external/phpThumb/phpthumb.filters.php | 769 +++++---- external/phpThumb/phpthumb.functions.php | 80 +- external/phpThumb/phpthumb.gif.php | 52 +- external/phpThumb/phpthumb.ico.php | 60 +- external/phpThumb/phpthumb.unsharp.php | 43 +- 14 files changed, 3868 insertions(+), 839 deletions(-) create mode 100644 external/phpThumb/docs/phpthumb.changelog.txt create mode 100644 external/phpThumb/docs/phpthumb.faq.txt create mode 100644 external/phpThumb/docs/phpthumb.license.commercial.txt create mode 100644 external/phpThumb/docs/phpthumb.license.txt create mode 100644 external/phpThumb/docs/phpthumb.readme.txt diff --git a/external/phpThumb/docs/phpthumb.changelog.txt b/external/phpThumb/docs/phpthumb.changelog.txt new file mode 100644 index 0000000000..11ec4c5478 --- /dev/null +++ b/external/phpThumb/docs/phpthumb.changelog.txt @@ -0,0 +1,1500 @@ +////////////////////////////////////////////////////////////////// +// phpThumb() by James Heinrich // +// available at http://phpthumb.sourceforge.net // +// and/or https://github.com/JamesHeinrich/phpThumb // +////////////////////////////////////////////////////////////////// + +¤ = structure change or important new feature +* = less important new feature or change + +v1.7.14 - + * Bugfix (G:25): escapeshellarg may exist but be disabled + +v1.7.13-201406261000 - June 26, 2014 + * Bugfix: incorrect variable name in phpThumb.php could prevent + all hash values from matching + + +v1.7.12-201406260900 - June 26, 2014 + ¤ high_security_mode enabled by default and strongly recommended + ¤ debug mode must be disabled to allow thumbnail generation + Thanks to Rafay Baloch (www.rafayhackingarticles.net) for + recommending some security configuration changes + * default config_cache_directory_depth is now 2 (was 4) + * Bugfix: temp files used with ImageMagick might not get deleted + from cache directory + * Bugfix (G:17): 'far' parameter not working as intended + * Bugfix (G:16): $PHPTHUMB_DEFAULTS configuration ignored + * Bugfix (G:15): $PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE logic wrong + * Bugfix (G:11): config_cache_maxsize does not count wasted space + * Bugfix (G:10): error images ignored relevant config options + * Bugfix (#962): support symlinked subfolders for image source + * Bugfix (#934): source image region (sx/sy/sw/sh) did not work + when using ImageMagick + * Bugfix (#925): add configurable URL separator + * Bugfix (#921): non-static phpUnsharpMask::applyUnsharpMask() + * Bugfix (#920): $PHPTHUMB_DEFAULTS with array value gives + array-to-string PHP error + * Bugfix (#909): unnecessary calls of shell commands when cached + * Bugfix (#618): cached files inside subdirs won't be deleted + * Bugfix (#594): ImageMagick variants not detected (e.g. OpenMP) + + +v1.7.11-201108081344 - August 8, 2011 + ¤ Added even more explicit escaping of command line parameters + ¤ $PHPTHUMB_CONFIG['high_security_password'] needs to be more + complex than before. Previously 5 characters length was + required, now password strength calculated based on character + type (a-z, A-Z, 0-9, other) and count. + See PasswordStrength() function in phpThumb.php + ¤ deliberate delay inserted on failed hash in high_security mode + to slow down brute force attempts + ¤ 'file' paramter removed (use object mode instead) + ¤ 'goto' paramter removed (use object mode instead) + ¤ Disable all demos by default, user will need to comment out a + line to run the demo + ¤ CleanUpCacheDirectory() is now only called once per hour, and + skipped entirely if cache directory is not writable + * Bugfix: crop broken if width or height set to 1.00 + * Bugfix: gamma filter for ImageMagick was broken + * Bugfix: newer versions of ImageMagick have changed "-gaussian" + filter to "-gaussian-blur" + * Bugfix: newer versions of ImageMagick have changed date format + from DD/MM/YY to YYYY-MM-DD + * Bugfix: image not found errors when using virtual subdirectories + * Bugfix: assorted errors in phpThumb.demo.check.php + * Bugfix (#265): source images other than JPEG/PNG/GIF would not + generate thumbnails for remote (http) images but work locally + * Bugfix (#253): ImageMagick not found if outside open_basedir + * Bugfix (#243): port ignored in URLreadFsock() + * Bugfix (#240): Any temporary file created through + phpThumb_tempnam() is automatically deleted at the end of the + script via phpThumb object destructor (PHP5 only) + * Bugfix (#216): uninitialized string offset + * Bugfix (#209): don't try ImageMagick first if + config_prefer_imagemagick == false + * Bugfix (#127): CleanUpURLencoding() ignored port number + * Bugfix (#38): CleanUpCacheDirectory() ignored config_cache_prefix + * Bugfix (#31): ExtractEXIFgetImageSize() may throw errors on non- + JPEG/TIFF images when calling exif_read_data() + + +v1.7.10 - April 24, 2011 + * ImageMagickVersion() returned unknown-version for versions + with hyphenated subversion numbers + (thanks r34wangØuwaterloo*ca) + * replace all ereg* functions with preg* equivalents for + PHP v5.3.0+ compatability + * Bugfix: security vulnerabilities when used with ImageMagick + + +v1.7.9 - May 28, 2008 + * "ra" (rotation) now handled by ImageMagick directly. + Note: If output to transparent-supporting format (PNG,GIF) + them ImageMagick support only enabled for v6.3.7 and above + when rotating to nonmultiples of 90° (e.g. rotate by 30°). + Transparent area behind rotate image buggy in v6.2.9 and + working fine in v6.3.7 (exact version where fixed is + unknown, reports welcome) + * Debug now shows server software version + * Debug now checks for GetImageSize() availability + * Better error message when neither ImageMagick nor GD are + installed on server (thanks kevinmØbuenacg*com) + * Bugfix: uncaught image-too-large exception when using + HTTP source image and ImageMagick is unavailable or fails + (thanks jslaggerØjsamdirect*com) + * Bugfix: phpThumb could sometimes die without showing an + error message when using an HTTP/data image source that is + too large for GD processing with PHP memory limit + (thanks jslaggerØjsamdirect*com) + * Bugfix: prevent error images from clobbering debug output + * Bugfix: temp file for ImageMagick processing not created + correctly when source image is HTTP or from non-file data + (thanks jonahØschwartzdev*com, tsolanØgmail*com) + * Bugfix: Filters are only removed from the processing queue + if ImageMagick supports them AND returns successfully + (thanks tsolanØgmail*com) + * Bugfix: ImageCreateFromStringReplacement() doesn't need to + fail in safe_mode if can still write temp file somewhere + (thanks avatar1983Øgmail*com) + * Bugfix: ImageMagickThumbnailToGD() doesn't need to + fail in safe_mode if can still write temp file somewhere + (thanks avatar1983Øgmail*com) + * Bugfix: better error messages when safe_mode enabled and + using MySQL database for image source + (thanks avatar1983Øgmail*com) + * Bugfix: "wmt" alignment broken for built-in fonts + (thanks mailØmmjaeger*com) + * Bugfix: CleanUpCacheDirectory() has some undefined + variables that might have been the cause of the images- + don't-show-on-first-page-load bug + (thanks hgØdynweb*net) + * Bugfix: phpThumb.php would not correctly skip unneeded + processing if source image was smaller than target size + (thanks adam*kingØcarnegiecycling*com*au) + * Bugfix: phpThumb.demo.check.php incorrectly calculated + age of ImageMagick version (for versions < 180 days old) + + +v1.7.8 - September 16, 2007 + ¤ Added 'stc' (Source Transparent Color) filter + (Feature Request #1672440) + ¤ 'zc' now supports directed crop (top/bottom/left/right) + (thanks leeøvirtualinkdesign*com, chrisøsostreassoc*com) + ¤ new class function resetObject() should be used to reset + default class paramters to default to allow reusing a + single object on multiple images + (see phpThumb.demo.object.php) + (thanks bjohnsonØaccomplishhosting*com) + ¤ "wmt" and "wmi" filters now support absolute positioning + using alignment values: {xoffset}x{yoffset} (eg: "10x20") + (Feature Request #1567113) + (thanks mailØpedrocandeias*com; + squidlibertyØusers*sourceforge*net) + ¤ "wmi" filter now supports watermark scaling & rotation + (Feature Request #1788063) + (thanks glen*fiebichØ2020promo*com) + ¤ Added "size" filter. NOTE: try not to use this filter, + it is inefficient and for special purposes only, please + see phpthumb.readme.txt entry before using. + (thanks glen*fiebichØ2020promo*com) + * Added wildcard domain options for config settings + nooffsitelink_valid_domains and nohotlink_valid_domains + (thanks meØjohannes*jarolim*com) + * Output image format defaults to input format (based on + filename) (thanks bjohnsonØaccomplishhosting*com) + * Sepia filter now uses ImageFilter under PHP5 + (thanks richard*comleyØmademedia*co*uk) + * "f" parameters now accepts formats with leading "." + (eg "&f=.png") to allow you to fool things that look at + the last characters of the URL to determine image type + (thanks alexØalexderas*nl) + * Added section to phpthumb.demo.check.php to test cache + file creation and deletion + * Bugfix [#1715256]: ImageMagick output not always used + if fltr set incorrectly + (thanks danakiØusers*sourceforge*net) + * Bugfix [#1541673]: ResolveFilenameToAbsolute() fails in + RenderToFile() if target file does not exist + (thanks jasonpellØusers*sourceforge*net) + * Bugfix [#1703373]: CleanUpURLencoding() broken if path + element equals "0" + (thanks izeronØusers*sourceforge*net) + * Bugfix [#1573399]: phpthumb_filters::Colorize() broken + under PHP5 (thanks cerwØusers*sourceforge*net) + * Bugfix [#1573399]: ImageMagick version of colorize filter + missing quotes (thanks cerwØusers*sourceforge*net) + * Bugfix [#1733462]: SafeExec broken + (thanks hansfnØusers*sourceforge*net) + * Bugfix [#1751821]: open_basedir restriction gives warning + when trying to initialize config_temp_dir + (thanks k-mystikØusers*sourceforge*net) + * Bugfix: [#1751880]: open_basedirs not initialized properly + under Windows (thanks k-mystikØusers*sourceforge*net) + * Bugfix: "A non well formed numeric value encountered" error + when using "cont" filter in PHP5 + (thanks isnbitØyahoo*com) + * Bugfix: Colorize filter ignored $amount under PHP5 + (thanks richard*comleyØmademedia*co*uk) + * Bugfix: double-drawn color in corders of Bevel filter + (thanks m*westmijzeØstudent*utwente*nl) + * Bugfix: 'nocache' parameter was forbidden + (thanks andreasØkringelstan*se) + * Bugfix: disabled functions (set_time_limit, shell_exec, etc) + not always correctly detected + (thanks ryandemmerØgmail*com, dr*creatorØgmail*com) + * Bugfix: phpThumbURL() was broken if __FILE__ and + $PHPTHUMB_CONFIG['document_root'] had different slash + styles (\ vs /) (thanks jobbetØskarin*com) + * Bugfix: 'wmt' watermark text not properly right- or center- + aligned with TTF fonts + * Bugfix: force stderr output to stdout in SafeExec + * Bugfix: filter-generated debug messages not passed back + * Bugfix: /demo/phpThumb.demo.gallery.php was not getting + correct DOCUMENT_ROOT value on some servers + (thanks latex*dragonØgmail*com) + * Bugfix: HTTP source images with no parameters were not + being passed through directly (thanks chrisØmegawap*net) + * Bugfix: "unknown image type" errors on non-GD-supported + remote image sources (thanks chrisØgorillachicago*com) + * Bugfix: remote images not found if server returned 302 + message with text other than "Found" + (thanks cveleØdefault*co*yu, kevinØkevinevans*net) + * Bugfix: resetObject() was clobbering debug messages + (thanks kevinØkevinevans*net) + * Bugfix: CleanUpURLencoding() was broken + (thanks kevinØkevinevans*net) + * Bugfix: Cache auto-purging was generally broken, especially + if the cache contained a directory or filename of "0" + (thanks hannoØxcalak*info; webdesignØweisshart*de) + + + +v1.7.7 - December 25, 2006 + ¤ Added phpThumb.demo.gallery.php -- basic image gallery demo + ¤ Added option for image watermark for anti-hotlinking. See + phpThumb.config.php "nooffsitelink_watermark_src" + (thanks rik_helsenØrad*be) + ¤ Added config option "imagemagick_use_thumbnail" to control + use of ImageMagick's "-thumbnail" command vs "-resize" (the + former discards non-visible metadata, the latter retains it) + Most times you want the smallest filesize so keep the default + setting (imagemagick_use_thumbnail==true) + (thanks niklasØmysticalgarden*se) + * Bugfix [#1620056]: EnsureDirectoryExists() failed to create + some directory structures (thanks jeromyØlocallinux*com) + * Bugfix [#1620056]: CleanUpCacheDirectory() would not purge + files from subdirectories if (cache_directory_depth > 0) + (thanks kingsquareØusers*sourceforge*net) + * Bugfix: nooffsitelink_* broken when running on non-standard + HTTP port (thanks marianbucur17Øyahoo*com) + + +v1.7.6 - December 09, 2006 + ¤ Added "sia" (Save Image As) parameter to provide default + filename when saving generated thumbnails + (thanks web_mkØhotmail*com) + ¤ Changed "lvl" filter parameters, and added option to choose + between four different methods (two internal, two from + ImageMagick). Added configurable threshold parameter. + (thanks publicØwoktiny*com for code for new internal method) + ¤ "wb" (White Balance) filter now processed by ImageMagick + * Changed GD max source pixels to 1/6 (from 1/5) available + memory, and changed SourceImageIsTooLarge() to account for + already-used memory (if known) + * More graceful error handling in object mode when source + larger than PHP memory limit and ImageMagick unavailable + (thanks djasonØdjason*com) + * Added ImageMagickFormatsList() + * CleanUpCacheDirectory() now also purges zero-byte orphan + files left over from aborted thumbnailings + * Bugfix [#1606069]: Changed default urlencoded space + character from "+" to "%20" + * Bugfix [#1608664]: "Unsupported operand types" in "wmi" + filter (thanks haydurØhaydur*com; squidliberty) + * Bugfix: debug mode now supports text output in all modes + * Bugfix: ImageMagick creation attempted before GD creation + * Bugfix: no longer fails silently if GD creation runs out of + memory + * Bugfix: poor alpha rendering from PNG to GIF with ImageMagick + * Bugfix: "wb" filter had no effect when "lvl" filter applied + in ImageMagick instead of GD + + +v1.7.5 - October 03, 2006 + ¤ Deprecated parameters "err", "file", "goto" + ¤ Added broad cache directory feature (see phpThumb.config.php + "cache_directory_depth") to spread cache files across many + directories for improved performance and ability to store + very large numbers (30000+) of cached files + (thanks despoixØopenxtrem*com) + ¤ phpThumb now follows HTTP redirects (status=302) to new + HTTP image URLs (configurable: config_http_follow_redirect) + (thanks shannahØsfu*ca) + ¤ Added "rot" (ROTate) filter which is similar to "ra" parameter + but now allows rotation of output of other filters (for + example, rotate image after fltr[]=mask is applied) + (thanks markØwoodjoint*ca) + ¤ Added WBMP output support (built-in GD or via ImageMagick) + (code was already mostly present, just was not allowed format) + ¤ [#1567113] "wmi" filter now accepts both x and y margins + and can be in pixels or percent of thumbnail dimensions + (thanks squidlibertyØusers*sourceforge*net) + * "hist" filter now accepts both X and Y margins + * Added config variables: config_http_fopen_timeout = 10; + config_http_follow_redirect = true + * Changed MIME type for WBMP to image/vnd.wap.wbmp + * Bugfix: Check for GD format support before attempting output + * Bugfix: Opening HTTP source images with URL query parameters + was broken (eg: http://host/show?id=123) + (thanks ivo*beckersØinfopractica*nl) + + +v1.7.4 - August 17, 2006 + ¤ Improved version of /demo/phpThumb.demo.showpic.php uses + phpThumb.php so any filters can be applied, as well as + resized image popups. + New file: /demo/javascript_api.js + Uses Javascript API by James Austin + (http://aspandjavascript.co.uk/javascript/javascript_api/) + ¤ Added "sfn" (Source Frame Number) parameter to specify + source frame in multi-frame/multi-page source formats, such + as GIF, TIFF, PDF, etc (thanks despoixØopenxtrem*com) + ¤ Added "dpi" (Dots Per Inch) parameter to specify + rasterising resolution for vector source formats (PDF, WMF) + (requires ImageMagick) (thanks despoixØopenxtrem*com) + * Added /demo/phpThumb.demo.object.simple.php + * Added debug points inside GenerateThumbnail + * Explicit error message for unsupported PDF source images + * Bugfix: SafeURLread broken with GETstring parameters in + fsockopen mode + * Bugfix: [#1540523] CleanUpCacheDirectory() does not delete + files as expected (thanks patricksleeØusers*sourceforge*net) + * Bugfix: added useful error message when no source specified + in object mode (thanks infoØdoepud*co*uk) + * Bugfix: timeout value ignored in URLreadFsock() + * Bugfix: timeout missing in SafeURLread CURL part + * Bugfix: ImageMagick now checked with --version (not -version) + * Bugfix: better ImageMagick (numeric) version number matching + * Bugfix: noGD errors showing up when GD imagecreate functions + fail and ImageMagick not available + (thanks caseyyØgmail*com) + * Bugfix: "-thumbnail" parameter not present in older versions + of ImageMagick, now using -resize if -thumbnail unavailable + (thanks atombomb96Øbtopenworld*com) + * Bugfix: "-resize" parameter requires explicit dimensions + ("100x100" instead of "100x") in older ImageMagick versions + (thanks atombomb96Øbtopenworld*com) + * Bugfix: phpThumb crashed with no output if ImageMagick failed + to resize but output image larger than max_source_pixels + (thanks atombomb96Øbtopenworld*com) + * Bugfix: phpThumb might die with no output on some large source + images when ImageMagick unavailable. + (thanks atombomb96Øbtopenworld*com) + + +v1.7.3 - July 11, 2006 + * Now returns useful message for HTTP sources if 404-file- + not-found (or similar) errors occur + * Added new fsockopen() section in SafeURLread() + * Removed PNG alpha warning for IE 7 (alpha PNGs now work) + * Bugfix: ImageMagick failing version check and dumping text + output (thanks infoØdevsystem*net) + * Bugfix: curl_exec failing with text output + (thanks infoØdevsystem*net) + * Bugfix: workaround for PHP Bug #36102 (fopen(http) crash + in PHP v4.4.2 + * Bugfix: "Unknown image type identified by..." problem when + opening http:// source images + (thanks webmasterØdanceage*com) + + +v1.7.2 - June 22, 2006 + ¤ [#1256693] Added $this->exif_raw_data which is returned + data from exif_read_data() on source image. + Requires PHP v4.2.0+ (thanks tebiØusers*sourceforge*net) + ¤ Added $this->outputImageData and RenderOutput() to allow + easy outputting of thumbnail data to a database or such. + Call RenderOutput() instead of RenderToFile() and then + access raw data in $this->outputImageData + (thanks r*cremerØswitch*nl) + ¤ Added 'crop' filter, which is applied after resizing (as + opposed to sx,sy,sw,sh which are before resizing) + (thanks scottØscottjehl*com) + * Enable creating new images with PATH_INFO style call + (thanks edenØinstyleit*com*au) + * Added warning message to encourage users not to use + full HTTP paths for "src" parameter + * Added fallback 'preg_quote' to phpthumb.functions.php in + case your PHP installation does not have preg_* functions + (thanks mortenØemeskay*dk) + * Added fallback 'imagesavealpha' if GD < v2.0.1 + (thanks oliver*heegerØweb*de) + * Added fallback 'imagealphablending' if GD < v2.0.1 + (thanks oliver*heegerØweb*de) + * Added 'nocache' parameter that suppresses writing to cache + file, but only if high_security_enabled is set + (thanks federicoØdonelleschi*com) + * Attempt to detect supported ImageMagick features + (thanks simonØjapancentre*com) + * Added temp dir detection to phpThumb.demo.check.php + * Added ImageMagick dir to phpThumb.demo.check.php + * Added ImageMagick features to phpThumb.demo.check.php + * Default (config_allow_src_above_docroot = true) when PHP + running in "cli" mode (thanks flobeeØgmail*com) + * Bugfix: [#1470791] 'iar' not working properly with + ImageMagick (thanks w1xØusers*sourceforge*net) + * Bugfix: [#1498564] illegal characters in cache filenames + (thanks carl-evertØusers*sourceforge*net) + * Bugfix: 'sx','sy','sw','sh','zc' cache parameters broken + (thanks federicoØdonelleschi*com) + * Bugfix: 'config_max_source_pixels' incorrectly handled + (thanks oliver*heegerØweb*de) + * Bugfix: 'aoe' not working properly + (thanks w1xØusers*sourceforge*net) + * Bugfix: setParameter() was broken for arrays + * Bugfix: setSourceFilename() wasn't setting 'src' + * Bugfix: suppress stat()-related file permission + notices (thanks lanceØmainecoastdesign*com) + * Bugfix: image format now initialized during ErrorImage() + * Bugfix: domain matching now case-insensitive + * Bugfix: some versions of ImageMagick not detected + (thanks arvidØfys*ku*dk) + * Bugfix: sometimes no image returned in safe_mode + (thanks bkainersØgmail*com) + * Bugfix: 'far' not always handled correctly + (thanks matthew*newtonØrealworldweb*com) + * Bugfix: PATH_INFO method not working if no filters specified + (thanks jjimenezØpracticaldata*com) + * Bugfix: first (internal) call to ImageMagickVersion() failed + under Windows + * Bugfix: Images source-cropped AND resized with ImageMagick were + wrong size (cropped size, not resized size) + (thanks joao*saleiroØwebfuel*pt) + * Bugfix: stat() warnings in CleanUpCacheDirectory() + (thanks christianØhss-haage*de) + * Bugfix: $PHPTHUMB_DEFAULTS not working when no other processing + parameters specified (thanks tbittnersØcox*net) + + +v1.7.1 - March 16, 2006 + * /demo/phpThumb.demo.check.php now checks: + - server software + - local and master config values (with ini_get and + get_cfg_var respectively) (thanks nEUTRonØgmx*tm) + - existance of assorted PHP functions and explains their + importance + * Bugfix: config_error_die_on_error now defaults to FALSE to + prevent object-mode errors dying in an error image + (thanks moshØtobt*de; riteshgupta1974Øgmail*com) + * Bugfix: setParameter() now handles array parameters (such + as 'fltr') by appending $value to $parameter + * Bugfix: /demo/phpThumb.demo.check.php incorrect CURL value + under PHP5 (thanks nEUTRonØgmx*tm) + * Bugfix: [#1439110] Limit fread() calls to 8kB + (see http://bugs.php.net/bug.php?id=35859) + (thanks andig2Øusers*sourceforge*net) + * Bugfix: Prevent RenderToFilename() from trying to render + to URLs (thanks Tim*MasseyØitrm*co*uk) + * Bugfix: [#1438657] missing path in phpThumbURL() + (thanks terracesØusers*sourceforge*net) + * Bugfix: zoomcrop was broken for non-square output + (thanks alisonØsemidivine*com, federicoØdonelleschi*com) + * Bugfix: suppress error messages when stat access to temp + dir is disabled (thanks rfineØvnuinc*com) + * Bugfix: ImageMagick processing was broken for source + images of types not supported by GetImageSize + (thanks rfineØvnuinc*com) + +v1.7.0 - February 15, 2006 + ¤ ImageMagick output is used directly far more frequently + for much improved speed and minor quality improvement. + ¤ ImageMagick now processes most of the image filters if + possible (will fall back to GD methods if unavailable) + ¤ GD support is now optional if ImageMagick is installed. + Known limitations include: + - no support for HTTP source images + - ICO output is buggy (in some ImageMagick versions) + - most &fltr[] filters don't work at all + - 'ar', 'ra', 'far' don't work + ¤ Added output support for ICO (icon) format (&f=ico). + Currently only supports single-image icons, but multi- + resolution support may be added in future versions + New file: phpthumb.ico.php + ¤ Added output support for BMP (bitmap) format (&f=bmp). + Currently only supports 24-bit RGB format (for simplicity) + ¤ Added new configuration & compatability checker + New file: demo/phpThumb.demo.check.php + * ImageMagick-generated thumbnails now have extra hidden + contents (EXIF data, etc) stripped (by using -thumbnail + instead of -resize) resulting in smaller filesizes + * Added background fill color, opacity and extent options to + 'wmt' filter (thanks craigØpc-fanatics*com) + * Added metacharacter (^*) support for 'wmt', currently: + source filesize in bytes (^Fb), kB (^Fk), MB (^Fm), + source image width (^X), source image height (^Y), + thumbnail width (^x), thumbnail height (^y) and caret (^^) + (Feature Request #1357815) + (thanks ticklemeozmoØusers*sourceforge*net) + * Moved ImageDestroy call from OutputThumbnail to end of + phpThumb.php to allow multiple calls to OutputThumbnail + * Added config_http_user_agent for site with browsersniffers + (thanks redrobØgmail*com) + * Added $PHPTHUMB_CONFIG['disable_pathinfo_parsing'] (default + false) which disables parsing $_SERVER[PATH_INFO] for + parameters. If you want to parse PATH_INFO, set to false + * Added $PHPTHUMB_CONFIG['disable_imagecopyresampled'] (default + false) which replaces ImageCopyResampled with + ImageCopyResampleBicubic for buggy PHP-GD versions + (thanks g*pelagattiØnetface*it) + * Added $PHPTHUMB_CONFIG['cache_prefix'] to allow sharing of + cache files across virtual servers (Feature Request #1395332) + (thanks doggyfrØusers*sourceforge*net) + * Added $PHPTHUMB_CONFIG['disable_onlycreateable_passthru'] with + default=true (increased speed) to allow direct passthru of + images that don't have GD support. (Feature Request #1396446) + (thanks zedboyØusers*sourceforge*net) + * Removed $PHPTHUMB_CONFIG['cache_differentiate_offsite'] because + it is now automatically tied in with nooffsitelink_enabled + (thanks doggysworldØlibertysurf*fr) + * Removed phpThumb.demo.cacheconvert2.php + * Debug messages are now passed back from filters + * $PHPTHUMB_CONFIG['cache_source_filemtime_ignore_remote'] now + defaults to true for much-improved cached performance + (thanks redrobØgmail*com) + * $PHPTHUMB_CONFIG['cache_differentiate_offsite'] now defaults + to false + * Added $PHPTHUMB_DEFAULTS['ar']='x' to phpThumb.config.php.default + * Added ImageDestroy($this->gdimg_source) to GenerateThumbnail() + to save memory before applying image filters + * gd_info() no longer member of phpthumb_functions + * cache files now default to using SERVER_NAME without 'www.' + * phpUnsharpMask::applyUnsharpMask() should be faster under PHP5 by + using ImageFilter(IMG_FILTER_GAUSSIAN_BLUR) when radius==1 + * Added alternate CURL method for HTTP source images if + allow_url_fopen is disabled (thanks webweberØmotiondraw*com) + * Replaced $this->osslash with DIRECTORY_SEPARATOR constant + * Bugfix: [#1398327] 'new' got broken (1x1 images) + * Bugfix: [#1412552] HTTP source images with special characters were + not getting urlencoded + * Bugfix: ImageSaveAlpha errors on GD v2.0.0 + * Bugfix: phpThumbDebug now entirely disabled if high_security=true + * Bugfix: source images with transparency lost transparency when + rotated (thanks roalklØyahoo*com) + * Bugfix: square source images were not resized when only (w|h)(p|l) + parameters passed + * Bugfix: source images are passed through unmodified in more cases + * Bugfix: ImageMagick not used on systems where it exists outside + defined open_basedir + * Bugfix: ImageMagickVersion() now returns correct versionstring + * Bugfix: ImageMagick warnings no longer cause ImageMagick to fail + * Bugfix: ErrorImage no longer fatal to phpThumbDebug + * Bugfix: "Array to string conversion" in foreach($a as $v) loops + (thanks zeeshanØtargetedmedia*co*uk) + * Bugfix: safe mode warnings in ImageCreateFromStringReplacement + (thanks adminØalex-home*net) + * Bugfix: nooffsitelink broken if !nooffsitelink_require_refer + (thanks depronØgmx*net) + * Bugfix: phpThumb failed when magic_quotes_runtime=true + (thanks stansawyerØyahoo*com) + * Bugfix: several issues with HTTP image sources + (thanks redrobØgmail*com) + * Bugfix: phpThumb_tempnam() would return incomplete temp filenames + under Windows, which may result in orphaned zero-byte temp files + in C:\ if multiple drives exist + +v1.6.2 - November 24, 2005 + ¤ Animated GIF output is now possible if ImageMagick is + available and no filters (other than resize) are applied + (thanks brandenbassØgmail*com for idea) + * Added $PHPTHUMB_CONFIG['cache_force_passthru'] to work + around cached-image-only-works-second-time issue + (thanks yakoØ11y11*com) + * Bugfix: black borders on some image edges + (thanks atelierØdelirius*ch && chuckØcatalyststudio*com) + * Bugfix: uncaught PHP warning in RenderToFile DebugMessage + * Bugfix: allow phpThumbDebug in noGD PHP installations + * Bugfix: 'hash' warning in high_security mode + (thanks bernhardØwtf*at) + * Bugfix: non-TTF rotated text watermarks now work (unrotated) + with no warnings if ImageRotate is unavailable + (thanks aparviaiØusers*sourceforge*net) + +v1.6.1 - August 26, 2005 + ¤ Filters now use GD functions where available (using + ImageFilter, only available in PHP v5.0.0+ with bundled + version of GD). Enabled for: colorize, negative, + grayscale, brightness, contrast, gaussian blur, selective + blur, mean removal (thanks donlaurØmac*com) + ¤ Added config_prefer_imagemagick (defaults=true) + ¤ Added phpthumb_filters::Grayscale() 'gray' + ¤ Added phpthumb_filters::ReduceColorDepth() 'rcd' + ¤ Added phpthumb_filters::Brightness() 'brit' + ¤ Added phpthumb_filters::Contrast() 'cont' + ¤ Added phpthumb_filters::Saturation() 'sat' + ¤ Added phpthumb_filters::EdgeDetect() 'edge' [PHP5 only] + ¤ Added phpthumb_filters::BlurGaussian() 'gblr' [PHP5 only] + ¤ Added phpthumb_filters::BlurSelective() 'gblr' [PHP5 only] + ¤ Added phpthumb_filters::MeanRemoval() 'mean' [PHP5 only] + ¤ Added phpthumb_filters::Smooth() 'smth' [PHP5 only] + * New timing debug info in phpThumbDebug + * Added config_cache_differentiate_offsite + * config_die_on_error now defaults to false + * ResolveSource works better + * cache filenames with 'fltr' parameters have changed + * Filters now skip processing if amount=0 or similar + * [#1263051] 'far' now accepts L,R,T,B,C as values giving + alignment of left/right/top/bottom/center respectively. + Old value of '1' defaults to centered + (thanks webgrappaØusers*sourceforge*net) + * Bugfix: RenderToFile() now fails properly when output format + is unknown + * Bugfix: PNG transparency wasn't working with 'far' + * Bugfix: source images with EXIF thumbnails that differ in + aspect ratio no longer use EXIF thumbnails as source unless + no other options exist + * Bugfix: setting 'src' with setParameter now invokes + setSourceFilename to properly set $this->sourceFilename + (thanks Gazou) + * Bugfix: 'zc' had poor quality when used with ImageMagick + * Bugfix: 'aoe' parameter broken when not using ImageMagick + (thanks frankieali4Øhotmail*com) + * Bugfix: fixed issue with symbolic links + (thanks hornet136Øgmail*com) + * Bugfix: config_max_source_pixels now defaults to same + calculation as used in phpThumb.config.php + (thanks vukshaØhotmail*com) + * Bugfix: Offsite cached thumbnails no longer use unique + referer (now either nothing or "_offsite") + (thanks swaayeØyahoo*com) + * Bugfix: "Unknown image type identified by “] + where is the target hex color to white balance + on, this color is what "should be" white, or light + gray. The filter attempts to maintain brightness so + any gray color can theoretically be used. If is + omitted the filter guesses based on brightest pixels + in each of RGB + ¤ Cached files are used by a Location header instead of + being passed through phpThumb.php using readfile + (thanks newtnØthrillnerds*com) + * Added 'cache_source_filemtime_ignore_local' and + 'cache_source_filemtime_ignore_remote' configurations + to ignore source modification and/or removal + (thanks raynerapeØgmail*com) + * Added 'md5s' parameter, which is the MD5 hash of the + source image -- if this parameter is passed with the + hash of the source image then the source image is not + checked for existance or modification and the cached + file is used (if available). If 'md5s' is passed an + empty string then phpThumb.php dies and outputs the + correct MD5 hash value. This parameter is the single- + file equivalent of 'cache_source_filemtime_ignore_*' + configuration paramters (thanks raynerapeØgmail*com) + * Added /demo/phpThumb.demo.object.php + * Unused parameter 'bgt' removed + * Added empty /cache/source/ directory to distribution + * Added /demo/ and /docs/ and /fonts/ directories + * Set default config_use_exif_thumbnail_for_speed = false + * Bugfix: Wrapped output buffering around all + include_once calls to prevent headers getting sent + accidentally + * Bugfix: md5_file and imagecolorallocatealpha calls + were undefined under PHP v4.1.x (thanks tomØemile*com) + * Bugfix: default 'f' parameter ('jpeg') overrode + config_output_format in object mode + (thanks mailØmmjaeger*com) + * Bugfix: suppressed error message for IIS shell_exec + errors (thanks tomØemile*com) + * Bugfix: Added PHP version check for stream_set_timeout + for HTTP sources (thanks raynerapeØgmail*com) + * Bugfix: overlay margins of 0.5-1.0 cause invalid image + dimensions error (thanks mailØmmjaeger*com) + * Bugfix: underlay margins were not working + (thanks mailØmmjaeger*com) + * Bugfix: [#1187735] EXIF thumbnails were incorrectly + output to the browser directly if requested thumbnail + exactly matched EXIF dimensions + (thanks rebootØusers*sourceforge*net) + +v1.5.2 - April 20, 2005 + ¤ phpThumb.config.php is renamed to + phpThumb.config.php.default to prevent accidental + overwriting. Please migrate your old settings to the new + file, delete your old config and rename the default to + phpThumb.config.php + ¤ Added new filters: + - 'blur' (Blur) [ex: &fltr[]=blur|] + where (0 < < 25) (default = 1) + (thanks thoensiØnetcom*no for code) + - 'hist' (Histogram) + [ex: &fltr[]=hist|||||||] + Where is the color band(s) to display, from back + to front (one or more of "rgba*" for Red Green Blue + Alpha and Grayscale respectively); + is a semicolon-seperated list of hex colors to + use for each graph band (defaults to FF0000, 00FF00, + 0000FF, 999999, FFFFFF respectively); + and are the width and height of the overlaid + histogram in pixels, or if <= 1 then percentage of + source image width/height; + is the alignment (same as for "wmi" and "wmt"); + is opacity from 0 to 100; + is the edge (and inter-tile) margin in percent + - 'over' (OVERlay/underlay image) overlays an image on + the thumbnail, or overlays the thumbnail on another + image (to create a picture frame for example) + [ex: &fltr[]=over||||] + where is the image filename; is "0" (default) + for overlay the image on top of the thumbnail or "1" + for overlay the thumbnail on top of the image; is + the margin - can be absolute pixels, or if < 1 is a + percentage of the thumbnail size [must be < 0.5] + (default is 0 for overlay and 10% for underlay); + is opacity (0 = transparent, 100 = opaque) + (thanks raynerapeØgmail*com, shabazz3Ømsu*edu) + - 'gray' (GRAYscale) [ex: &fltr[]=gray] + is an alias to 100% desaturation + * New configuration 'cache_source_directory' allows the + unprocessed source image to be cached when source is + HTTP or from a database (thanks raynerapeØgmail*com) + * Added 'cache' subdirectory to phpThumb distribution + since this is the default location for the cache + folder. + * Default value for config_error_die_on_source_failure + changed to true (thanks shabazz3Ømsu*edu) + * Added checks to make sure $this->gdimg_output is a + resource before allowing calls to RenderToFile or + OutputThumbnail + * Better error messages when phpThumb.config.php missing + * Bugfix: watermark overlay margins were wrong + * Bugfix: 'lvl' filter no longer processes if not needed + * Bugfix: off-server thumbnail error message was wrong + * Bugfix: several PHP safe mode fixes + (thanks virginiaØalertbutnotalarmed*com) + * Bugfix: cache filenames broken for filter parameters + with paths (thanks srcericØusers.sourceforge.net) + +v1.5.1 - April 06, 2005 + * Added some security upgrades: + - 'config_*' parameters cannot be passed by GETstring + - 'config_nooffsitelink_require_refer' is a new option + (disabled by default) that only allows calls to + phpThumb() from a refering domain listed in + 'config_nooffsitelink_valid_domains' + - disallowed paramters now generate an error image if + present in the GETstring + - 'high_security_enabled' if set to true enabled new + mode of verification, and requires a small function + to generate a hash for calls to phpThumb: + echo ''; + This function is supplied at the bottom of + phpThumb.config.php (thanks paulØstonie*co*uk) + ¤ Added new parameter "new" (phpThumb.php only) which can + create a new image without using "src" parameter. Set + "&new=|" where is the background hex color, + is (optional) opacity (0=transparent, 100=opaque). + (thanks mailØmmjaeger*com) + ¤ Added new filters: + - 'sep' (Sepia) [ex: &fltr[]=sep||] + where is a number between 0 and 100 for the + amount of colorization (default=50), and is + the hex color to colorize to (default=A28065). + (thanks mailØmmjaeger*com) + - 'lvl' (Levels) [ex: &fltr[]=lvl||| + where can be one of 'r', 'g', 'b', 'a' (for + Red, Green, Blue, Alpha respectively), or '*' for all + channels based on average grayscale value (default). + and are the clip points for the levels + (range = 0-255) and are set to clip 0.1% of each end + by default. Use -1 for min and/or max to invoke auto- + detect mode. Using default parameters (&fltr[]=lvl) + is similar to Auto Contrast in Adobe Photoshop. + * Bugfix: Image MIME header was incorrect for cached + images. + * Bugfix: Cache was broken for images pulled from a + database in phpThumb.php + (thanks dragutin*cvetkovicØdragontech-ltd*com) + * Bugfix: Hotlink/Offsite prevention was broken when + image was already cached. + * Bugfix: ImageMagick path was incorrect in some cases + (thanks joshgØtwcny*rr*com) + * Bugfix: ProportionalResize() in phpthumb.functions.php + had a broken check for default values + (thanks Bert*ClaeysØarinso*com) + * Bugfix: transparency now preserved for GIF & PNG input + (thanks tristanØcyrax*ch) + * Bugfix: transparency now supported for GIF output + (thanks j_ivanovØabv*bg) + * Bugfix: alpha transparency could be lost in ApplyMask() + (thanks analyzerxØgmail*com) + * Bugfix: errors on 16/32-bit BMPs + (thanks mattØhellstrominc*com) + * Bugfix: Added datestamp to cached filenames for remote + (HTTP) files, and better warning for caching + (thanks a*gambinoØabramo*it) + * Faster BMP parsing (thanks sgeppertØmail*utexas*edu) + * Added 'error_die_on_source_failure' configuration to + allow invalid source images to show an error rather + than output unmodified source image. + (thanks mindpixelØgmail*com) + * Added $phpThumb->fatalerror which will contain the + text of the fatal error if 'error_die_on_error' is + false. (thanks mindpixelØgmail*com) + +v1.5.0 - February 4, 2005 + * Added new filter parameter 'fltr' that is an array and + can apply multiple effects in sequence. Current filters + that can be called are: + - 'gam' (Gamma Correction) [ex: &fltr[]=gam|] + where can be a number >0 to 10+ (default 1.0) + - 'ds' (DeSaturate) [ex: &fltr[]=ds|] + where is a number between zero (no change) + and 100 (complete desaturation -- grayscale), or it + can be a negative number for saturation boost. + (thanks mailØmmjaeger*com) + - 'clr' (Colorize) [ex: &fltr[]=clr||] + where is a number between 0 and 100 for the + amount of colorization, and is the hex color + to colorize to. (thanks mailØmmjaeger*com) + - 'neg' (Negative) [ex: &fltr[]=neg] + inverts the color + - 'th' (ThresHold) [ex: &fltr[]=th|] (range 0-255) + every grayscale pixel brighter than is set to + white, every darker pixel is set to black + (thanks mailØmmjaeger*com) + - 'usm' (UnSharpMask) [ex: &fltr[]=usm|||] + where is the amount (default = 80), is the + radius (default = 0.5), is the threshold + (default = 3). + - 'wmi' (WaterMarkImage) + [ex: &fltr[]=wmi||||] where is the + filename of the image to overlay, is the + alignment (one of BR, BL, TR, TL, C, R, L, T, B, * + where B=bottom, T=top, L=left, R=right, C=centre, + *=tile), is opacity from 0 to 100, is the + edge (and inter-tile) margin in percent + - 'wmt' (WaterMarkText) + [ex: &fltr[]=wmt||||||||] + where: + is the text to use as a watermark, + is the font size (1-5 for built-in font, or point + size for TrueType fonts), + is the alignment (one of BR, BL, TR, TL, C, R, L, + T, B, * where B=bottom, T=top, L=left, R=right, + C=centre, *=tile), + is the hex color of the text + is the filename of the TTF file (optional, if + omitted a built-in font will be used) + is opacity from 0 to 100, + is the edge (and inter-tile) margin in percent + is the angle + (thanks mailØmmjaeger*com) + - 'flip' [ex: &fltr[]=flip|x or &fltr[]=flip|y] + flip image on X or Y axis + (thanks mailØmmjaeger*com) + - 'elip' [ex: &fltr[]=elip] + similar to rounded corners but more extreme + (thanks mailØmmjaeger*com) + - 'mask' [ex: &fltr[]=mask|filename.png] + greyscale values of mask are applied as the alpha + channel to the main image. White is opaque, black + is transparent. + - 'bvl' (BeVeL) [ex: &fltr[]=bvl|||] + where is the bevel width, is the hex color + for the top and left shading, is the hex color + for the bottom and right shading + (thanks mailØmmjaeger*com) + - 'fram' (FRAMe) draws a frame, similar to border but + more configurable (thanks mailØmmjaeger*com) + [ex: &fltr[]=fram|||||] + where is the width of the main border, is + the width of each side of the bevel part, is the + hex color of the main border, is the highlight + bevel color, is the shadow bevel color + - 'drop' (DROP shadow) + [ex: &fltr[]=drop||||] + where is distance from image to shadow, is + width of shadow fade (not yet implemented), is + the hex color of the shadow, and is the angle of + the shadow (default=225) + - 'ric' (Rounded Image Corners) + [ex: &fltr[]=ric||] + where is the horizontal corner radius, + is the vertical corner radius + * Split out filter functions into phpthumb.filters.php + * 'usa','usr','ust' parameters have been removed and + replaced with the 'fltr' call (see above) + * 'wmf','wma','wmp','wmm' parameters have been removed + and replaced with the 'fltr' call (see above) + * 'brx','bry','bw' parameters have been removed + and replaced with the 'fltr' call (see above) + * 'bw=0' to force aspect ratio has been replaced by + 'far=1' (force aspect ratio) + * Filters that produce transparent sections (such as + Rounded Corners, Ellipse, Mask, Rotate) are now output + as 32-bit/alpha PNG, or flattened with "bg" background + color for JPEG/GIF output (thanks mailØmmjaeger*com) + * Added 'zc' (Zoom Crop) parameter + (thanks arcookeØgmail*com, mailØmmjaeger*com, + pl16056Ømacnews*de, kezzasmØusers*sourceforge*net, etc) + * AutoRotate now can use EXIF orientation tag ('ar=x') + * Added 'ttf_directory' configuration parameter for + TrueType watermarks (thanks mailØmmjaeger*com) + * Added "Last-Modified" header to cache portion of + phpThumb.php which should allow better user-side + caching of thumbnails. (thanks derekØnetsimple*net) + * Added 'cache_disable_warning' configuration which will + cause an error image to be displayed if the cache + directory isn't configured, unless explicitly disabled + * Added 'nooffsitelink_enabled' configuration which + prevents linking to thumbnails on your server from + another domain. Defaults to watermaking linked images + with text warning message. + (thanks anteØabstraktmedia*com) + * Added 'error_image_width' & 'error_image_height' + config variables (thanks mailØmmjaeger*com) + * Rounded image corners now requires GD v2.0.1 and PHP + v4.3.2. Corners are transparent (for PNG output) and + antialiased. + * Rotate by arbitary angle ('ra') now has a transparent + background for PNG output + * Cached filenames now have an additional component for + applied filters + * Cached filenames now have an additional component for + HTTP referer, but only if the refering domain does not + match the domain of the server (designed to prevent + imaged linked from offsite with error message being + cached the same as the local cached version) + * Added setSourceImageResource() to allow use of an + existing GD image resource for thumbnailing + (thanks danØgonmad*co*uk) + * Now including phpThumb.demo.demo1.php (main demo page) + and phpThumb.demo.demo2.php (configurable demo page) + in the phpThumb() distribution + (thanks mailØmmjaeger*com) + * Added many more debugging/tracing message points + * Added set_time_limit(30) to phpThumb.php + * Bugfix: ImageMagick not used if `which convert` points + to a link and not a file (thanks bkainersØgmail*com) + * Bugfix: 'bgt' parameter was sometimes misspelled 'bct' + * Bugfix: 'wmm' couldn't be set to zero + * Bugfix: 'wmm' parameter was only applied to top/left of + image + * Bugfix: auto-detection of document_root failed on + Windows (thanks xbartvØhotmail*com) + * Bugfix: phpThumbDebug could be bypassed if EXIF + thumbnail present (thanks olgradinØcheckfree*com) + * Bugfix: cache file wasn't being written if EXIF data + was used directly (thanks olgradinØcheckfree*com) + * Bugfix: phpThumb.demo.showpic.php was broken by popup + blockers for images larger than the screen. + (thanks mailØmmjaeger*com) + +v1.4.11 - October 11, 2004 + * Changed sx/sy/sw/sh parameters to allow decimal values + (>0 but <1) to represent percent of source image + (thanks mordorØdefault*co*yu) + * Added config_error_silent_die_on_error for no-output + die on fatal errors (thanks johannesØformformat*se) + * Added auto-detection of probable 'document_root' if + that key is not available in $_SERVER + * Bugfix: Check `which convert` failing with error + message (thanks chadØchadshome*com) + * Bugfix: Image cropping to invalid areas outside source + image caused text output (thanks mordorØdefault*co*yu) + +v1.4.10 - August 22, 2004 + * Bugfix: cached files not written in most cases + (thanks kizerØcourtkizer*com, snuffØinbox*ru) + * Bugfix: ApacheLookupURIarray() crashes in CGI mode + (thanks hanskrentelØyahoo*de) + * Bugfix: phpthumb_bmpfile2gd() was broken + (thanks iØmindlace*net) + +v1.4.9 - August 9, 2004 + * Bugfix: changed destination filename in RenderToFile() + (thanks alextkØwalla*com) + * Bugfix: problems with HTTP image source when called as + an object (thanks alextkØwalla*com) + +v1.4.8 - August 4, 2004 + * $this->error has changed to $this->errors and is now + an array of strings (instead of a single string) + * A lot more error conditions (invalid cache directory, + etc) are now reported in $this->errors + (thanks aidan*slingsbyØlineone*net) + * Removed all define(CONSTANT) in the phpThumb() + constructor - you can now access: + - PHPTHUMB_VERSION == $this->phpthumb_version; + - PHPTHUMB_OSSLASH == $this->osslash; + - PHPTHUMB_ISWINDOWS == $this->iswindows; + * Bugfix: Error message from apache_lookup_uri() failing + under Apache2 now reported cleanly + (thanks derbaffØyahoo*com) + * Bugfix: missing phpthumb_functions:: class name for + ImageTypeToMIMEtype() call in ExtractEXIFgetImageSize() + (thanks aidan*slingsbyØlineone*net) + * Bugfix: ImageTypeToMIMEtype() was broken for PHP older + than v4.3.0 (thanks georg*schreiberØbatch-pc*es) + * Bugfix: RenderToFile() now returns false if it fails + (thanks phpthumbØsendthemtomir*com) + * Bugfix: Corrupt JPEG/PNG/GIF files that failed + ImageCreateFrom*() were not being passed to ImageMagick + for fallback, nor passed through unmodified if IM was + unavailable or failed (thanks r*chongØmogenic*net) + * Bugfix: Improved backtick safe-mode limit detection + (thanks 1Øadamcarrington*com) + * Bugfix: EXIF thumbnails were being used as source when + they should not be (thanks aidan*slingsbyØlineone*net) + * Bugfix: Cached files were not being created or used + properly (thanks aidan*slingsbyØlineone*net) + * Bugfix: max_source_pixels not set correct on some PHP + versions (thanks derbaffØyahoo*com) + * Bugfix: 'down' parameter ignored for unprocessed and + cached files (thanks aidan*slingsbyØlineone*net) + +v1.4.7 - July 27, 2004 + * Included a modified version of "module.graphic.bmp.php" + from getID3() [http://getid3.sourceforge.net] as + "phpthumb.bmp.php" for BMP reading support without + ImageMagick. It works, but it's *very* slow, especially + for large images (as in 640x480 or larger). + * Added check to prevent error messages when shell_exec + is disabled (thanks webmasterØneester*com) + +v1.4.6 - July 22, 2004 + * Added new section to phpthumb.config.php where you can + easily specify defaults for any parameter you can set + in the URL. Normally URL parameters override these + default values, unless you set + $PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE to false + * Renamed phpthumb.config.php to phpThumb.config.php + since it's part of phpThumb.php, not part of + phpthumb.class.php (change of case only, will not + affect Windows servers, but will affect *nix) + * Changed cached filename of rawImageData-source images + from urlencode('') to md5(rawImageData). This should + make caching thumbnails from non-file sources more + reliable. + * Added ImageMagick debugging information + * Removed unneccesary default values from cached + filenames. This may invalidate some previously cached + files. phpthumb.demo.cacheconvert.php has been updated + to handle v1.4.1-1.4.5 => v1.4.6+ cache filenames. + * Bugfix: Cached filename did not have file-modified + datestamp when used as implmented in phpThumb.php + * Bugfix: RenderToFile() now accepts relative filenames + (thanks aidan*slingsbyØlineone*net) + * Bugfix: AllowOutputEnlargment setting was ignored when + falling back to ImageMagick + * Bugfix: IgnoreAspectRatio setting was ignored when + falling back to ImageMagick + * Bugfix: config_temp_directory was ignored in gd_info() + in PHP < v4.3.0 when phpinfo() returns no GD + information (due to safe mode restrictions) + (thanks mimyrtekØmyrtek*com) + +v1.4.5 - June 28, 2004 + * Added new parameter 'down' where you can specify a + filename and OutputThumbnail() will cause the file + to be downloaded rather than displayed in the browser. + Demo images on silisoftware.com/scripts/phpThumb/demo/ + can all be downloaded to show off this feature. + (thanks stuartscrumpØyahoo*co*uk) + * Added ability to remove old files from cache directory + based on last-access time and/or number of cached files + and/or total size of cached files + (thanks jrmhaigØyahoo*co*uk) + * Added public CleanUpCacheDirectory() for cache cleaning + (see above) if you need to call it manually + * Included new file phpThumb.demo.cacheconvert.php to + convert old-style cache names to the current (and + hopefully last!) standard naming convention. + (thanks joshgØtwcny*rr*com) + * Added configuration value 'document_root' for rare case + when $_SERVER['DOCUMENT_ROOT'] return incorrect value + (thanks joshgØtwcny*rr*com) + * Now tries to create thumbnail with ImageMagick if + ImageCreateFromJPEG etc fails, before falling back to + outputting unmodified source data. + * Bugfix: HTTP image sources were broken + (thanks fritz*weisshartØt-online*de) + * Bugfix: ImageMagick callout wasn't being used if EXIF + thumbnail was available + (thanks joshgØtwcny*rr*com) + * Bugfix: HTTP src with space in filename was broken + (thanks drØrhodes360*com) + * Bugfix: version_compare_replacement() was broken for + PHP v4.1.0+ + +v1.4.4 - June 8, 2004 + * Bugfix: network-share (Windows) source filenames were + not possible. Now works, but you must use the network + name and not a mapped drive name, for example: + \\othercomputer\file.jpg - good + \\192.168.2.1\file.jpg - good + z:\file.jpg - won't work + This is a PHP limitation (see www.php.net/file-exists) + Note: you may want to use "/" slashes instead of "\" if + you have magic_quotes_gpc enabled to avoid stripslashes + problems. + (thanks drØrhodes360*com) + * Bugfix: missing "phpthumb_functions::" in + ImageCreateFromStringReplacement() + (thanks zapletalØsoftwaremedia*cz) + +v1.4.3 - May 25, 2004 + * Added new configuration variable 'config_temp_directory' + to allow you to specify a writable directory name for + temp files if you do not have access to the system temp + directory on your server (Safe Mode restrictions etc) + (thanks nickØregenmag*com) + * Added new configuration variable + 'config_error_die_on_error' which can be set to false if + you want to retrieve the error message without having it + dumped as an image - the error message is now available + in $phpThumb->error + * Images are passed through directly with no processing + and no caching if no parameters are passed to alter the + image (resize, crop, sharpening, etc) + (thanks nchmuraØusers*sourceforge*net) + * Added new configuration variable 'config_disable_debug' + which disabled phpThumbDebug from working if you have + security concerns about the displayed information + * Bugfix: Added detection at the top of phpThumb.php for + no-GD errors to avoid parse errors later in the code + (thanks nickØregenmag*com) + * Bugfix: RoundedImageCorners() had some off-by-1 errors + (thanks ola*thunbergØhome*se) + +v1.4.2 - May 10, 2004 + * Added IE-compatability mode for transparent corners + (set 'bct=256') + * Bugfix: version_compare_replacement() was broken in PHP + older than 4.1.0 + (thanks nickØregenmag*com) + +v1.4.1.1 - May 9, 2004 + * Bugfix: Removed ImageTrueColorToPalette hack. + See http://bugs.php.net/bug.php?id=28341 + * Bugfix: 'maxb' option for PNG/GIF output incorrect + bit depth under some circumstances + +v1.4.1 - May 9, 2004 + * Added 'maxb' (MAXimum Bytes) option to auto-set the + output image quality (JPEG) or bit depth (PNG/GIF) so + that the output thumbnail is less than 'maxb' bytes + (thanks e_belleØhotmail*com) + * Added 'bgt' parameter to make rounded corners from + 'brx'/'bry' option transparent when used with PNG + output. Note: PHP/GD appears buggy at this time, so this + option must force output to 256-color mode for this + to work. The feature will be updated when a non-broken + version of PHP/GD is released. + (thanks javierØircorion*net) + * Bugfix: Caching was broken + (thanks mikeØgdaymate*nl, jurewiczØgo3*pl) + +v1.4.0 - April 30, 2004 + * Rewritten as a PHP class. Split into several files: + - phpthumb.class.php = most processing code + - phpthumb.functions.php = support functions + - phpthumb.readme.txt = usage instructions + - phpthumb.changelog.txt = this file + - phpthumb.config.php = configuration file + - phpthumb.gif.php = Non-GD GIF reading support + - phpthumb.unsharp.php = Unsharp Masking support + - phpThumb.php = demo script that works + exactly as previous versions; this is a drop-in + replacement for existing phpThumb() installations + - phpThumb.demo.showpic.php = demo script that auto- + resizes a popup window to the size of the image + shown. Useful if you want popup images but do not + know the large image size beforehand + * Added optional call-out to ImageMagick (if avaible) if + source image is larger than PHP memory restrictions + allow. ImageMagick installation should be auto-detected + under *nix, but you should configure 'imagemagick_path' + for use under Windows. + * 'max_source_pixels' is now auto-calculated from PHP + configuration settings. Due to various server-level + restrictions that may override PHP settings this + calculated value may not always be correct, and you may + have to specify the value manually. + * Added rounded-corner border option. You must specify + both 'brx' (horizontal radius) and 'bry' (vertical + radius) as well as 'bw' (border width). If 'bw' is + greater than zero, the image will be shrunk to fit + inside the border with a margin of background color. + If 'bw' is zero, the corners of the image will be + cut off and filled with background color. + (thanks javierØircorion*net) + * Minor speed improvement for unsharp masking + +v1.3.7 - March 28, 2004 + * Bugfix: GD version detection was broken on PHP <4.3.0 + on servers where phpinfo() was disabled + (thanks javierØircorion*net) + * Bugfix: Non-GD GIF support was broken on restricted + PHP configurations + (thanks javierØircorion*net) + * Bugfix: phpThumb.gif.php output error messages if PHP + was running in Safe Mode + * Added 'iar' parameter (Ignore Aspect Ratio) to allow + non-proportional resizing (stretch image to fit). + You must specify 'h' and 'w' to use this option. + (thanks javierØircorion*net) + +v1.3.6 - March 14, 2004 + * Bugfix: was broken when register_globals turned on + (thanks joshgØtwcny*rr*com) + * Bugfix: Images with transparent backgrounds now have + the background color filled with the color specified + by the 'bg' parameter + * Bugfix: ImageCreateFromString() is broken in the + non-bundled GD. Added workaround, but please use + the bundled version of GD if possible + (thanks dnØxbe*ch) + * Bugfix: EXIF thumbnail caching was broken + * Bugfix: EXIF thumbnail handling was broken for PHP + v4.2.x + (thanks smithk1Øshaw*ca) + * Bugfix: Image borders with GD2 were misaligned + * Bugfix: virtual paths/filenames like /~user/foo.jpg + should now work properly, if PHP is installed as an + Apache module (see www.php.net/apache-lookup-uri) + * Bugfix: contents of any non-image file could be + displayed (including PHP & HTML files) + (thanks arsyanØarsyan*com) + * Added rotation parameters 'ra' and 'ar' + (thanks drØrhodes360*com) + * Added $CONFIG['output_allow_enlarging'], defaulted + to false, to prevent smaller-than-max-size images + from being enlarged beyond their original size. If + you want to be able to enlarge images, set this to + false. Can be overridden with the 'aoe' parameter + (thanks dnØxbe*ch) + * Changed all configuration variables to be under one + array named $CONFIG + * Moved color and font options for ErrorImage() to + $CONFIG variables + * Changed cached filename structure (again) to a more + flexible format that can handle future expansion + (old cached files are invalid and will be recreated) + * Added more debugging code to phpThumbDebug + +v1.3.5 - February 29, 2004 + * Added capability to use EXIF thumbnail that may be + embedded in source image (often is in digital camera + JPEGs) and source image dimensions are larger than + $config_max_source_pixels. This will overcome the + limitation where PHP runs out of memory processing + large images (usually >1600x1200). EXIF thumbnail + extraction requires PHP v4.2.0 or higher and EXIF + support compiled into PHP (or php_exif extension) + * Eliminated intermediate read-file-to-memory stage if + image is created from local file. Should allow + larger images to be processed without running out of + memory. + * Added optional 'goto' parameter to be used with the + 'file' parameter, where 'goto' is a URL that is + redirected to after image is rendered to file + (thanks wimbleØwebdonors*com) + * Added optional 'xto' parameter that will bypass all + processing and just return the embedded EXIF + thumbnail, if available. + * Added error-handling if ImageTypes() is unavailable + +v1.3.4 - February 15, 2004 + * Custom error image option (&err=img.jpg) which can + also be set as $config_error_message_image_default + (thanks carlØ4thstar*net) + * &f=text will now output plain-text error messages + * ErrorImage() now used for anti-hotlink messages (if + $config_nohotlink_erase_image is true) + +v1.3.3 - February 5, 2004 + * Bugfix: Added stripslashes() to filenames if + magic_quotes_gpc is enabled + (thanks arsyanØarsyan*com) + * Output can now be rendered to a file only (not to + browser) specified by the 'file' parameter + (thanks arsyanØarsyan*com) + * JPEG quality now has a maximum of 95%, as specified + in the GD documentation + +v1.3.2.1 - February 3, 2004 + * Bugfix: gd_version() was broken for GD v2.0+ + * Bugfix: removed debugging code + +v1.3.2 - February 3, 2004 + * Bugfix: when borders are enabled, portait images + with no width constraint, or landscape images with + no height constraint were smaller than neccesary by + double the border width + (thanks jjjØxs4all*nl) + * Added unsharp mask option thanks to Torstein Hønsi: + http://www.vikjavev.com/hovudsida/umtestside.php + Note: requires GD v2.x to function + (thanks jjjØxs4all*nl) + * Updated cache filenames to reflect new parameters, + this means old cached files will need to be deleted + (or not, they just will never get called again) and + new cached versions will be created. + * Added caching to gd_info() calls for minor speedup + +v1.3.1 - February 2, 2004 + * Added optional border (width and color configurable) + (thanks arsyanØarsyan*com) + * Added option to create fixed-dimension thumbnails + regardless of source aspect ration. Set the 'bw' + (BorderWidth) parameter (even to 0) and this will be + enabled. Outside the actual image will be filled + with 'bg' color (default FFFFFF) + (thanks arsyanØarsyan*com) + +v1.3.0 - January 27, 2004 + * Added watermarking option to overlay thumbnails with + a semi-transparent watermark image (copied from a + seperate source watermark image) + (thanks arsyanØarsyan*com) + * Added option for absolute filenames (on both Windows + and *nix) outside the DOCUMENT_ROOT directory + * Added debug output dump for diagnosing problems) + +v1.2.8 - January 19, 2004 + * added ability to specify relative pathnames as well + as absolute pathnames (pathname is relative to the + location of phpThumb.php if the passed source does + not begin with "/" + +v1.2.7 - January 7, 2004 + * Added patch to allow use of PHP older than 4.1.0 + (or GD without PNG support) for non-GD GIF support + (thanks hostwebserverØhotmail*com) + +v1.2.6 - January 4, 2004 + * Added patch to allow use of PHP older than 4.1.0 + (without the superglobals arrays) + +v1.2.5 - December 26, 2003 + * Added configuration options for default output image + format and max width/height + +v1.2.4 - December 20, 2003 + * Bugfix: temp directory for non-native GD support not + always returning valid directory + * Caching feature reintroduced (see configuration) + +v1.2.3 - December 19, 2003 + * Added anti-hotlink code so the thumbnail script on + one domain cannot be used by another domain. The + list of allowed domains defaults to the current + domain but is configurable below as + $config_nohotlink_valid_domains. The message, text + size, colors and whether to blank the image or not + are also configurable + * Bugfix: URL image sources were not able to use the + non-GD GIF-reading functions + +v1.2.2 - December 17, 2003 + * Added option to use http:// URL as image source + +v1.2.1 - December 11, 2003 + * Added option to get source data from a database + rather than a physical file + * Bugfix: resize not proportional when wide image + limited more by max height than max width + Thanks mathias_strasserØgmx*net + * Removed caching code + +v1.2.0 - December 10, 2003 + * Added GIF support for versions of GD that do not + have built-in GIF support (v1.6.x) via the "GIF + Util" class by Fabien Ezber (www.yamasoft.com) + GD's built-in GIF-reading functions are faster, and + are present in PHP v4.3.0 or newer, but all versions + of GD can display resized GIF thumbnails now. + +v1.1.2 - October 26, 2003 + * check for source image existance to prevent text + error messages + * if GD not available, a GIF saying "no GD" is shown + instead of showing the original image + * Cache feature introduced + +v1.1.1 - September 28, 2003 + * better resize code by sfisher10Øcox*net + +v1.1.0 - September 1, 2003 + * initial public release + * thumbnails can now be larger than source image + * graphical error messages + +v1.0.0 - January 7, 2002 + * initial private release diff --git a/external/phpThumb/docs/phpthumb.faq.txt b/external/phpThumb/docs/phpthumb.faq.txt new file mode 100644 index 0000000000..e873dc88c0 --- /dev/null +++ b/external/phpThumb/docs/phpthumb.faq.txt @@ -0,0 +1,372 @@ +////////////////////////////////////////////////////////////////// +// phpThumb() by James Heinrich // +// available at http://phpthumb.sourceforge.net // +// and/or https://github.com/JamesHeinrich/phpThumb // +////////////////////////////////////////////////////////////////// +/// // +// Frequently Asked Questions (FAQ) about phpThumb() // +// /// +////////////////////////////////////////////////////////////////// + + +Q: My question isn't answered here, how do I get support? +A: Please visit http://support.silisoftware.com for any + questions, suggestions, bugs, etc. + + +Q: I think I found a bug, what's the first thing I should do? +A: Please make sure you're using the latest version: + https://github.com/JamesHeinrich/phpThumb + There's a good chance I may have already fixed the bug, so + please make sure you can reproduce it with the latest version + before reporting the bug. + + +Q: phpThumb doesn't work as expected, and it may be a server + configuration issue -- how do I check? +A: Please run /demo/demo.check.php to find out how your server + matches up with the recommended configuration and for + suggestions on what to change for improved performance. + + +Q: What is the GPL? Can I use this for commercial sites? +A: See the GPL FAQ: http://www.gnu.org/licenses/gpl-faq.html + In general, if you just want to call phpThumb.php in the + standard manner + then there is no problem, you're free to do this no matter + if you site is commercial or not, or what license your code + is released under. + If you're calling phpThumb() as an object then you will + probably run into license issues, so consult the above FAQ + and the GPL itself. + No matter if you use phpThumb() commercially or not, no + payment is required. However, donations are always welcome + and can be made at http://phpthumb.sourceforge.net + + +Q: Some images generate thumbnails, but some fail (the original + non-resized image is output instead). +A: Your PHP installation does not have a high enough memory_limit + and ImageMagick is not installed on the server. The PHP memory + required is 5 times the number of pixels in the image. + For example: + 640x480x5 = 1.5MB + 1600x1200x5 = 9.2MB + You can adjust the PHP memory limit in php.ini (if you have + permission on your server to do so), or (better yet) install + ImageMagick on the server and that will bypass the memory limit + issue. If you can't do either of the above, you can resize the + images manually (with your favourite image editor) to a size + that your memory_limit setting can handle, and/or you can + re-save the images with an image editor that can embed an EXIF + thumbnail (Photoshop for example) which phpThumb can use as an + image source (lower image quality, but perhaps better than + nothing). + + +Q: Is there are way to determine the new height and width of the + generated thumbnail (so I can put it in the width/height)? +A: The problem is that phpThumb.php returns an image -- there is no + way to pass on any additional info such as width/height. + However, you can do something like this: + require_once('phpthumb.functions.php'); + $pic = 'picture.jpg'; + list($source_w, $source_h) = GetImageSize($pic); + $max_w = 375; + $max_h = 400; + list($newW, $newH) = phpthumb_functions::ProportionalResize( + $source_w, $source_h, $max_w, $max_h); + $url = 'phpThumb.php?src='.$pic.'&w='.$max_w.'&h='.$max_h; + echo "'; + + +Q: I'm getting is this error message: + Failed: RenderToFile() failed because + !is_resource($this->gdimg_output) +A: You missed the call to GenerateThumbnail() before + RenderToFile() or OutputThumbnail. + See /demo/phpThumb.demo.object.php for an example. + + +Q: I'm trying to save a phpThumb-generated image in Internet + Explorer and it saves in BMP format, why? +A: This is not phpThumb's fault, it is an IE issue: + http://support.microsoft.com/default.aspx?scid=kb;en-us;810978 + http://support.microsoft.com/default.aspx?scid=kb;en-us;260650 + + +Q: PNG images with transparent areas show up with gray background + in the areas that are supposed to be transparent. +A: Internet Explorer has had a broken PNG alpha-channel display + implementation for a decade, so it may never get fixed. Other + major browsers generally handle alpha-transparent PNGs fine. + See http://www.silisoftware.com/png_transparency/ + For an alpha-channel PNG display in IE hack, see this page: + http://www.koivi.com/ie-png-transparency/ + + +Q: I'm getting " does not exist" when I know the + file does exist +A: Check that these two values are present and properly + configured in phpThumb.config.php (introduced in v1.6.0): + $PHPTHUMB_CONFIG['allow_src_above_docroot'] (default=false) + $PHPTHUMB_CONFIG['allow_src_above_phpthumb'] (default=true) + If your images are outside DOCUMENT_ROOT (this includes if + you have an image upload form, most likely the images will + get uploaded to "/tmp/" or similar) then you will have + to configure 'allow_src_above_docroot' to true. + Make sure whatever user the webserver is running as has read + permission to the file/directory you're reading from + + +Q: Should I use phpThumb.php, or use phpThumb() as an object? +A: phpThumb.php is easier to use (less coding) for basic uses. + phpThumb.php handles all caching; your own object will need + to have its own caching code. If you just want to display a + thumbnailed version of an existing image, use phpThumb.php + If you want to render one (or more) thumbnails to static + files (during upload, for example), that's an appropriate + use for the object mode. Also, phpThumb.config.php is only + used by phpThumb.php, so if you instantiate your own object + you need to manually set all configuration options because + phpThumb.config.php has NO effect. So, to repeat: + **always use phpThumb.php unless you NEED to have an object** + + +Q: The first time I go to a page which contains thumbnails I + don't actually see the thumbnail, I just get a browser image + placeholder (or no image). As soon as I hit refresh, all the + thumbnail images pop into place really fast. +A: You can try and see if it works better with + $PHPTHUMB_CONFIG['cache_force_passthru'] = false; + but typically the default setting works better. + Note: There were some maybe-undefined variables prior to + v1.7.9 that contributed to this behavior. If you notice + this happening in v1.7.9 or newer please email me at + info@silisoftware.com + + +Q: Are there any front-end GUI interfaces to phpThumb()? +A: See /demo/readme.demo.txt + + +Q: Are there / have there been any security issues in phpThumb? +A: http://secunia.com/product/5199/ + + +Q: Why can't Flash work with images output from phpThumb()? +A: Flash doesn't like progressive JPEG. Set: + $PHPTHUMB_CONFIG['output_interlace'] = false; + + +Q: Image quality is not very good - why? +A: If you're using GD v1.x, no way around it. Upgrade to GD v2.x + + +Q: Image quality is very bad, very pixelated -- why? +A: You may be trying to resize images larger than the available + PHP memory, so phpThumb is simply extracting and using the + EXIF thumbnail as the image source, which is usually about + 160x120 (so if you resize it to 640x480 it will look very bad). + To calculate the required size for memory_limit in php.ini, + calculate the number of pixels in the image and multiply by 5: + For example, 1600x1200 = 1600 * 1200 * 5 = 9600000 = 10M + Easy solution: install ImageMagick + + +Q: Can I save the generated thumbnail to a file? +A: Yes, there are several ways to do so; the best way is to call + phpThumb as an object and call RenderToFile() to save the + thumbnail to whatever filename you want. + See /demo/phpThumb.demo.object.php for an example. + The other way is to use the 'file' parameter (see + /docs/phpthumb.readme.txt) but this parameter is deprecated + and does not work in phpThumb v1.7.5 and newer. + + +Q: "Off-server thumbnailing is not allowed" -- how do I enable it? +A: By default, phpThumb() only makes thumbnails for the same + domain that it is running on. To allow it to make thumbnails + for a limited number of other domains, add them + (in phpThumb.config.php) like this: + $PHPTHUMB_CONFIG['nohotlink_valid_domains'] = array( + @$_SERVER['HTTP_HOST'], 'example.com', 'www.example.com', + 'subdomain.example.net', 'example.org'); + To disable off-server thumbnail blocking, just set: + $PHPTHUMB_CONFIG['nohotlink_enabled'] = false; + + +Q: Is it possible to set the parameters (like w/h/fltr[]) in + the config, so that they can't be changed over the URL? +A: Take a look at $PHPTHUMB_DEFAULTS at the bottom of + phpThumb.config.php You'll want to set + $PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE = false + possibly also + $PHPTHUMB_DEFAULTS_DISABLEGETPARAMS = true + You may also want to investigate + $PHPTHUMB_CONFIG['high_security_enabled'] = true + (see the example at the bottom of phpThumb.config.php + for how to call images in HighSecurity mode) + + +Q: Is there a way to use phpThumb() object to create thumbnails + without the parameters in the URL showing the location of + the image etc? +A: There is a demo in /demo/phpThumb.demo.object.php. You could + modify this into your own file, but there still remains the + problem of passing parameters to the file, whether it's + phpThumb.php or your own instantiation of a phpThumb() object. + I would suggest is putting as many of the common parameters + into phpThumb.config.php as possible under $PHPTHUMB_DEFAULTS, + so you then don't have to pass them for each image. If you + don't want people modifying the parameters, turn on + $PHPTHUMB_CONFIG['high_security_enabled'] and set a password + (you'll need to generate the tags with phpThumbURL() + provided at the bottom of phpThumb.config.php). If you don't + want people accessing your source images at all, you can + place them outside DOCUMENT_ROOT on your server (as long as + phpThumb/PHP has read access to the directory). The other + option is to put your source images in a MySQL database + and set $PHPTHUMB_CONFIG['mysql_query'] and related + parameters in phpThumb.config.php to pull your source images + from the database. That way it's impossible to retrieve the + images except through phpThumb.php, and if high_security is + enabled, then nobody can modify the parameters to view + anything except what you want to show. So, yes, it's possible + to use your own object, but it's probably better to use + phpThumb.php if possible -- one notable issue is that + phpThumb.php handles all the caching, so you're on your own + to deal with that if you create your own object. + + +Q: How do I write the output thumbnail back to a database instead + of outputting to the browser or a file? +A: See /demo/phpThumb.demo.object.php Basically you need to call + $this->GenerateThumbnail() then $this->RenderOutput() and then + the output raw image data is found in $this->outputImageData + + +Q: phpThumb runs slowly, as if the images aren't cached, when I use HTTP source + images (not on my server). How can I make it go faster? +A: $PHPTHUMB_CONFIG['cache_source_filemtime_ignore_remote'] = true; + // if true, remote source images will not be checked for modification date and + // cached image will be used if available, even if source image is changed or removed + + +Q: What does the "cache_default_only_suffix" configuration option do? +A: Cache files are normally created with big ugly names like + "phpThumb_cache_www.example.com_src1a482c2c760463795ff18faf073b389f_par3e099041c2f4a73041a7f5d7e7fc481a_dat1119952152.jpeg" + but if cache_default_only_suffix is enabled, cache filenames are simplified to + "pic_thumb.jpg" (for example). The problem is that only one version of that + thumbnail is possible, and you can never call it again with a different size, + or different filters, etc. Generally you don't want that enabled, but it's + there because some people asked for it. + + +Q: Why is the visual size of rotated images smaller than the unrotated images? +A: phpThumb fits the rotated image into the 'w' and 'h' dimensions. + Try not specifying a 'w' parameter: phpThumb.php?src=file.png&ra=15 + That should leave the image the apparent same size as the unrotated image + (in actual fact the canvas size is enlarged to fit the rotated image in it). + + +Q: phpThumb.demo.check.php says Safe Mode is off for Master but on for Local, + and I checked php.ini and it's already set off. How do I disable safe mode? +A: Your PHP was probably installed as an Apache module. If so, you have to set + php_admin_value safe_mode "Off" + in your domain settings (usually between tags in httpd.conf). + Then you have to restart Apache. + + +Q: How can I purge cached files when I delete the source image? +A: You can either let phpThumb's built-in cache purging features (see phpThumb.config.php) + take effect, or you can manually walk through your source images to delete and find + the matching cache files and delete them: + if ($dh = opendir($sourcedir)) { + while ($file = readddir($dh)) { + if ($file == $WhatIwantToDelete) { + $md5 = md5_file($sourcedir.'/'.$file); + unlink($phpthumb_cache_dir.'/phpThumb_cache_www.example.com_src'.$md5.'*.*'); + } + } + closedir($dh); + } + + +Q: Is it safe to delete cache files? +A: Yes, it is safe to delete any cache files and/or directories. phpThumb will + automatically re-create them as needed. Also, take a look at the "cache_max*" + settings in phpThumb.config.php for automatic cache purging. + + +Q: How can I find the filename that phpThumb.php will use to + cache a particular image? +A: It's not easily possible to get the cache filename. You can + see the method used to calculate it in SetCacheFilename() + in phpthumb.class.php (around line 2991-3090). If you need + to know where an image will be rendered to, it may be + easier and better to call phpThumb as an object and handle + your own caching. See /demo/phpThumb.demo.object.simple.php + for an example. + + +Q: Can I make thumbnails from a PDF? +A: Yes, as long as you have both ImageMagick and GhostScript + installed. The AFPL version of GhostScript seems to work + better than the GNU version (at least for me it does). + http://www.imagemagick.org + http://www.cs.wisc.edu/~ghost/ + You may want to use the "sfn" (Source Frame Number) + parameter of phpThumb to specify which page to thumbnail. + + +Q: Can I make a thumbnail of a webpage? +A: Possibly, but it's not easy. Theoretically, if you have + html2ps, GhostScript and ImageMagick all installed it should + be possible, but I have not tested that. Other projects that + attempt to generate thumbnails from webpages include: + http://www.boutell.com/webthumb/ + + +Q: When I resize an animated GIF the new "smaller" version is + actually a larger file size -- why? +A: Animated GIFs use a variety of temporal and spatial compression + techniques. The source GIF is probably very well optimized, but + when each frame is resized some of the desirable compression + properties could be negatively affected (the number of colours + can increase; dithered areas compress very poorly compared to + solid areas of colour). ImageMagick may also not produce the + most filesize-optimized animated GIF possible. + + +Q: Can I use source images from (same or another) server that uses + a script with parameters to display images? For example: + http://sourceforge.net/sflogo.php?group_id=106407&type=5 + (displays a PNG image, 210x62) +A: Yes, you should be able to use phpThumb like that no problem. + If the source image is on a different server you need to set + $PHPTHUMB_CONFIG['nohotlink_valid_domains'] to contain the source + domain(s) [eg: sourceforge.net] if it's a small list of possible + source domains, or make sure $PHPTHUMB_CONFIG['nohotlink_enabled'] + is set to false to allow creating source images from any domain/IP. + You will also need to properly encode the image source (using PHP + function rawurlencode): + /phpThumb.php?src=http%3A%2F%2Fsourceforge.net%2Fsflogo.php%3Fgroup_id%3D106407%26type%3D5&w=100 + + +Q: phpThumb is the best software in the world, how can I donate? +A: There's a handy "Support this project" button at the top of + http://phpthumb.sourceforge.net which will take you through + the process (and give SourceForge a ~5% cut), or if you prefer + you can send PayPal donations directly to info@silisoftware.com + + +Q: What is the proper name for this script/program/library? +A: The official name is "phpThumb()" but it may be written + as simply "phpThumb" in short form (or where parentheses + are not permitted), or "phpthumb" in case-insensitive + environments. The following is a non-exhaustive sample of + unacceptable forms: PHPthumb; phpThumbs; phpthump; + phpthumbnailer; phpThumbnail; PHP Thumb; Phpthumb; etc. + + diff --git a/external/phpThumb/docs/phpthumb.license.commercial.txt b/external/phpThumb/docs/phpthumb.license.commercial.txt new file mode 100644 index 0000000000..37c845d589 --- /dev/null +++ b/external/phpThumb/docs/phpthumb.license.commercial.txt @@ -0,0 +1,27 @@ + phpThumb() Commercial License + ============================= + +phpThumb() is licensed under the "GNU Public License" (GPL) and/or the +"phpThumb() Commercial License" (pTCL). This document describes the pTCL. + +--------------------------------------------------------------------- + +The license is non-exclusively granted to a single person or company, +per payment of the license fee, for the lifetime of that person or +company. The license is non-transferrable. + +The pTCL grants the licensee the right to use phpThumb() in commercial +closed-source projects. Modifications may be made to phpThumb() with no +obligation to release the modified source code. phpThumb() (or pieces +thereof) may be included in any number of projects authored (in whole +or in part) by the licensee. + +The licensee may use any version of phpThumb(), past, present or future, +as is most convenient. This license does not entitle the licensee to +receive any technical support, updates or bugfixes, except as such are +made publicly available to all phpThumb() users. + +The licensee may not sub-license phpThumb() itself, meaning that any +commercially released product containing all or parts of phpThumb() must +have added functionality beyond what is available in phpThumb(); +phpThumb() itself may not be re-licensed by the licensee. diff --git a/external/phpThumb/docs/phpthumb.license.txt b/external/phpThumb/docs/phpthumb.license.txt new file mode 100644 index 0000000000..9fec808290 --- /dev/null +++ b/external/phpThumb/docs/phpthumb.license.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/external/phpThumb/docs/phpthumb.readme.txt b/external/phpThumb/docs/phpthumb.readme.txt new file mode 100644 index 0000000000..ad6502820f --- /dev/null +++ b/external/phpThumb/docs/phpthumb.readme.txt @@ -0,0 +1,673 @@ +////////////////////////////////////////////////////////////////// +// phpThumb() by James Heinrich // +// available at http://phpthumb.sourceforge.net // +// and/or https://github.com/JamesHeinrich/phpThumb // +////////////////////////////////////////////////////////////////// +/// // +// This code is released under the GNU GPL: // +// http://www.gnu.org/copyleft/gpl.html // +// // +// phpThumb() is free to use according to the terms of the GPL. // +// GPL FAQ: http://gnu.org/licenses/gpl-faq.html // +// // +// Donations are gratefully accepted from happy users :) // +// See http://phpthumb.sourceforge.net // +// /// +////////////////////////////////////////////////////////////////// + +============ +Description: +============ + +phpThumb() uses the GD library to create thumbnails from images (GIF, PNG +or JPEG) on the fly. The output size is configurable (can be larger or +smaller than the source), and the source may be the entire image or only a +portion of the original image. True color and resampling is used if +GD v2.0+ is available, otherwise low-color and simple resizing is used. +Source image can be a physical file on the server or can be retrieved from +a database. GIFs are supported on all versions of GD even if GD does not +have native GIF support thanks to the GIFutil class by Fabien Ezber. + +AntiHotlinking feature prevents other people from using your server to +resize their thumbnails, or link to your images from another server. The +cache feature reduces server load. + + +======== +Support: +======== +First, read this file. +Then read phpthumb.faq.txt +Then run /demo/phpThumb.demo.check.php +If you still think it's a bug, or can't figure it out, please go to +http://support.silisoftware.com + + +============= +Installation: +============= + +1) Download from either official site: + * https://github.com/JamesHeinrich/phpThumb (current development version) + * http://phpthumb.sourceforge.net (occasional releases + documentation) +2) unzip to a location of your choice on your server, putting it in its + own subdirectory (e.g. /phpThumb/ is useful but not required) +3) rename phpThumb.config.php.default -> phpThumb.config.php +4) edit phpThumb.config.php as needed to suit your server configuration. + * the only setting you must set is 'high_security_password' + * most other values are auto-detected, but your particular server config + may necessitate setting other values such as 'document_root' or + 'imagemagick_path' + * see also "Configuration" section below +5) Check your server configuration by opening + /phpThumb/demo/phpThumb.demo.check.php in your browser. Settings that are + highlighted green are good; yellow/orange/red may need to be adjusted. + + +====== +Usage: +====== + +Call phpThumb() just like you would a normal image (i.e. as the SRC attribute +of an IMG tag): + +To generate the hash value you must include the phpThumb.config.php file and use the +phpThumbURL function to generate the URL including the hash value: + echo ''; +The hash is calculated with the 'high_security_password' config value, so you +must generate a complex password value for that setting in phpThumb.config.php +(once, when installing phpThumb). + +See the "demo" link on http://phpthumb.sourceforge.net for more usage examples. +Parameters that can be passed are listed below under "URL Parameters". + +NOTE: It's recommended you use the local image filename +wherever possible (rather than http://) because performance +is much better, less (or no) use of temp files, and the +last-modified check for cached files doesn't work for +remote files. + +To access files over a LAN with Windows share names you +must use the network name (or IP) and not a mapped drive +name, for example: + //othercomputer/file.jpg - good + //192.168.2.1/file.jpg - good + z:/file.jpg - won't work +This is a PHP limitation (see www.php.net/file-exists) +Note: you may want to use "/" slashes instead of "\" if +you have magic_quotes_gpc enabled to avoid stripslashes +problems, although either slash should work if +magic_quotes_gpc is disabled + + +================================ +Alternate PATH_INFO-style Usage: +================================ + +phpThumb.php can also be called by passing parameters not +after the usual "?" but like this: + phpThumb.php/=;x; +For example: + phpThumb.php/100;pic.jpg + phpThumb.php/100;images/pic.jpg + phpThumb.php/100;/images/pic.jpg + phpThumb.php/100x200;pic.jpg + phpThumb.php/x200;pic.jpg + phpThumb.php/f=jpeg;q=50;100x200;pic.jpg + phpThumb.php/fltr[]=usm;100;pic.jpg + + must be the last item. Dimensions must be the second- +last item. As many key/value pairs for parameters can be +passed before those last two items, with each pair joined by +equals ("=") and seperated by semicolon (";") + + +============================================== +Calling as an object (not using phpThumb.php): +============================================== + +NOTE: most people don't need to and should not do this. If you just want to +display resized images, please just use phpThumb.php, not the object mode. +To render output to one (or more) files instead of the browser, you should +skip phpThumb.php and instantiate your own object. Please take a look at +/demo/phpThumb.demo.object.php for details. + +Note: phpThumb.php is where the caching code is located, if you instantiate + your own phpThumb() object that code is bypassed and it's up to you to + handle the reading and writing of cached files. + + +============== +Configuration: +============== + +There are some configuration options you may (but are not required to) change. +Most configuration options can be set when you call phpThumb() - see list below), +but default configuration options (such as cache directory) are in +phpThumb.config.php - this is the only file you should ever modify. + + +IMPORTANT: +The configuration file is distributed as phpThumb.config.php.default to prevent +accidental overwriting of old configuration settings. Please migrate your old +settings to the new file (if upgrading), or delete your old config and rename +the default to phpThumb.config.php since newer releases may include settings not +present in your older configuration file. + + +The configuration options you should maybe modify are: +* high_security_password - required to generate the secure hashed URLs for + phpThumb using phpThumbURL() in phpThumb.config.php + Password must be sufficiently complex (typically means at least 20 mixed + alpha/numeric/punctuation characters). You can generate a good password + at http://www.silisoftware.com/tools/password-random.php +* cache_directory - thumbnailing is slow and processor-intensive. Enabling + caching will dramatically speed up future thumbnail serving +* imagemagick_path - Most image-processing functions can be processed faster + if ImageMagick is available on the server. +* max_source_pixels - This should be auto-detected, but if auto-detection + fails and you get an invalid image from large source images, set this to + about 20% of your available PHP memory limit. + The amount of memory required for phpThumb depends on several factors: + * the dimensions of the source image + * the dimensions of the output image + * whether unsharp masking is applied + * whether watermarks are applied, etc. + The auto-detection of memory limits works as a general "safe" value. You + may be able to exceed the auto value by a small or large amount, depending + on whether you apply watermarks and/or sharpening, and the output size of + your thumbnails. If ImageMagick is available then the amount of available + PHP memory is usually not an issue. + + +/////////////////////////////////////////////////////////////////////////// +Note: High-Security mode is VERY STRONGLY recommended enabled in all cases. +Each call to phpThumb.php needs to be made through the function supplied +at the bottom of phpThumb.config.php which create the hash: + require_once('phpThumb.config.php'); + echo ''; +/////////////////////////////////////////////////////////////////////////// + + +=========== +Parameters: +=========== + + src = filename of source image + new = create new image, not thumbnail of existing image. + Requires "w" and "h" parameters set. + [ex: &new=FF0000|75] - red background, 75% opacity + Set to hex color string of background. Opacity is + optional (defaults to 100% opaque). + w = max width of output thumbnail in pixels + h = max height of output thumbnail in pixels + wp = max width for portrait images + hp = max height for portrait images + wl = max width for landscape images + hl = max height for landscape images + ws = max width for square images + hs = max height for square images + f = output image format ("jpeg", "png", or "gif") + q = JPEG compression (1=worst, 95=best, 75=default) + sx = left side of source rectangle (default = 0) + (values 0 < sx < 1 represent percentage) + sy = top side of source rectangle (default = 0) + (values 0 < sy < 1 represent percentage) + sw = width of source rectangle (default = fullwidth) + (values 0 < sw < 1 represent percentage) + sh = height of source rectangle (default = fullheight) + (values 0 < sh < 1 represent percentage) + zc = zoom-crop. Will auto-crop off the larger dimension + so that the image will fill the smaller dimension + (requires both "w" and "h", overrides "iar", "far") + Set to "1" or "C" to zoom-crop towards the center, + or set to "T", "B", "L", "R", "TL", "TR", "BL", "BR" + to gravitate towards top/left/bottom/right directions + (requies ImageMagick for values other than "C" or "1") + bg = background hex color (default = FFFFFF) + bc = border hex color (default = 000000) +fltr = filter system. Call as an array as follows: + - "brit" (Brightness) [ex: &fltr[]=brit|] + where is the amount +/- to adjust brightness + (range -255 to 255) + Availble in PHP5 with bundled GD only. + - "cont" (Constrast) [ex: &fltr[]=cont|] + where is the amount +/- to adjust contrast + (range -255 to 255) + Availble in PHP5 with bundled GD only. + - "gam" (Gamma Correction) [ex: &fltr[]=gam|] + where can be a number 0.01 to 10 (default 1.0) + Must be >0 (zero gives no effect). There is no max, + although beyond 10 is pretty useless. Negative + numbers actually do something, maybe not quite the + desired effect, but interesting nonetheless. + - "sat" (SATuration) [ex: &fltr[]=sat|] + where is a number between zero (no change) + and -100 (complete desaturation = grayscale), or it + can be any positive number for increased saturation. + - "ds" (DeSaturate) [ex: &fltr[]=ds|] + is an alias for "sat" except values are inverted + (positive values remove color, negative values boost + saturation) + - "gray" (Grayscale) [ex: &fltr[]=gray] + remove all color from image, make it grayscale + - "th" (Threshold) [ex: &fltr[]=th|] + makes image greyscale, then sets all pixels brighter + than (range 0-255) to white, and all pixels + darker than to black + - "rcd" (Reduce Color Depth) [ex: &fltr[]=rcd||] + where is the number of colors (2-256) you want + in the output image, and is "1" for dithering + (deault) or "0" for no dithering + - "clr" (Colorize) [ex: &fltr[]=clr||] + where is a number between 0 and 100 for the + amount of colorization, and is the hex color + to colorize to. + - "sep" (Sepia) [ex: &fltr[]=sep||] + where is a number between 0 and 100 for the + amount of colorization (default=50), and is + the hex color to colorize to (default=A28065). + Note: this behaves differently when applied by + ImageMagick, in which case 80 is default, and lower + values give brighter/yellower images and higher + values give darker/bluer images + - "usm" (UnSharpMask) [ex: &fltr[]=usm|||] + where is the amount (default = 80, range 0-255), + is the radius (default = 0.5, range 0.0-10.0), + is the threshold (default = 3, range 0-50). + - "blur" (Blur) [ex: &fltr[]=blur|] + where (0 < < 25) (default = 1) + - "gblr" (Gaussian Blur) [ex: &fltr[]=gblr] + Availble in PHP5 with bundled GD only. + - "sblr" (Selective Blur) [ex: &fltr[]=gblr] + Availble in PHP5 with bundled GD only. + - "smth" (Smooth) [ex: &fltr[]=smth|] + where is the weighting value for the matrix + (range -10 to 10, default 6) + Availble in PHP5 with bundled GD only. + - "lvl" (Levels) + [ex: &fltr[]=lvl||| + where can be one of 'r', 'g', 'b', 'a' (for + Red, Green, Blue, Alpha respectively), or '*' for all + RGB channels (default) based on grayscale average. + ImageMagick methods can support multiple channels + (eg "lvl|rg|3") but internal methods cannot (they will + use first character of channel string as channel) + can be one of: + 0=Internal RGB; + 1=Internal Grayscale; + 2=ImageMagick Contrast-Stretch (default) + 3=ImageMagick Normalize (may appear over-saturated) + is how much of brightest/darkest pixels + will be clipped in percent (default = 0.1%) + Using default parameters (&fltr[]=lvl) is similar to + Auto Contrast in Adobe Photoshop. + - "wb" (White Balance) [ex: &fltr[]=wb|] + where is the target hex color to white balance + on, this color is what "should be" white, or light + gray. The filter attempts to maintain brightness so + any gray color can theoretically be used. If is + omitted the filter guesses based on brightest pixels + in each of RGB + OR can be the percent of white clipping used + to calculate auto-white-balance (default = 0.1%) + NOTE: "wb" in default settings already gives an effect + similar to "lvl", there is usually no need to use "lvl" + if "wb" is already used. + - "hist" (Histogram) + [ex: &fltr[]=hist||||||||] + Where is the color band(s) to display, from back + to front (one or more of "rgba*" for Red Green Blue + Alpha and Grayscale respectively); + is a semicolon-seperated list of hex colors to + use for each graph band (defaults to FF0000, 00FF00, + 0000FF, 999999, FFFFFF respectively); + and are the width and height of the overlaid + histogram in pixels, or if <= 1 then percentage of + source image width/height; + is the alignment (same as for "wmi" and "wmt"); + is opacity from 0 (transparent) to 100 (opaque) + (requires PHP v4.3.2, otherwise 100% opaque); + and are the edge margin in pixels (or percent + if 0 < (x|y) < 1) + - "over" (OVERlay/underlay image) overlays an image on + the thumbnail, or overlays the thumbnail on another + image (to create a picture frame for example) + [ex: &fltr[]=over||||] + where is the image filename; is "0" (default) + for overlay the image on top of the thumbnail or "1" + for overlay the thumbnail on top of the image; is + the margin - can be absolute pixels, or if < 1 is a + percentage of the thumbnail size [must be < 0.5] + (default is 0 for overlay and 10% for underlay); + is opacity (0 = transparent, 100 = opaque) + (requires PHP v4.3.2, otherwise 100% opaque); + (thanks raynerapeØgmail*com, shabazz3Ømsu*edu) + - "wmi" (WaterMarkImage) + [ex: &fltr[]=wmi||||||] where + is the filename of the image to overlay; + is the alignment (one of BR, BL, TR, TL, C, + R, L, T, B, *) where B=bottom, T=top, L=left, + R=right, C=centre, *=tile) + *or* + an absolute position in pixels (from top-left + corner of canvas to top-left corner of overlay) + in format {xoffset}x{yoffset} (eg: "10x20") + note: this is center position of image if + and are set + is opacity from 0 (transparent) to 100 (opaque) + (requires PHP v4.3.2, otherwise 100% opaque); + and are the edge (and inter-tile) margin in + pixels (or percent if 0 < (x|y) < 1) + *or* + if is absolute-position format then and + represent maximum width and height that the + watermark image will be scaled to fit inside + is rotation angle of overlaid watermark + - "wmt" (WaterMarkText) + [ex: &fltr[]=wmt|||||||||||] + where: + is the text to use as a watermark; + URLencoded Unicode HTMLentities must be used for + characters beyond chr(127). For example, the + "eighth note" character (U+266A) is represented + as "♪" and then urlencoded to "%26%239834%3B" + Any instance of metacharacters will be replaced + with their calculated value. Currently supported: + ^Fb = source image filesize in bytes + ^Fk = source image filesize in kilobytes + ^Fm = source image filesize in megabytes + ^X = source image width in pixels + ^Y = source image height in pixels + ^x = thumbnail width in pixels + ^y = thumbnail height in pixels + ^^ = the character ^ + is the font size (1-5 for built-in font, or point + size for TrueType fonts); + is the alignment (one of BR, BL, TR, TL, C, R, L, + T, B, * where B=bottom, T=top, L=left, R=right, + C=centre, *=tile); + note: * does not work for built-in font "wmt" + *or* + an absolute position in pixels (from top-left + corner of canvas to top-left corner of overlay) + in format {xoffset}x{yoffset} (eg: "10x20") + is the hex color of the text; + is the filename of the TTF file (optional, if + omitted a built-in font will be used); + is opacity from 0 (transparent) to 100 (opaque) + (requires PHP v4.3.2, otherwise 100% opaque); + is the edge (and inter-tile) margin in percent; + is the angle + is the hex color of the background; + is background opacity from 0 (transparent) to + 100 (opaque) + (requires PHP v4.3.2, otherwise 100% opaque); + is the direction(s) in which the background is + extended (either 'x' or 'y' (or both, but both + will obscure entire image)) + Note: works with TTF fonts only, not built-in + - "flip" [ex: &fltr[]=flip|x or &fltr[]=flip|y] + flip image on X or Y axis + - "ric" [ex: &fltr[]=ric||] + rounds off the corners of the image (to transparent + for PNG output), where is the horizontal radius + of the curve and is the vertical radius + - "elip" [ex: &fltr[]=elip] + similar to rounded corners but more extreme + - "mask" [ex: &fltr[]=mask|filename.png|] + greyscale values of mask are applied as the alpha + channel to the main image. White is opaque, black + is transparent, unless the (invert) parameter is + set to 1 in which case black is opaque and white is + transparent + - "bvl" (BeVeL) [ex: &fltr[]=bvl|||] + where is the bevel width, is the hex color + for the top and left shading, is the hex color + for the bottom and right shading + - "bord" (BORDer) [ex: &fltr[]=bord|||| + where is the width in pixels, and are + horizontal and vertical radii for rounded corners, + and is the hex color of the border + - "fram" (FRAMe) draws a frame, similar to "bord" but + more configurable + [ex: &fltr[]=fram|||||] + where is the width of the main border, is + the width of each side of the bevel part, is the + hex color of the main border, is the highlight + bevel color, is the shadow bevel color + - "drop" (DROP shadow) + [ex: &fltr[]=drop|||||] + where is distance from image to shadow, is + width of shadow fade (not yet implemented), is + the hex color of the shadow, is the angle of the + shadow (default=225), is opacity (0=transparent, + 100=opaque, default=100) (not yet implemented) + - "crop" (CROP image) + [ex: &fltr[]=crop||||] + where is the number of pixels to crop from the left + side of the resized image; , , are for right, + top and bottom respectively. Where (0 < x < 1) the + value will be used as a percentage of width/height. + Left and top crops take precedence over right and + bottom values. Cropping will be limited such that at + least 1 pixel of width and height always remains. + - "rot" (ROTate) + [ex: &fltr[]=rot||] + where is the rotation angle in degrees; is the + background hex color. Similar to regular "ra" parameter + but is applied in filter order after regular processing + so you can rotate output of other filters. + - "size" (reSIZE) + [ex: &fltr[]=size|||] + where is the horizontal dimension in pixels, is + the vertical dimension in pixels, is boolean whether + to stretch (if 1) or resize proportionately (0, default) + and will be interpreted as percentage of current + output image size if values are (0 < X < 1) + NOTE: do NOT use this filter unless absolutely neccesary. + It is only provided for cases where other filters need to + have absolute positioning based on source image and the + resultant image should be resized after other filters are + applied. This filter is less efficient than the standard + resizing procedures. + - "stc" (Source Transparent Color) + [ex: &fltr[]=stc|||] + where is the hex color of the target color to be made + transparent; is the minimum threshold in percent (all + pixels within % of the target color will be 100% + transparent, default =5); is the maximum threshold + in percent (all pixels more than % from the target + color will be 100% opaque, default =10); pixels between + the two thresholds will be partially transparent. +md5s = MD5 hash of the source image -- if this parameter is + passed with the hash of the source image then the + source image is not checked for existance or + modification and the cached file is used (if + available). If 'md5s' is passed an empty string then + phpThumb.php dies and outputs the correct MD5 hash + value. This parameter is the single-file equivalent + of 'cache_source_filemtime_ignore_*' configuration + paramters + xto = EXIF Thumbnail Only - set to only extract EXIF + thumbnail and not do any additional processing + ra = Rotate by Angle: angle of rotation in degrees + positive = counterclockwise, negative = clockwise + ar = Auto Rotate: set to "x" to use EXIF orientation + stored by camera. Can also be set to "l" or "L" + for landscape, or "p" or "P" for portrait. "l" + and "P" rotate the image clockwise, "L" and "p" + rotate the image counter-clockwise. + sfn = Source Frame Number - use this frame/page number for + multi-frame/multi-page source images (GIF, TIFF, etc) + aoe = Output Allow Enlarging - override the setting for + $CONFIG['output_allow_enlarging'] (1=on, 0=off) + ("far" and "iar" both override this and allow output + larger than input) + iar = Ignore Aspect Ratio - disable proportional resizing + and stretch image to fit "h" & "w" (which must both + be set). (1=on, 0=off) (overrides "far") + far = Force Aspect Ratio - image will be created at size + specified by "w" and "h" (which must both be set). + Alignment: L=left,R=right,T=top,B=bottom,C=center + BL,BR,TL,TR use the appropriate direction if the + image is landscape or portrait. + dpi = Dots Per Inch - input DPI setting when importing from + vector image format such as PDF, WMF, etc + sia = Save Image As - default filename to save generated + image as. Specify the base filename, the extension + (eg: ".png") will be automatically added +maxb = MAXimum Byte size - output quality is auto-set to + fit thumbnail into "maxb" bytes (compression + quality is adjusted for JPEG, bit depth is adjusted + for PNG and GIF) +down = filename to save image to. If this is set the + browser will prompt to save to this filename rather + than display the image + +// Deprecated: +file = if set then thumbnail will be rendered to this + filename, not output and not cached. + (Deprecated. Disabled by default since v1.6.0, + unavailable in v1.7.5 and later. You should + instantiate your own object instead) +goto = URL to redirect to after rendering image to file + * Must begin with "http://" + * Requires file parameter set + (Deprecated. Disabled by default since v1.6.0, + unavailable in v1.7.5 and later. You should + instantiate your own object instead) + err = custom error image filename instead of showing + error messages (for use on production sites) + (Deprecated. Disabled by default since v1.6.0, + unavailable in v1.7.5 and later. You should + instantiate your own object instead) + + +============== +General Notes: +============== + +* Always use the local image filename wherever possible + rather than a full http:// URL because performance is + much better, less (or no) use of temp files, and the + last-modified check for cached files doesn't work for + remote files. For example: + good: phpThumb.php?src=/images/nicepic.jpg + bad: phpThumb.php?src=/home/httpd/example/images/nicepic.jpg + worse: phpThumb.php?src=http://example.com/images/nicepic.jpg + +* Thumbnails will be scaled proportionately to fit in a + box of at most (width * height) pixels + (unless "iar" is set) + +* Thumbnail caching for URL or database sources requires + an absolute directory name for $config_cache_directory + Physical file cached thumbnails will be recreated if + the source file changes, but remote/database files + cannot (modification time isn't readily available) + +* If you need a GUI interface to phpThumb(), or for a user + to specify crop settings, or something like that please + see the list of known programs in /demo/readme.demos.txt + +* Cropping images can be specified with either exact pixel + values for sx/sy/sw/sh parameters, or if those are set + to a value >0 and <1 then these are interpreted as a + percentage of the source image width/height. For example, + to crop 25% off all sides, you would specify parameters: + phpThumb.php?src=pic.jpg&sx=.25&sy=.25&sw=.5&sh=.5 + +* phpThumb() may have tempfile access issues on servers + where Safe Mode is enabled, specificly when accessing + a file over HTTP, or when a non-bundled version of GD + is in use. Specifying "config_temp_directory" may help + +* Properly resolving /~user/ style filenames requires + apache_lookup_uri(), which is missing or broken in + Apache2, or if PHP is not installed as an Apache module. + phpThumb() does try and work around this if it is + unavailable, but you may have to specify a full filename + for "src" if you encounter problems. + +* phpThumb() should work with PHP v4.0.6+, but seems to + have a few quirks before v4.1.0 + EXIF thumbnail extraction requires PHP v4.2.0+ + Image rotation requires PHP v4.3.0+. There have been + reports of problems with PHP older than v4.3.3 + Partial transparency for overlays requires PHP v4.3.2+ + Some image filters require PHP v5.0.0+ + Run /demo/phpThumb.demo.check.php to examine your server + +* phpThumb() works better and faster when ImageMagick is + available. Most functions will work with only GD2, but + speed is much faster with ImageMagick, and much larger + images can be processed with ImageMagick than GD. + +* phpThumb() works with GD v1.x, but works better with + GD v2.0+ because of the true-color image support + and ImageCopyResampled(). Also, there appears to be a + bug in ImageCopyResized() which is used with GD v1.x + where the bottom and/or right line of pixels is set + to the background color (due to a rounding error?) + NOTE: Please use the bundled version of GD if at all + possible (with PHP v4.3.0+) because the non-bundled + version has bugs which may cause PHP to crash: + * http://bugs.php.net/bug.php?id=21518 + * http://bugs.php.net/bug.php?id=24174 + phpThumb() has a workaround for the above bug but + there may be other bugs, and the workaround is slow. + Alpha transparent output requires GD >= 2.0.1 and + PHP >= 4.3.2 + Most (if not all) filters require GD v2.x to function + at all. But many filters can be handled by ImageMagick + instead of GD. + +* Filters handled by ImageMagick or GD: + - brit;cont;ds;sat;gray;clr;sep;gam;neg;th;rcd;flip;edge; + emb;lvl;blur;gblr;usm;wb; +* Filters handled only by ImageMagick: + - none yet +* Filters handled only by GD + PHP5: + - sblr;mean;smth; +* Filters handled only by GD2: + - bvl;wmi;wmt;over;hist;fram;drop;mask;elip;ric;bord; + +* Some browsers, notably Internet Explorer (before v7.0), + have problems with PNG transparency. See description: + http://www.silisoftware.com/png_alpha_transparency/ + http://trific.ath.cx/web/png/ + There are some work-around fixes for this IE problem, eg: + http://www.twinhelix.com/css/iepngfix/demo/ + + +=============== +Thanks & Links: +=============== + +* Original image used in phpThumb logo provided by + Mark James: http://www.famfamfam.com/lab/icons/ + + + +======================================== +== phpThumb Commercial License (pTCL) == +======================================== + +See /docs/phpthumb.license.commercial.txt +for details on the terms of the license. + +Current list of pTCL licensees: +(updated list at http://www.phpthumb.com/) + +1) Accomplish Hosting, LLC + http://www.accomplishhosting.com + effective 2007-Apr-28 (lifetime license) + +2) Eric Pujol + http://www.kaprikorn.fr/ + effective 2007-Sep-29 (lifetime license) + +3) CalemEAM Inc. + http://www.calemeam.com/ + effective 2010-Jun-14 (lifetime license) \ No newline at end of file diff --git a/external/phpThumb/phpThumb.config.php b/external/phpThumb/phpThumb.config.php index 21b3939bc8..e42252d8c2 100644 --- a/external/phpThumb/phpThumb.config.php +++ b/external/phpThumb/phpThumb.config.php @@ -36,10 +36,11 @@ // * Security configuration -$PHPTHUMB_CONFIG['high_security_enabled'] = false; // DO NOT DISABLE THIS ON ANY PUBLIC-ACCESSIBLE SERVER. If disabled, your server is vulnerable to hacking attempts, both on your server and via your server to other servers. When enabled, requires 'high_security_password' set to be set and requires the use of phpThumbURL() function (at the bottom of phpThumb.config.php) to generate hashed URLs -$PHPTHUMB_CONFIG['high_security_password'] = ''; // required if 'high_security_enabled' is true, and must be at complex (uppercase, lowercase, numbers, punctuation, etc -- punctuation is strongest, lowercase is weakest; see PasswordStrength() in phpThumb.php). You can use a password generator like http://silisoftware.com/tools/password-random.php to generate a strong password +$PHPTHUMB_CONFIG['disable_debug'] = true; // DO NOT DISABLE THIS ON ANY PUBLIC-ACCESSIBLE SERVER. Prevents phpThumb from displaying any information about your system. If true, phpThumbDebug and error messages will be disabled. If set to false (debug messages enabled) then debug mode will be FORCED -- ONLY debug output will be presented, no actual thumbnail (to avoid accidentally leaving debug mode enabled on a production server) +$PHPTHUMB_CONFIG['high_security_enabled'] = false; // DO NOT DISABLE THIS ON ANY PUBLIC-ACCESSIBLE SERVER. If disabled, your server is more vulnerable to hacking attempts, both on your server and via your server to other servers. When enabled, requires 'high_security_password' set to be set and requires the use of phpThumbURL() function (at the bottom of phpThumb.config.php) to generate hashed URLs +$PHPTHUMB_CONFIG['high_security_password'] = ''; // required if 'high_security_enabled' is true, and must be at complex (uppercase, lowercase, numbers, punctuation, etc -- punctuation is strongest, lowercase is weakest; see PasswordStrength() in phpthumb.functions.php). You can use a password generator like http://silisoftware.com/tools/password-random.php to generate a strong password + $PHPTHUMB_CONFIG['high_security_url_separator'] = '&'; // should almost always be left as '&'. Must be a single character. Do not change to '&' -- htmlspecialchars wrapped around phpThumbURL() takes care of this without breaking the hash -$PHPTHUMB_CONFIG['disable_debug'] = true; // DO NOT ENABLE THIS ON ANY PUBLIC-ACCESSIBLE SERVER. Prevent phpThumb from displaying any information about your system. If true, phpThumbDebug and error messages will be disabled. If set to false (debug messages enabled) then debug mode will be FORCED -- ONLY debug output will be presented, no actual thumbnail (to avoid accidentally leaving debug mode enabled on a production server) $PHPTHUMB_CONFIG['allow_src_above_docroot'] = false; // if false (default) only allow src within document_root; if true, allow src to be anywhere in filesystem $PHPTHUMB_CONFIG['allow_src_above_phpthumb'] = true; // if true (default), allow src to be anywhere in filesystem; if false only allow src within sub-directory of phpThumb installation $PHPTHUMB_CONFIG['auto_allow_symlinks'] = true; // if true (default), allow symlink target directories without explicitly whitelisting them @@ -182,7 +183,7 @@ $PHPTHUMB_CONFIG['background_hexcolor'] = 'FFFFFF'; // Default background color when thumbnail aspect ratio does not match fixed-dimension box - usual HTML-style hex color notation (overridden with 'bg' parameter) // * Watermark configuration -$PHPTHUMB_CONFIG['ttf_directory'] = dirname(__FILE__).'../mpdf60/ttfonts'; // Base directory for TTF font files +$PHPTHUMB_CONFIG['ttf_directory'] = dirname(__FILE__).'/fonts'; // Base directory for TTF font files //$PHPTHUMB_CONFIG['ttf_directory'] = 'c:/windows/fonts'; @@ -190,10 +191,10 @@ // You may want to pull data from a database rather than a physical file // If so, modify the $PHPTHUMB_CONFIG['mysql_query'] line to suit your database structure // Note: the data retrieved must be the actual binary data of the image, not a URL or filename - +$PHPTHUMB_CONFIG['mysql_extension'] = 'mysqli'; // either "mysqli" or "mysql" $PHPTHUMB_CONFIG['mysql_query'] = ''; -//$PHPTHUMB_CONFIG['mysql_query'] = 'SELECT `picture` FROM `products` WHERE (`id` = \''.mysql_escape_string(@$_GET['id']).'\')'; +//$PHPTHUMB_CONFIG['mysql_query'] = 'SELECT `picture` FROM `products` WHERE (`id` = \''.mysqli_real_escape_string(@$_GET['id']).'\')'; // These 4 values must be modified if $PHPTHUMB_CONFIG['mysql_query'] is not empty, but may be ignored if $PHPTHUMB_CONFIG['mysql_query'] is blank. $PHPTHUMB_CONFIG['mysql_hostname'] = 'localhost'; @@ -210,9 +211,10 @@ // * Compatability settings -$PHPTHUMB_CONFIG['disable_pathinfo_parsing'] = true; // if true, $_SERVER[PATH_INFO] is not parsed. May be needed on some server configurations to allow normal behavior. -$PHPTHUMB_CONFIG['disable_imagecopyresampled'] = false; // if true, ImageCopyResampled is replaced with ImageCopyResampleBicubic. May be needed for buggy versions of PHP-GD. -$PHPTHUMB_CONFIG['disable_onlycreateable_passthru'] = true; // if true, any image that can be parsed by GetImageSize() can be passed through; if false, only images that can be converted to GD by ImageCreateFrom(JPEG|GIF|PNG) functions are allowed +$PHPTHUMB_CONFIG['disable_pathinfo_parsing'] = true; // if true, $_SERVER[PATH_INFO] is not parsed. May be needed on some server configurations to allow normal behavior. +$PHPTHUMB_CONFIG['disable_imagecopyresampled'] = false; // if true, imagecopyresampled is replaced with ImageCopyResampleBicubic. May be needed for buggy versions of PHP-GD. +$PHPTHUMB_CONFIG['disable_onlycreateable_passthru'] = true; // if true, any image that can be parsed by getimagesize() can be passed through; if false, only images that can be converted to GD by ImageCreateFrom(JPEG|GIF|PNG) functions are allowed +$PHPTHUMB_CONFIG['disable_realpath'] = false; // PHP realpath() function requires that "the running script must have executable permissions on all directories in the hierarchy, otherwise realpath() will return FALSE". Set config_disable_realpath=false to enable alternate filename-parsing that does not use realpath() function (but also does not resolve symbolic links) // * HTTP remote file opening settings @@ -252,10 +254,21 @@ function phpThumbURL($ParameterString, $path_to_phpThumb='phpThumb.php') { global $PHPTHUMB_CONFIG; + if (is_array($ParameterString)) { + $ParameterStringArray = $ParameterString; + } else { + parse_str($ParameterString, $ParameterStringArray); + } $ParamterStringEncodedArray = array(); - foreach (explode($PHPTHUMB_CONFIG['high_security_url_separator'], $ParameterString) as $key_value_pair) { - @list($key, $value) = explode('=', $key_value_pair); - $ParamterStringEncodedArray[] = $key.'='.rawurlencode($value); + foreach ($ParameterStringArray as $key => $value) { + if (is_array($value)) { + // e.g. fltr[] is passed as an array + foreach ($value as $subvalue) { + $ParamterStringEncodedArray[] = $key.'[]='.rawurlencode($subvalue); + } + } else { + $ParamterStringEncodedArray[] = $key.'='.rawurlencode($value); + } } $ParameterString = implode($PHPTHUMB_CONFIG['high_security_url_separator'], $ParamterStringEncodedArray); return $path_to_phpThumb.'?'.$ParameterString.$PHPTHUMB_CONFIG['high_security_url_separator'].'hash='.md5($ParameterString.$PHPTHUMB_CONFIG['high_security_password']); diff --git a/external/phpThumb/phpThumb.php b/external/phpThumb/phpThumb.php index 62a8233534..18152a95dc 100644 --- a/external/phpThumb/phpThumb.php +++ b/external/phpThumb/phpThumb.php @@ -16,10 +16,14 @@ if (ini_get('magic_quotes_runtime')) { die('"magic_quotes_runtime" is set in php.ini, cannot run phpThumb with this enabled'); } +// Set a default timezone if web server has not done already in php.ini +if (!ini_get('date.timezone') && function_exists('date_default_timezone_set')) { // PHP >= 5.1.0 + date_default_timezone_set('UTC'); +} $starttime = array_sum(explode(' ', microtime())); // could be called as microtime(true) for PHP 5.0.0+ // this script relies on the superglobal arrays, fake it here for old PHP versions -if (phpversion() < '4.1.0') { +if (PHP_VERSION < '4.1.0') { $_SERVER = $HTTP_SERVER_VARS; $_GET = $HTTP_GET_VARS; } @@ -37,15 +41,6 @@ function SendSaveAsFileHeaderIfNeeded() { return true; } -function PasswordStrength($password) { - $strength = 0; - $strength += strlen(preg_replace('#[^a-z]#', '', $password)) * 0.5; // lowercase characters are weak - $strength += strlen(preg_replace('#[^A-Z]#', '', $password)) * 0.8; // uppercase characters are somewhat better - $strength += strlen(preg_replace('#[^0-9]#', '', $password)) * 1.0; // numbers are somewhat better - $strength += strlen(preg_replace('#[a-zA-Z0-9]#', '', $password)) * 2.0; // other non-alphanumeric characters are best - return $strength; -} - function RedirectToCachedFile() { global $phpThumb; @@ -65,7 +60,7 @@ function RedirectToCachedFile() { $phpThumb->DebugTimingMessage('skipped using cached image', __FILE__, __LINE__); $phpThumb->DebugMessage('Would have used cached file, but skipping due to phpThumbDebug', __FILE__, __LINE__); $phpThumb->DebugMessage('* Would have sent headers (1): Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT', __FILE__, __LINE__); - if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) { + if ($getimagesize = @getimagesize($phpThumb->cache_filename)) { $phpThumb->DebugMessage('* Would have sent headers (2): Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]), __FILE__, __LINE__); } if (preg_match('#^'.preg_quote($nice_docroot).'(.*)$#', $nice_cachefile, $matches)) { @@ -82,16 +77,17 @@ function RedirectToCachedFile() { } SendSaveAsFileHeaderIfNeeded(); - header('Cache-Control: private'); header('Pragma: private'); - header('Expires: '.date(DATE_RFC822, strtotime(' 1 day'))); + header('Cache-Control: max-age='.$phpThumb->getParameter('config_cache_maxage')); + header('Expires: '.date(DATE_RFC1123, time() + $phpThumb->getParameter('config_cache_maxage'))); if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) && ($nModified == strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) && !empty($_SERVER['SERVER_PROTOCOL'])) { header('Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT'); header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified'); exit; } header('Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT'); - if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) { + header('ETag: "'.md5_file($phpThumb->cache_filename).'"'); + if ($getimagesize = @getimagesize($phpThumb->cache_filename)) { header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2])); } elseif (preg_match('#\\.ico$#i', $phpThumb->cache_filename)) { header('Content-Type: image/x-icon'); @@ -119,7 +115,7 @@ function RedirectToCachedFile() { ob_end_clean(); $phpThumb = new phpThumb(); $phpThumb->DebugTimingMessage('phpThumb.php start', __FILE__, __LINE__, $starttime); -$phpThumb->SetParameter('config_error_die_on_error', true); +$phpThumb->setParameter('config_error_die_on_error', true); if (!phpthumb_functions::FunctionIsDisabled('set_time_limit')) { set_time_limit(60); // shouldn't take nearly this long in most cases, but with many filters and/or a slow server... @@ -198,7 +194,7 @@ function RedirectToCachedFile() { if (empty($_GET['hash'])) { $phpThumb->config_disable_debug = false; // otherwise error message won't print $phpThumb->ErrorImage('ERROR: missing hash'); - } elseif (PasswordStrength($phpThumb->config_high_security_password) < 20) { + } elseif (phpthumb_functions::PasswordStrength($phpThumb->config_high_security_password) < 20) { $phpThumb->config_disable_debug = false; // otherwise error message won't print $phpThumb->ErrorImage('ERROR: $PHPTHUMB_CONFIG[high_security_password] is not complex enough'); } elseif ($_GET['hash'] != md5(str_replace($phpThumb->config_high_security_url_separator.'hash='.$_GET['hash'], '', $_SERVER['QUERY_STRING']).$phpThumb->config_high_security_password)) { @@ -237,6 +233,7 @@ function RedirectToCachedFile() { } if (!empty($_GET['src']) && isset($_GET['md5s']) && empty($_GET['md5s'])) { + $md5s = ''; if (preg_match('#^([a-z0-9]+)://#i', $_GET['src'], $protocol_matches)) { if (preg_match('#^(f|ht)tps?://#i', $_GET['src'])) { if ($rawImageData = phpthumb_functions::SafeURLread($_GET['src'], $error, $phpThumb->config_http_fopen_timeout, $phpThumb->config_http_follow_redirect)) { @@ -282,33 +279,88 @@ function RedirectToCachedFile() { } if ($phpThumb->config_mysql_query) { - if ($cid = @mysql_connect($phpThumb->config_mysql_hostname, $phpThumb->config_mysql_username, $phpThumb->config_mysql_password)) { - if (@mysql_select_db($phpThumb->config_mysql_database, $cid)) { - if ($result = @mysql_query($phpThumb->config_mysql_query, $cid)) { - if ($row = @mysql_fetch_array($result)) { + if ($phpThumb->config_mysql_extension == 'mysqli') { - mysql_free_result($result); - mysql_close($cid); - $phpThumb->setSourceData($row[0]); - unset($row); + $found_missing_function = false; + foreach (array('mysqli_connect') as $required_mysqli_function) { + if (!function_exists($required_mysqli_function)) { + $found_missing_function = $required_mysqli_function; + break; + } + } + if ($found_missing_function) { + $phpThumb->ErrorImage('SQL function unavailable: '.$found_missing_function); + } else { + $mysqli = new mysqli($phpThumb->config_mysql_hostname, $phpThumb->config_mysql_username, $phpThumb->config_mysql_password, $phpThumb->config_mysql_database); + if ($mysqli->connect_error) { + $phpThumb->ErrorImage('MySQLi connect error ('.$mysqli->connect_errno.') '.$mysqli->connect_error); + } else { + if ($result = $mysqli->query($phpThumb->config_mysql_query)) { + if ($row = $result->fetch_array()) { + + $result->free(); + $mysqli->close(); + $phpThumb->setSourceData($row[0]); + unset($row); + + } else { + $result->free(); + $mysqli->close(); + $phpThumb->ErrorImage('no matching data in database.'); + } + } else { + $mysqli->close(); + $phpThumb->ErrorImage('Error in MySQL query: "'.$mysqli->error.'"'); + } + } + unset($_GET['id']); + } + + } elseif ($phpThumb->config_mysql_extension == 'mysql') { + $found_missing_function = false; + //foreach (array('mysql_connect', 'mysql_select_db', 'mysql_query', 'mysql_fetch_array', 'mysql_free_result', 'mysql_close', 'mysql_error') as $required_mysql_function) { + foreach (array('mysql_connect') as $required_mysql_function) { + if (!function_exists($required_mysql_function)) { + $found_missing_function = $required_mysql_function; + break; + } + } + if ($found_missing_function) { + $phpThumb->ErrorImage('SQL function unavailable: '.$found_missing_function); + } else { + if ($cid = @mysql_connect($phpThumb->config_mysql_hostname, $phpThumb->config_mysql_username, $phpThumb->config_mysql_password)) { + if (@mysql_select_db($phpThumb->config_mysql_database, $cid)) { + if ($result = @mysql_query($phpThumb->config_mysql_query, $cid)) { + if ($row = @mysql_fetch_array($result)) { + + mysql_free_result($result); + mysql_close($cid); + $phpThumb->setSourceData($row[0]); + unset($row); + + } else { + mysql_free_result($result); + mysql_close($cid); + $phpThumb->ErrorImage('no matching data in database.'); + } + } else { + mysql_close($cid); + $phpThumb->ErrorImage('Error in MySQL query: "'.mysql_error($cid).'"'); + } } else { - mysql_free_result($result); mysql_close($cid); - $phpThumb->ErrorImage('no matching data in database.'); + $phpThumb->ErrorImage('cannot select MySQL database: "'.mysql_error($cid).'"'); } } else { - mysql_close($cid); - $phpThumb->ErrorImage('Error in MySQL query: "'.mysql_error($cid).'"'); + $phpThumb->ErrorImage('cannot connect to MySQL server'); } - } else { - mysql_close($cid); - $phpThumb->ErrorImage('cannot select MySQL database: "'.mysql_error($cid).'"'); + unset($_GET['id']); } + } else { - $phpThumb->ErrorImage('cannot connect to MySQL server'); + $phpThumb->ErrorImage('config_mysql_extension not supported'); } - unset($_GET['id']); } //////////////////////////////////////////////////////////////// @@ -436,8 +488,8 @@ function RedirectToCachedFile() { $SourceFilename = $phpThumb->ResolveFilenameToAbsolute($phpThumb->src); // security and size checks - if ($phpThumb->getimagesizeinfo = @GetImageSize($SourceFilename)) { - $phpThumb->DebugMessage('Direct passthru GetImageSize() returned [w='.$phpThumb->getimagesizeinfo[0].';h='.$phpThumb->getimagesizeinfo[1].';t='.$phpThumb->getimagesizeinfo[2].']', __FILE__, __LINE__); + if ($phpThumb->getimagesizeinfo = @getimagesize($SourceFilename)) { + $phpThumb->DebugMessage('Direct passthru getimagesize() returned [w='.$phpThumb->getimagesizeinfo[0].';h='.$phpThumb->getimagesizeinfo[1].';t='.$phpThumb->getimagesizeinfo[2].']', __FILE__, __LINE__); if (!@$_GET['w'] && !@$_GET['wp'] && !@$_GET['wl'] && !@$_GET['ws'] && !@$_GET['h'] && !@$_GET['hp'] && !@$_GET['hl'] && !@$_GET['hs']) { // no resizing needed @@ -461,8 +513,9 @@ function RedirectToCachedFile() { break 2; } - $ImageCreateFunctions = array(1=>'ImageCreateFromGIF', 2=>'ImageCreateFromJPEG', 3=>'ImageCreateFromPNG'); + $ImageCreateFunctions = array(1=>'imagecreatefromgif', 2=>'imagecreatefromjpeg', 3=>'imagecreatefrompng'); $theImageCreateFunction = @$ImageCreateFunctions[$phpThumb->getimagesizeinfo[2]]; + $dummyImage = false; if ($phpThumb->config_disable_onlycreateable_passthru || (function_exists($theImageCreateFunction) && ($dummyImage = @$theImageCreateFunction($SourceFilename)))) { // great @@ -474,7 +527,7 @@ function RedirectToCachedFile() { $phpThumb->ErrorImage('Headers already sent ('.basename(__FILE__).' line '.__LINE__.')'); exit; } - if (@$_GET['phpThumbDebug']) { + if (!empty($_GET['phpThumbDebug'])) { $phpThumb->DebugTimingMessage('skipped direct $SourceFilename passthru', __FILE__, __LINE__); $phpThumb->DebugMessage('Would have passed "'.$SourceFilename.'" through directly, but skipping due to phpThumbDebug', __FILE__, __LINE__); break; @@ -494,7 +547,7 @@ function RedirectToCachedFile() { } } else { - $phpThumb->DebugMessage('Not passing "'.$SourceFilename.'" through directly because GetImageSize() failed', __FILE__, __LINE__); + $phpThumb->DebugMessage('Not passing "'.$SourceFilename.'" through directly because getimagesize() failed', __FILE__, __LINE__); break; } break; @@ -543,11 +596,11 @@ function RedirectToCachedFile() { $alpha = (100 - min(100, max(0, $opacity))) * 1.27; if ($alpha) { $phpThumb->setParameter('is_alpha', true); - ImageAlphaBlending($phpThumb->gdimg_source, false); - ImageSaveAlpha($phpThumb->gdimg_source, true); + imagealphablending($phpThumb->gdimg_source, false); + imagesavealpha($phpThumb->gdimg_source, true); } $new_background_color = phpthumb_functions::ImageHexColorAllocate($phpThumb->gdimg_source, $bghexcolor, false, $alpha); - ImageFilledRectangle($phpThumb->gdimg_source, 0, 0, $phpThumb->w, $phpThumb->h, $new_background_color); + imagefilledrectangle($phpThumb->gdimg_source, 0, 0, $phpThumb->w, $phpThumb->h, $new_background_color); } else { $phpThumb->ErrorImage('failed to create "new" image ('.$phpThumb->w.'x'.$phpThumb->h.')'); } @@ -643,5 +696,3 @@ function RedirectToCachedFile() { $phpThumb->phpThumbDebug(); } //////////////////////////////////////////////////////////////// - -?> diff --git a/external/phpThumb/phpthumb.bmp.php b/external/phpThumb/phpthumb.bmp.php index 82d9ba3912..5b8862bb6c 100644 --- a/external/phpThumb/phpthumb.bmp.php +++ b/external/phpThumb/phpthumb.bmp.php @@ -20,10 +20,6 @@ class phpthumb_bmp { - function __construct() { - return true; - } - function phpthumb_bmp2gd(&$BMPdata, $truecolor=true) { $ThisFileInfo = array(); if ($this->getid3_bmp($BMPdata, $ThisFileInfo, true, true)) { @@ -43,8 +39,8 @@ function phpthumb_bmpfile2gd($filename, $truecolor=true) { } function GD2BMPstring(&$gd_image) { - $imageX = ImageSX($gd_image); - $imageY = ImageSY($gd_image); + $imageX = imagesx($gd_image); + $imageY = imagesy($gd_image); $BMP = ''; for ($y = ($imageY - 1); $y >= 0; $y--) { @@ -85,11 +81,11 @@ function GD2BMPstring(&$gd_image) { function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $ExtractData=false) { - // shortcuts - $ThisFileInfo['bmp']['header']['raw'] = array(); - $thisfile_bmp = &$ThisFileInfo['bmp']; - $thisfile_bmp_header = &$thisfile_bmp['header']; - $thisfile_bmp_header_raw = &$thisfile_bmp_header['raw']; + // shortcuts + $ThisFileInfo['bmp']['header']['raw'] = array(); + $thisfile_bmp = &$ThisFileInfo['bmp']; + $thisfile_bmp_header = &$thisfile_bmp['header']; + $thisfile_bmp_header_raw = &$thisfile_bmp_header['raw']; // BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp // all versions @@ -252,9 +248,9 @@ function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $ExtractDa // DWORD biClrUsed; // DWORD biClrImportant; - $thisfile_bmp_header_raw['width'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4), true); + $thisfile_bmp_header_raw['width'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4)); $offset += 4; - $thisfile_bmp_header_raw['height'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4), true); + $thisfile_bmp_header_raw['height'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4)); $offset += 4; $thisfile_bmp_header_raw['planes'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2)); $offset += 2; @@ -264,9 +260,9 @@ function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $ExtractDa $offset += 4; $thisfile_bmp_header_raw['bmp_data_size'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4)); $offset += 4; - $thisfile_bmp_header_raw['resolution_h'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4), true); + $thisfile_bmp_header_raw['resolution_h'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4)); $offset += 4; - $thisfile_bmp_header_raw['resolution_v'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4), true); + $thisfile_bmp_header_raw['resolution_v'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4)); $offset += 4; $thisfile_bmp_header_raw['colors_used'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4)); $offset += 4; @@ -591,7 +587,7 @@ function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $ExtractDa // of color indexes that follow. Subsequent bytes contain color indexes in their // high- and low-order 4 bits, one color index for each pixel. In absolute mode, // each run must be aligned on a word boundary. - unset($paletteindexes); + $paletteindexes = array(); for ($i = 0; $i < ceil($secondbyte / 2); $i++) { $paletteindexbyte = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1)); $paletteindexes[] = ($paletteindexbyte & 0xF0) >> 4; @@ -706,23 +702,23 @@ function PlotPixelsGD(&$BMPdata, $truecolor=true) { if ($truecolor) { - $gd = @ImageCreateTrueColor($imagewidth, $imageheight); + $gd = @imagecreatetruecolor($imagewidth, $imageheight); } else { - $gd = @ImageCreate($imagewidth, $imageheight); + $gd = @imagecreate($imagewidth, $imageheight); if (!empty($BMPdata['palette'])) { // create GD palette from BMP palette foreach ($BMPdata['palette'] as $dummy => $color) { list($r, $g, $b) = $this->IntColor2RGB($color); - ImageColorAllocate($gd, $r, $g, $b); + imagecolorallocate($gd, $r, $g, $b); } } else { // create 216-color websafe palette for ($r = 0x00; $r <= 0xFF; $r += 0x33) { for ($g = 0x00; $g <= 0xFF; $g += 0x33) { for ($b = 0x00; $b <= 0xFF; $b += 0x33) { - ImageColorAllocate($gd, $r, $g, $b); + imagecolorallocate($gd, $r, $g, $b); } } } @@ -740,11 +736,11 @@ function PlotPixelsGD(&$BMPdata, $truecolor=true) { foreach ($colarray as $col => $color) { list($red, $green, $blue) = $this->IntColor2RGB($color); if ($truecolor) { - $pixelcolor = ImageColorAllocate($gd, $red, $green, $blue); + $pixelcolor = imagecolorallocate($gd, $red, $green, $blue); } else { - $pixelcolor = ImageColorClosest($gd, $red, $green, $blue); + $pixelcolor = imagecolorclosest($gd, $red, $green, $blue); } - ImageSetPixel($gd, $col, $row, $pixelcolor); + imagesetpixel($gd, $col, $row, $pixelcolor); } } return $gd; @@ -762,15 +758,13 @@ function PlotBMP(&$BMPinfo) { $im = $this->PlotPixelsGD($BMPinfo['bmp']); if (headers_sent()) { echo 'plotted '.($BMPinfo['resolution_x'] * $BMPinfo['resolution_y']).' pixels in '.(time() - $starttime).' seconds
'; - ImageDestroy($im); + imagedestroy($im); exit; - } else { - header('Content-Type: image/png'); - ImagePNG($im); - ImageDestroy($im); - return true; } - return false; + header('Content-Type: image/png'); + imagepng($im); + imagedestroy($im); + return true; } function BMPcompressionWindowsLookup($compressionid) { @@ -874,5 +868,3 @@ function CastAsInt($floatnum) { } } - -?> \ No newline at end of file diff --git a/external/phpThumb/phpthumb.class.php b/external/phpThumb/phpthumb.class.php index dcce7bed77..8a9d2726ce 100644 --- a/external/phpThumb/phpthumb.class.php +++ b/external/phpThumb/phpthumb.class.php @@ -12,7 +12,7 @@ ob_start(); if (!include_once(dirname(__FILE__).'/phpthumb.functions.php')) { ob_end_flush(); - die('failed to include_once("'.realpath(dirname(__FILE__).'/phpthumb.functions.php').'")'); + die('failed to include_once("'.dirname(__FILE__).'/phpthumb.functions.php")'); } ob_end_clean(); @@ -130,6 +130,7 @@ class phpthumb { var $config_cache_prefix = ''; // default value set in the constructor below // * MySQL + var $config_mysql_extension = null; var $config_mysql_query = null; var $config_mysql_hostname = null; var $config_mysql_username = null; @@ -145,6 +146,8 @@ class phpthumb { var $config_allow_src_above_phpthumb = true; var $config_auto_allow_symlinks = true; // allow symlink target directories without explicitly whitelisting them var $config_additional_allowed_dirs = array(); // additional directories to allow source images to be read from + var $config_file_create_mask = 0755; + var $config_dir_create_mask = 0755; // * HTTP fopen var $config_http_fopen_timeout = 10; @@ -154,6 +157,7 @@ class phpthumb { var $config_disable_pathinfo_parsing = false; var $config_disable_imagecopyresampled = false; var $config_disable_onlycreateable_passthru = false; + var $config_disable_realpath = false; var $config_http_user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7'; @@ -207,18 +211,37 @@ class phpthumb { var $AlphaCapableFormats = array('png', 'ico', 'gif'); var $is_alpha = false; - var $iswindows = null; - var $issafemode = null; + var $iswindows = null; + var $issafemode = null; + var $php_memory_limit = null; - var $phpthumb_version = '1.7.14-201503301816'; + var $phpthumb_version = '1.7.14-201608101311'; ////////////////////////////////////////////////////////////////////// // public: constructor function __construct() { + $this->phpThumb(); + } + + function phpThumb() { $this->DebugTimingMessage('phpThumb() constructor', __FILE__, __LINE__); $this->DebugMessage('phpThumb() v'.$this->phpthumb_version, __FILE__, __LINE__); - $this->config_max_source_pixels = round(max(intval(ini_get('memory_limit')), intval(get_cfg_var('memory_limit'))) * 1048576 * 0.20); // 20% of memory_limit + + foreach (array(ini_get('memory_limit'), get_cfg_var('memory_limit')) as $php_config_memory_limit) { + if (strlen($php_config_memory_limit)) { + if (substr($php_config_memory_limit, -1, 1) == 'G') { // PHP memory limit expressed in Gigabytes + $php_config_memory_limit = intval(substr($php_config_memory_limit, 0, -1)) * 1073741824; + } elseif (substr($php_config_memory_limit, -1, 1) == 'M') { // PHP memory limit expressed in Megabytes + $php_config_memory_limit = intval(substr($php_config_memory_limit, 0, -1)) * 1048576; + } + $this->php_memory_limit = max($this->php_memory_limit, $php_config_memory_limit); + } + } + if ($this->php_memory_limit > 0) { // could be "-1" for "no limit" + $this->config_max_source_pixels = round($this->php_memory_limit * 0.20); // 20% of memory_limit + } + $this->iswindows = (bool) (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'); $this->issafemode = (bool) preg_match('#(1|ON)#i', ini_get('safe_mode')); $this->config_document_root = (!empty($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : $this->config_document_root); @@ -401,8 +424,8 @@ function GenerateThumbnail() { ); $this->DebugMessage('memory_get_usage() after copy-resize = '.(function_exists('memory_get_usage') ? @memory_get_usage() : 'n/a'), __FILE__, __LINE__); - ImageDestroy($this->gdimg_source); - $this->DebugMessage('memory_get_usage() after ImageDestroy = '.(function_exists('memory_get_usage') ? @memory_get_usage() : 'n/a'), __FILE__, __LINE__); + imagedestroy($this->gdimg_source); + $this->DebugMessage('memory_get_usage() after imagedestroy = '.(function_exists('memory_get_usage') ? @memory_get_usage() : 'n/a'), __FILE__, __LINE__); $this->phpThumbDebug('8i'); $this->AntiOffsiteLinking(); @@ -436,18 +459,18 @@ function RenderOutput() { } $builtin_formats = array(); - if (function_exists('ImageTypes')) { - $imagetypes = ImageTypes(); + if (function_exists('imagetypes')) { + $imagetypes = imagetypes(); $builtin_formats['wbmp'] = (bool) ($imagetypes & IMG_WBMP); $builtin_formats['jpg'] = (bool) ($imagetypes & IMG_JPG); $builtin_formats['gif'] = (bool) ($imagetypes & IMG_GIF); $builtin_formats['png'] = (bool) ($imagetypes & IMG_PNG); } - $this->DebugMessage('ImageInterlace($this->gdimg_output, '.intval($this->config_output_interlace).')', __FILE__, __LINE__); - ImageInterlace($this->gdimg_output, intval($this->config_output_interlace)); + $this->DebugMessage('imageinterlace($this->gdimg_output, '.intval($this->config_output_interlace).')', __FILE__, __LINE__); + imageinterlace($this->gdimg_output, intval($this->config_output_interlace)); - $this->DebugMessage('RenderOutput() attempting Image'.strtoupper(@$this->thumbnailFormat).'($this->gdimg_output)', __FILE__, __LINE__); + $this->DebugMessage('RenderOutput() attempting image'.strtolower(@$this->thumbnailFormat).'($this->gdimg_output)', __FILE__, __LINE__); ob_start(); switch ($this->thumbnailFormat) { case 'wbmp': @@ -456,7 +479,7 @@ function RenderOutput() { ob_end_clean(); return false; } - ImageJPEG($this->gdimg_output, null, $this->thumbnailQuality); + imagejpeg($this->gdimg_output, null, $this->thumbnailQuality); $this->outputImageData = ob_get_contents(); break; @@ -467,7 +490,7 @@ function RenderOutput() { ob_end_clean(); return false; } - ImageJPEG($this->gdimg_output, null, $this->thumbnailQuality); + imagejpeg($this->gdimg_output, null, $this->thumbnailQuality); $this->outputImageData = ob_get_contents(); break; @@ -494,9 +517,9 @@ function RenderOutput() { $this->DebugMessage('Specified thumbnailQuality "'.$this->thumbnailQuality.'" is outside the accepted range (0-9, or -1). Using 6 as default value.', __FILE__, __LINE__); $PNGquality = 6; } - ImagePNG($this->gdimg_output, null, $PNGquality); + imagepng($this->gdimg_output, null, $PNGquality); } else { - ImagePNG($this->gdimg_output); + imagepng($this->gdimg_output); } $this->outputImageData = ob_get_contents(); break; @@ -507,12 +530,11 @@ function RenderOutput() { ob_end_clean(); return false; } - ImageGIF($this->gdimg_output); + imagegif($this->gdimg_output); $this->outputImageData = ob_get_contents(); break; case 'bmp': - $ImageOutFunction = '"builtin BMP output"'; if (!@include_once(dirname(__FILE__).'/phpthumb.bmp.php')) { $this->DebugMessage('Error including "'.dirname(__FILE__).'/phpthumb.bmp.php" which is required for BMP format output', __FILE__, __LINE__); ob_end_clean(); @@ -524,7 +546,6 @@ function RenderOutput() { break; case 'ico': - $ImageOutFunction = '"builtin ICO output"'; if (!@include_once(dirname(__FILE__).'/phpthumb.ico.php')) { $this->DebugMessage('Error including "'.dirname(__FILE__).'/phpthumb.ico.php" which is required for ICO format output', __FILE__, __LINE__); ob_end_clean(); @@ -575,6 +596,7 @@ function RenderToFile($filename) { if ($this->RenderOutput()) { if (file_put_contents($renderfilename, $this->outputImageData)) { + @chmod($renderfilename, $this->getParameter('config_file_create_mask')); $this->DebugMessage('RenderToFile('.$renderfilename.') succeeded', __FILE__, __LINE__); return true; } @@ -598,7 +620,6 @@ function OutputThumbnail() { } if (headers_sent()) { return $this->ErrorImage('OutputThumbnail() failed - headers already sent'); - exit; } $downloadfilename = phpthumb_functions::SanitizeFilename(is_string($this->sia) ? $this->sia : ($this->down ? $this->down : 'phpThumb_generated_thumbnail'.'.'.$this->thumbnailFormat)); @@ -616,8 +637,8 @@ function OutputThumbnail() { } else { - $this->DebugMessage('ImageInterlace($this->gdimg_output, '.intval($this->config_output_interlace).')', __FILE__, __LINE__); - ImageInterlace($this->gdimg_output, intval($this->config_output_interlace)); + $this->DebugMessage('imageinterlace($this->gdimg_output, '.intval($this->config_output_interlace).')', __FILE__, __LINE__); + imageinterlace($this->gdimg_output, intval($this->config_output_interlace)); switch ($this->thumbnailFormat) { case 'jpeg': header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat)); @@ -819,9 +840,9 @@ function CleanUpCacheDirectory() { $empty_dirs = array(); foreach ($AllFilesInCacheDirectory as $fullfilename) { if (is_dir($fullfilename)) { - $empty_dirs[realpath($fullfilename)] = 1; + $empty_dirs[$this->realPathSafe($fullfilename)] = 1; } else { - unset($empty_dirs[realpath(dirname($fullfilename))]); + unset($empty_dirs[$this->realPathSafe(dirname($fullfilename))]); } } krsort($empty_dirs); @@ -916,8 +937,8 @@ function setOutputFormat() { $this->thumbnailFormat = 'ico'; // Set default output format based on what image types are available - if (function_exists('ImageTypes')) { - $imagetypes = ImageTypes(); + if (function_exists('imagetypes')) { + $imagetypes = imagetypes(); if ($imagetypes & IMG_WBMP) { $this->thumbnailFormat = 'wbmp'; $AvailableImageOutputFormats[] = 'wbmp'; @@ -935,8 +956,7 @@ function setOutputFormat() { $AvailableImageOutputFormats[] = 'jpeg'; } } else { - //return $this->ErrorImage('ImageTypes() does not exist - GD support might not be enabled?'); - $this->DebugMessage('ImageTypes() does not exist - GD support might not be enabled?', __FILE__, __LINE__); + $this->DebugMessage('imagetypes() does not exist - GD support might not be enabled?', __FILE__, __LINE__); } if ($this->ImageMagickVersion()) { $IMformats = array('jpeg', 'png', 'gif', 'bmp', 'ico', 'wbmp'); @@ -1002,15 +1022,15 @@ function setCacheDirectory() { $this->config_cache_directory = str_replace('/', DIRECTORY_SEPARATOR, $this->config_cache_directory); } if ($this->config_cache_directory) { - $real_cache_path = realpath($this->config_cache_directory); + $real_cache_path = $this->realPathSafe($this->config_cache_directory); if (!$real_cache_path) { - $this->DebugMessage('realpath($this->config_cache_directory) failed for "'.$this->config_cache_directory.'"', __FILE__, __LINE__); + $this->DebugMessage('$this->realPathSafe($this->config_cache_directory) failed for "'.$this->config_cache_directory.'"', __FILE__, __LINE__); if (!is_dir($this->config_cache_directory)) { $this->DebugMessage('!is_dir('.$this->config_cache_directory.')', __FILE__, __LINE__); } } if ($real_cache_path) { - $this->DebugMessage('setting config_cache_directory to realpath('.$this->config_cache_directory.') = "'.$real_cache_path.'"', __FILE__, __LINE__); + $this->DebugMessage('setting config_cache_directory to $this->realPathSafe('.$this->config_cache_directory.') = "'.$real_cache_path.'"', __FILE__, __LINE__); $this->config_cache_directory = $real_cache_path; } } @@ -1089,7 +1109,7 @@ function normalizePath($segments) { function matchPath($path, $allowed_dirs) { if (!empty($allowed_dirs)) { foreach ($allowed_dirs as $one_dir) { - if (preg_match('#^'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', realpath($one_dir))).'#', $path)) { + if (preg_match('#^'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', $this->realPathSafe($one_dir))).'#', $path)) { return true; } } @@ -1107,7 +1127,7 @@ function isInOpenBasedir($path) { $open_basedirs = array(); if (strlen($ini_text) > 0) { foreach (preg_split('#[;:]#', $ini_text) as $key => $value) { - $open_basedirs[$key] = realpath($value); + $open_basedirs[$key] = $this->realPathSafe($value); } } } @@ -1121,14 +1141,14 @@ function resolvePath($path, $allowed_dirs) { // add base path to the top of the list if (!$this->config_allow_src_above_docroot) { - array_unshift($allowed_dirs, realpath($this->config_document_root)); + array_unshift($allowed_dirs, $this->realPathSafe($this->config_document_root)); } else { if (!$this->config_allow_src_above_phpthumb) { - array_unshift($allowed_dirs, realpath(dirname(__FILE__))); + array_unshift($allowed_dirs, $this->realPathSafe(dirname(__FILE__))); } else { // no checks are needed, offload the work to realpath and forget about it - $this->DebugMessage('resolvePath: checks disabled, returning '.realpath($path), __FILE__, __LINE__); - return realpath($path); + $this->DebugMessage('resolvePath: checks disabled, returning '.$this->realPathSafe($path), __FILE__, __LINE__); + return $this->realPathSafe($path); } } if ($path == '') { @@ -1143,7 +1163,7 @@ function resolvePath($path, $allowed_dirs) { // http://support.silisoftware.com/phpBB3/viewtopic.php?t=964 $segments = explode(DIRECTORY_SEPARATOR, $path); for ($i = 0; $i < count($segments); $i++) { - $this->applyPathSegment($parts, $segments[$i]); + $this->applyPathSegment($parts, $segments[$i]); $thispart = implode(DIRECTORY_SEPARATOR, $parts); if ($this->isInOpenBasedir($thispart)) { if (is_link($thispart)) { @@ -1186,6 +1206,45 @@ function resolvePath($path, $allowed_dirs) { return $path; } + + function realPathSafe($filename) { + // http://php.net/manual/en/function.realpath.php -- "Note: The running script must have executable permissions on all directories in the hierarchy, otherwise realpath() will return FALSE" + // realPathSafe() provides a reasonable facsimile of realpath() but does not resolve symbolic links, nor does it check that the file/path actually exists + if (!$this->config_disable_realpath) { + return realpath($filename); + } + + // http://stackoverflow.com/questions/21421569 + $newfilename = preg_replace('#[\\/]+#', DIRECTORY_SEPARATOR, $filename); + if (!preg_match('#^'.DIRECTORY_SEPARATOR.'#', $newfilename)) { + $newfilename = dirname(__FILE__).DIRECTORY_SEPARATOR.$newfilename; + } + do { + $beforeloop = $newfilename; + + // Replace all sequences of more than one / with a single one [[ If you're working on a system that treats // at the start of a path as special, make sure you replace multiple / characters at the start with two of them. This is the only place where POSIX allows (but does not mandate) special handling for multiples, in all other cases, multiple / characters are equivalent to a single one.]] + $newfilename = preg_replace('#'.DIRECTORY_SEPARATOR.'+#', DIRECTORY_SEPARATOR, $newfilename); + + // Replace all occurrences of /./ with / + $newfilename = preg_replace('#'.DIRECTORY_SEPARATOR.'\\.'.DIRECTORY_SEPARATOR.'#', DIRECTORY_SEPARATOR, $newfilename); + + // Remove ./ if at the start + $newfilename = preg_replace('#^\\.'.DIRECTORY_SEPARATOR.'#', '', $newfilename); + + // Remove /. if at the end + $newfilename = preg_replace('#'.DIRECTORY_SEPARATOR.'\\.$#', '', $newfilename); + + // Replace /anything/../ with / + $newfilename = preg_replace('#'.DIRECTORY_SEPARATOR.'[^'.DIRECTORY_SEPARATOR.']+'.DIRECTORY_SEPARATOR.'\\.\\.'.DIRECTORY_SEPARATOR.'#', DIRECTORY_SEPARATOR, $newfilename); + + // Remove /anything/.. if at the end + $newfilename = preg_replace('#'.DIRECTORY_SEPARATOR.'[^'.DIRECTORY_SEPARATOR.']+'.DIRECTORY_SEPARATOR.'\\.\\.$#', '', $newfilename); + + } while ($newfilename != $beforeloop); + return $newfilename; + } + + function ResolveFilenameToAbsolute($filename) { if (empty($filename)) { return false; @@ -1222,11 +1281,11 @@ function ResolveFilenameToAbsolute($filename) { if ($ApacheLookupURIarray = phpthumb_functions::ApacheLookupURIarray($filename)) { $AbsoluteFilename = $ApacheLookupURIarray['filename']; } else { - $AbsoluteFilename = realpath($filename); + $AbsoluteFilename = $this->realPathSafe($filename); if (@is_readable($AbsoluteFilename)) { - $this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.$filename.'", but the correct filename ('.$AbsoluteFilename.') seems to have been resolved with realpath($filename)', __FILE__, __LINE__); + $this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.$filename.'", but the correct filename ('.$AbsoluteFilename.') seems to have been resolved with $this->realPathSafe($filename)', __FILE__, __LINE__); } elseif (is_dir(dirname($AbsoluteFilename))) { - $this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.dirname($filename).'", but the correct directory ('.dirname($AbsoluteFilename).') seems to have been resolved with realpath(.)', __FILE__, __LINE__); + $this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.dirname($filename).'", but the correct directory ('.dirname($AbsoluteFilename).') seems to have been resolved with $this->realPathSafe(.)', __FILE__, __LINE__); } else { return $this->ErrorImage('phpthumb_functions::ApacheLookupURIarray() failed for "'.$filename.'". This has been known to fail on Apache2 - try using the absolute filename for the source image (ex: "/home/user/httpdocs/image.jpg" instead of "/~user/image.jpg")'); } @@ -1254,11 +1313,11 @@ function ResolveFilenameToAbsolute($filename) { if ($ApacheLookupURIarray = phpthumb_functions::ApacheLookupURIarray(dirname(@$_SERVER['PHP_SELF']))) { $AbsoluteFilename = $ApacheLookupURIarray['filename'].DIRECTORY_SEPARATOR.$filename; } else { - $AbsoluteFilename = realpath('.').DIRECTORY_SEPARATOR.$filename; + $AbsoluteFilename = $this->realPathSafe('.').DIRECTORY_SEPARATOR.$filename; if (@is_readable($AbsoluteFilename)) { - $this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.dirname(@$_SERVER['PHP_SELF']).'", but the correct filename ('.$AbsoluteFilename.') seems to have been resolved with realpath(.)/$filename', __FILE__, __LINE__); + $this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.dirname(@$_SERVER['PHP_SELF']).'", but the correct filename ('.$AbsoluteFilename.') seems to have been resolved with $this->realPathSafe(.)/$filename', __FILE__, __LINE__); } elseif (is_dir(dirname($AbsoluteFilename))) { - $this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.dirname(@$_SERVER['PHP_SELF']).'", but the correct directory ('.dirname($AbsoluteFilename).') seems to have been resolved with realpath(.)', __FILE__, __LINE__); + $this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.dirname(@$_SERVER['PHP_SELF']).'", but the correct directory ('.dirname($AbsoluteFilename).') seems to have been resolved with $this->realPathSafe(.)', __FILE__, __LINE__); } else { return $this->ErrorImage('phpthumb_functions::ApacheLookupURIarray() failed for "'.dirname(@$_SERVER['PHP_SELF']).'". This has been known to fail on Apache2 - try using the absolute filename for the source image'); } @@ -1272,17 +1331,17 @@ function ResolveFilenameToAbsolute($filename) { $this->DebugMessage('is_link()==true, changing "'.$AbsoluteFilename.'" to "'.readlink($AbsoluteFilename).'"', __FILE__, __LINE__); $AbsoluteFilename = readlink($AbsoluteFilename); } - if (realpath($AbsoluteFilename)) { - $AbsoluteFilename = realpath($AbsoluteFilename); + if ($this->realPathSafe($AbsoluteFilename)) { + $AbsoluteFilename = $this->realPathSafe($AbsoluteFilename); } */ if ($this->iswindows) { - $AbsoluteFilename = preg_replace('#^'.preg_quote(realpath($this->config_document_root)).'#i', realpath($this->config_document_root), $AbsoluteFilename); + $AbsoluteFilename = preg_replace('#^'.preg_quote($this->realPathSafe($this->config_document_root)).'#i', str_replace('\\', '\\\\', $this->realPathSafe($this->config_document_root)), $AbsoluteFilename); $AbsoluteFilename = str_replace(DIRECTORY_SEPARATOR, '/', $AbsoluteFilename); } $AbsoluteFilename = $this->resolvePath($AbsoluteFilename, $this->config_additional_allowed_dirs); - if (!$this->config_allow_src_above_docroot && !preg_match('#^'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', realpath($this->config_document_root))).'#', $AbsoluteFilename)) { - $this->DebugMessage('!$this->config_allow_src_above_docroot therefore setting "'.$AbsoluteFilename.'" (outside "'.realpath($this->config_document_root).'") to null', __FILE__, __LINE__); + if (!$this->config_allow_src_above_docroot && !preg_match('#^'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', $this->realPathSafe($this->config_document_root))).'#', $AbsoluteFilename)) { + $this->DebugMessage('!$this->config_allow_src_above_docroot therefore setting "'.$AbsoluteFilename.'" (outside "'.$this->realPathSafe($this->config_document_root).'") to null', __FILE__, __LINE__); return false; } if (!$this->config_allow_src_above_phpthumb && !preg_match('#^'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__))).'#', $AbsoluteFilename)) { @@ -1326,6 +1385,7 @@ function ImageMagickWhichConvert() { } else { $WhichConvert = trim(phpthumb_functions::SafeExec('which convert')); @file_put_contents($IMwhichConvertCacheFilename, $WhichConvert); + @chmod($IMwhichConvertCacheFilename, $this->getParameter('config_file_create_mask')); } } } @@ -1348,12 +1408,12 @@ function ImageMagickCommandlineBase() { $commandline = (!is_null($this->config_imagemagick_path) ? $this->config_imagemagick_path : ''); - if ($this->config_imagemagick_path && ($this->config_imagemagick_path != realpath($this->config_imagemagick_path))) { - if (@is_executable(realpath($this->config_imagemagick_path))) { - $this->DebugMessage('Changing $this->config_imagemagick_path ('.$this->config_imagemagick_path.') to realpath($this->config_imagemagick_path) ('.realpath($this->config_imagemagick_path).')', __FILE__, __LINE__); - $this->config_imagemagick_path = realpath($this->config_imagemagick_path); + if ($this->config_imagemagick_path && ($this->config_imagemagick_path != $this->realPathSafe($this->config_imagemagick_path))) { + if (@is_executable($this->realPathSafe($this->config_imagemagick_path))) { + $this->DebugMessage('Changing $this->config_imagemagick_path ('.$this->config_imagemagick_path.') to $this->realPathSafe($this->config_imagemagick_path) ('.$this->realPathSafe($this->config_imagemagick_path).')', __FILE__, __LINE__); + $this->config_imagemagick_path = $this->realPathSafe($this->config_imagemagick_path); } else { - $this->DebugMessage('Leaving $this->config_imagemagick_path as ('.$this->config_imagemagick_path.') because !is_execuatable(realpath($this->config_imagemagick_path)) ('.realpath($this->config_imagemagick_path).')', __FILE__, __LINE__); + $this->DebugMessage('Leaving $this->config_imagemagick_path as ('.$this->config_imagemagick_path.') because !is_execuatable($this->realPathSafe($this->config_imagemagick_path)) ('.$this->realPathSafe($this->config_imagemagick_path).')', __FILE__, __LINE__); } } $this->DebugMessage(' file_exists('.$this->config_imagemagick_path.') = '.intval( @file_exists($this->config_imagemagick_path)), __FILE__, __LINE__); @@ -1398,6 +1458,7 @@ function ImageMagickCommandlineBase() { } @file_put_contents($IMcommandlineBaseCacheFilename, $commandline); + @chmod($IMcommandlineBaseCacheFilename, $this->getParameter('config_file_create_mask')); } return $commandline; } @@ -1424,7 +1485,7 @@ function ImageMagickVersion($returnRAW=false) { $this->DebugMessage('ImageMagick version checked with "'.$commandline.'"', __FILE__, __LINE__); $versionstring[1] = trim(phpthumb_functions::SafeExec($commandline)); if (preg_match('#^Version: [^0-9]*([ 0-9\\.\\:Q/\\-]+)#i', $versionstring[1], $matches)) { - $versionstring[0] = $matches[1]; + $versionstring[0] = trim($matches[1]); } else { $versionstring[0] = false; $this->DebugMessage('ImageMagick did not return recognized version string ('.$versionstring[1].')', __FILE__, __LINE__); @@ -1433,6 +1494,7 @@ function ImageMagickVersion($returnRAW=false) { } @file_put_contents($IMversionCacheFilename, $versionstring[0]."\n".$versionstring[1]); + @chmod($IMversionCacheFilename, $this->getParameter('config_file_create_mask')); } } @@ -1489,7 +1551,7 @@ function ImageMagickFormatsList() { function SourceDataToTempFile() { if ($IMtempSourceFilename = $this->phpThumb_tempnam()) { - $IMtempSourceFilename = realpath($IMtempSourceFilename); + $IMtempSourceFilename = $this->realPathSafe($IMtempSourceFilename); ob_start(); $fp_tempfile = fopen($IMtempSourceFilename, 'wb'); $tempfile_open_error = ob_get_contents(); @@ -1497,6 +1559,7 @@ function SourceDataToTempFile() { if ($fp_tempfile) { fwrite($fp_tempfile, $this->rawImageData); fclose($fp_tempfile); + @chmod($IMtempSourceFilename, $this->getParameter('config_file_create_mask')); $this->sourceFilename = $IMtempSourceFilename; $this->DebugMessage('ImageMagickThumbnailToGD() setting $this->sourceFilename to "'.$IMtempSourceFilename.'" from $this->rawImageData ('.strlen($this->rawImageData).' bytes)', __FILE__, __LINE__); } else { @@ -1520,7 +1583,7 @@ function ImageMagickThumbnailToGD() { // $UnAllowedParameters contains options that can only be processed in GD, not ImageMagick // note: 'fltr' *may* need to be processed by GD, but we'll check that in more detail below $UnAllowedParameters = array('xto', 'ar', 'bg', 'bc'); - // 'ra' may be part of this list, if not a multiple of 90� + // 'ra' may be part of this list, if not a multiple of 90 degrees foreach ($UnAllowedParameters as $parameter) { if (isset($this->$parameter)) { $this->DebugMessage('$this->useRawIMoutput=false because "'.$parameter.'" is set', __FILE__, __LINE__); @@ -1530,39 +1593,40 @@ function ImageMagickThumbnailToGD() { } } $this->DebugMessage('$this->useRawIMoutput='.($this->useRawIMoutput ? 'true' : 'false').' after checking $UnAllowedParameters', __FILE__, __LINE__); + $ImageCreateFunction = ''; $outputFormat = $this->thumbnailFormat; if (phpthumb_functions::gd_version()) { if ($this->useRawIMoutput) { switch ($this->thumbnailFormat) { case 'gif': - $ImageCreateFunction = 'ImageCreateFromGIF'; + $ImageCreateFunction = 'imagecreatefromgif'; $this->is_alpha = true; break; case 'png': - $ImageCreateFunction = 'ImageCreateFromPNG'; + $ImageCreateFunction = 'imagecreatefrompng'; $this->is_alpha = true; break; case 'jpg': case 'jpeg': - $ImageCreateFunction = 'ImageCreateFromJPEG'; + $ImageCreateFunction = 'imagecreatefromjpeg'; break; default: $this->DebugMessage('Forcing output to PNG because $this->thumbnailFormat ('.$this->thumbnailFormat.' is not a GD-supported format)', __FILE__, __LINE__); $outputFormat = 'png'; - $ImageCreateFunction = 'ImageCreateFromPNG'; + $ImageCreateFunction = 'imagecreatefrompng'; $this->is_alpha = true; $this->useRawIMoutput = false; break; } if (!function_exists(@$ImageCreateFunction)) { - // ImageMagickThumbnailToGD() depends on ImageCreateFromPNG/ImageCreateFromGIF + // ImageMagickThumbnailToGD() depends on imagecreatefrompng/imagecreatefromgif //$this->DebugMessage('ImageMagickThumbnailToGD() aborting because '.@$ImageCreateFunction.'() is not available', __FILE__, __LINE__); $this->useRawIMoutput = true; //return false; } } else { $outputFormat = 'png'; - $ImageCreateFunction = 'ImageCreateFromPNG'; + $ImageCreateFunction = 'imagecreatefrompng'; $this->is_alpha = true; $this->useRawIMoutput = false; } @@ -1592,7 +1656,7 @@ function ImageMagickThumbnailToGD() { $commandline = $this->ImageMagickCommandlineBase(); if ($commandline) { if ($IMtempfilename = $this->phpThumb_tempnam()) { - $IMtempfilename = realpath($IMtempfilename); + $IMtempfilename = $this->realPathSafe($IMtempfilename); $IMuseExplicitImageOutputDimensions = false; if ($this->ImageMagickSwitchAvailable('thumbnail') && $this->config_imagemagick_use_thumbnail) { @@ -1608,25 +1672,27 @@ function ImageMagickThumbnailToGD() { if ($fp_im_temp = @fopen($IMtempfilename, 'wb')) { // erase temp image so ImageMagick logo doesn't get output if other processing fails fclose($fp_im_temp); + @chmod($IMtempfilename, $this->getParameter('config_file_create_mask')); } } if (!is_null($this->dpi) && $this->ImageMagickSwitchAvailable('density')) { - // for raster source formats only (WMF, PDF, etc) + // for vector source formats only (WMF, PDF, etc) + $commandline .= ' -flatten'; $commandline .= ' -density '.phpthumb_functions::escapeshellarg_replacement($this->dpi); } ob_start(); - $getimagesize = GetImageSize($this->sourceFilename); + $getimagesize = getimagesize($this->sourceFilename); $GetImageSizeError = ob_get_contents(); ob_end_clean(); if (is_array($getimagesize)) { - $this->DebugMessage('GetImageSize('.$this->sourceFilename.') SUCCEEDED: '.print_r($getimagesize, true), __FILE__, __LINE__); + $this->DebugMessage('getimagesize('.$this->sourceFilename.') SUCCEEDED: '.print_r($getimagesize, true), __FILE__, __LINE__); } else { - $this->DebugMessage('GetImageSize('.$this->sourceFilename.') FAILED with error "'.$GetImageSizeError.'"', __FILE__, __LINE__); + $this->DebugMessage('getimagesize('.$this->sourceFilename.') FAILED with error "'.$GetImageSizeError.'"', __FILE__, __LINE__); } if (is_array($getimagesize)) { - $this->DebugMessage('GetImageSize('.$this->sourceFilename.') returned [w='.$getimagesize[0].';h='.$getimagesize[1].';f='.$getimagesize[2].']', __FILE__, __LINE__); + $this->DebugMessage('getimagesize('.$this->sourceFilename.') returned [w='.$getimagesize[0].';h='.$getimagesize[1].';f='.$getimagesize[2].']', __FILE__, __LINE__); $this->source_width = $getimagesize[0]; $this->source_height = $getimagesize[1]; $this->DebugMessage('source dimensions set to '.$this->source_width.'x'.$this->source_height, __FILE__, __LINE__); @@ -1770,7 +1836,7 @@ function ImageMagickThumbnailToGD() { } else { - $this->DebugMessage('GetImageSize('.$this->sourceFilename.') failed', __FILE__, __LINE__); + $this->DebugMessage('getimagesize('.$this->sourceFilename.') failed', __FILE__, __LINE__); if ($this->w || $this->h) { $exactDimensionsBang = (($this->iar && (intval($this->w) > 0) && (intval($this->h) > 0)) ? '!' : ''); if ($IMuseExplicitImageOutputDimensions) { @@ -2188,13 +2254,13 @@ function ImageMagickThumbnailToGD() { unset($this->fltr[$filterkey]); } $this->IMresizedData = file_get_contents($IMtempfilename); - $getimagesize_imresized = @GetImageSize($IMtempfilename); - $this->DebugMessage('GetImageSize('.$IMtempfilename.') returned [w='.$getimagesize_imresized[0].';h='.$getimagesize_imresized[1].';f='.$getimagesize_imresized[2].']', __FILE__, __LINE__); + $getimagesize_imresized = @getimagesize($IMtempfilename); + $this->DebugMessage('getimagesize('.$IMtempfilename.') returned [w='.$getimagesize_imresized[0].';h='.$getimagesize_imresized[1].';f='.$getimagesize_imresized[2].']', __FILE__, __LINE__); if (($this->config_max_source_pixels > 0) && (($getimagesize_imresized[0] * $getimagesize_imresized[1]) > $this->config_max_source_pixels)) { $this->DebugMessage('skipping ImageMagickThumbnailToGD::'.$ImageCreateFunction.'() because IM output is too large ('.$getimagesize_imresized[0].'x'.$getimagesize_imresized[0].' = '.($getimagesize_imresized[0] * $getimagesize_imresized[1]).' > '.$this->config_max_source_pixels.')', __FILE__, __LINE__); } elseif (function_exists(@$ImageCreateFunction) && ($this->gdimg_source = @$ImageCreateFunction($IMtempfilename))) { - $this->source_width = ImageSX($this->gdimg_source); - $this->source_height = ImageSY($this->gdimg_source); + $this->source_width = imagesx($this->gdimg_source); + $this->source_height = imagesy($this->gdimg_source); $this->DebugMessage('ImageMagickThumbnailToGD::'.$ImageCreateFunction.'() succeeded, $this->gdimg_source is now ('.$this->source_width.'x'.$this->source_height.')', __FILE__, __LINE__); $this->DebugMessage('ImageMagickThumbnailToGD() returning $this->IMresizedData ('.strlen($this->IMresizedData).' bytes)', __FILE__, __LINE__); } else { @@ -2233,8 +2299,8 @@ function ImageMagickThumbnailToGD() { function Rotate() { if ($this->ra || $this->ar) { - if (!function_exists('ImageRotate')) { - $this->DebugMessage('!function_exists(ImageRotate)', __FILE__, __LINE__); + if (!function_exists('imagerotate')) { + $this->DebugMessage('!function_exists(imagerotate)', __FILE__, __LINE__); return false; } if (!include_once(dirname(__FILE__).'/phpthumb.filters.php')) { @@ -2310,9 +2376,9 @@ function Rotate() { if ($rotate_angle % 90) { $this->is_alpha = true; } - phpthumb_filters::ImprovedImageRotate($this->gdimg_source, $rotate_angle, $this->config_background_hexcolor, $this->bg); - $this->source_width = ImageSX($this->gdimg_source); - $this->source_height = ImageSY($this->gdimg_source); + phpthumb_filters::ImprovedImageRotate($this->gdimg_source, $rotate_angle, $this->config_background_hexcolor, $this->bg, $this); + $this->source_width = imagesx($this->gdimg_source); + $this->source_height = imagesy($this->gdimg_source); } return true; } @@ -2385,7 +2451,7 @@ function OffsiteDomainIsAllowed($hostname, $allowed_domains) { function AntiOffsiteLinking() { // Optional anti-offsite hijacking of the thumbnail script - $allow = true; + $allow = true; if ($allow && $this->config_nooffsitelink_enabled && (@$_SERVER['HTTP_REFERER'] || $this->config_nooffsitelink_require_refer)) { $this->DebugMessage('AntiOffsiteLinking() checking $_SERVER[HTTP_REFERER] "'.@$_SERVER['HTTP_REFERER'].'"', __FILE__, __LINE__); foreach ($this->config_nooffsitelink_valid_domains as $key => $valid_domain) { @@ -2395,9 +2461,7 @@ function AntiOffsiteLinking() { } $parsed_url = phpthumb_functions::ParseURLbetter(@$_SERVER['HTTP_REFERER']); if (!$this->OffsiteDomainIsAllowed(@$parsed_url['host'], $this->config_nooffsitelink_valid_domains)) { - $allow = false; - $erase = $this->config_nooffsitelink_erase_image; - $message = $this->config_nooffsitelink_text_message; + $allow = false; //$this->DebugMessage('AntiOffsiteLinking() - "'.@$parsed_url['host'].'" is NOT in $this->config_nooffsitelink_valid_domains ('.implode(';', $this->config_nooffsitelink_valid_domains).')', __FILE__, __LINE__); $this->ErrorImage('AntiOffsiteLinking() - "'.@$parsed_url['host'].'" is NOT in $this->config_nooffsitelink_valid_domains ('.implode(';', $this->config_nooffsitelink_valid_domains).')'); } else { @@ -2411,8 +2475,6 @@ function AntiOffsiteLinking() { if (!$this->OffsiteDomainIsAllowed(@$parsed_url['host'], $this->config_nohotlink_valid_domains)) { // This domain is not allowed $allow = false; - $erase = $this->config_nohotlink_erase_image; - $message = $this->config_nohotlink_text_message; $this->DebugMessage('AntiOffsiteLinking() - "'.$parsed_url['host'].'" is NOT in $this->config_nohotlink_valid_domains ('.implode(';', $this->config_nohotlink_valid_domains).')', __FILE__, __LINE__); } else { $this->DebugMessage('AntiOffsiteLinking() - "'.$parsed_url['host'].'" is in $this->config_nohotlink_valid_domains ('.implode(';', $this->config_nohotlink_valid_domains).')', __FILE__, __LINE__); @@ -2430,9 +2492,9 @@ function AntiOffsiteLinking() { if (!phpthumb_functions::IsHexColor($this->config_error_textcolor)) { return $this->ErrorImage('Invalid hex color string "'.$this->config_error_textcolor.'" for $this->config_error_textcolor'); } - if ($erase) { + if ($this->config_nooffsitelink_erase_image) { - return $this->ErrorImage($message, $this->thumbnail_width, $this->thumbnail_height, $this->config_error_bgcolor, $this->config_error_textcolor, $this->config_error_fontsize); + return $this->ErrorImage($this->config_nooffsitelink_text_message, $this->thumbnail_width, $this->thumbnail_height); } else { @@ -2449,21 +2511,21 @@ function AntiOffsiteLinking() { $opacity = 50; $margin = 5; $phpthumbFilters->WatermarkOverlay($this->gdimg_output, $watermark_img, '*', $opacity, $margin); - ImageDestroy($watermark_img); + imagedestroy($watermark_img); unset($phpthumbFilters); } else { - $nohotlink_text_array = explode("\n", wordwrap($message, floor($this->thumbnail_width / ImageFontWidth($this->config_error_fontsize)), "\n")); + $nohotlink_text_array = explode("\n", wordwrap($this->config_nooffsitelink_text_message, floor($this->thumbnail_width / imagefontwidth($this->config_error_fontsize)), "\n")); $nohotlink_text_color = phpthumb_functions::ImageHexColorAllocate($this->gdimg_output, $this->config_error_textcolor); - $topoffset = round(($this->thumbnail_height - (count($nohotlink_text_array) * ImageFontHeight($this->config_error_fontsize))) / 2); + $topoffset = round(($this->thumbnail_height - (count($nohotlink_text_array) * imagefontheight($this->config_error_fontsize))) / 2); $rowcounter = 0; - $this->DebugMessage('AntiOffsiteLinking() writing '.count($nohotlink_text_array).' lines of text "'.$message.'" (in #'.$this->config_error_textcolor.') on top of image', __FILE__, __LINE__); + $this->DebugMessage('AntiOffsiteLinking() writing '.count($nohotlink_text_array).' lines of text "'.$this->config_nooffsitelink_text_message.'" (in #'.$this->config_error_textcolor.') on top of image', __FILE__, __LINE__); foreach ($nohotlink_text_array as $textline) { - $leftoffset = max(0, round(($this->thumbnail_width - (strlen($textline) * ImageFontWidth($this->config_error_fontsize))) / 2)); - ImageString($this->gdimg_output, $this->config_error_fontsize, $leftoffset, $topoffset + ($rowcounter++ * ImageFontHeight($this->config_error_fontsize)), $textline, $nohotlink_text_color); + $leftoffset = max(0, round(($this->thumbnail_width - (strlen($textline) * imagefontwidth($this->config_error_fontsize))) / 2)); + imagestring($this->gdimg_output, $this->config_error_fontsize, $leftoffset, $topoffset + ($rowcounter++ * imagefontheight($this->config_error_fontsize)), $textline, $nohotlink_text_color); } } @@ -2489,7 +2551,7 @@ function AlphaChannelFlatten() { case 'gif': // image has alpha transparency, but output as GIF which can handle only single-color transparency - $CurrentImageColorTransparent = ImageColorTransparent($this->gdimg_output); + $CurrentImageColorTransparent = imagecolortransparent($this->gdimg_output); if ($CurrentImageColorTransparent == -1) { // no transparent color defined @@ -2498,53 +2560,53 @@ function AlphaChannelFlatten() { return false; } - if ($img_alpha_mixdown_dither = @ImageCreateTrueColor(ImageSX($this->gdimg_output), ImageSY($this->gdimg_output))) { + if ($img_alpha_mixdown_dither = @imagecreatetruecolor(imagesx($this->gdimg_output), imagesy($this->gdimg_output))) { + $dither_color = array(); for ($i = 0; $i <= 255; $i++) { - $dither_color[$i] = ImageColorAllocate($img_alpha_mixdown_dither, $i, $i, $i); + $dither_color[$i] = imagecolorallocate($img_alpha_mixdown_dither, $i, $i, $i); } // scan through current truecolor image copy alpha channel to temp image as grayscale for ($x = 0; $x < $this->thumbnail_width; $x++) { for ($y = 0; $y < $this->thumbnail_height; $y++) { $PixelColor = phpthumb_functions::GetPixelColor($this->gdimg_output, $x, $y); - ImageSetPixel($img_alpha_mixdown_dither, $x, $y, $dither_color[($PixelColor['alpha'] * 2)]); + imagesetpixel($img_alpha_mixdown_dither, $x, $y, $dither_color[($PixelColor['alpha'] * 2)]); } } // dither alpha channel grayscale version down to 2 colors - ImageTrueColorToPalette($img_alpha_mixdown_dither, true, 2); + imagetruecolortopalette($img_alpha_mixdown_dither, true, 2); // reduce color palette to 256-1 colors (leave one palette position for transparent color) - ImageTrueColorToPalette($this->gdimg_output, true, 255); + imagetruecolortopalette($this->gdimg_output, true, 255); // allocate a new color for transparent color index - $TransparentColor = ImageColorAllocate($this->gdimg_output, 1, 254, 253); - ImageColorTransparent($this->gdimg_output, $TransparentColor); + $TransparentColor = imagecolorallocate($this->gdimg_output, 1, 254, 253); + imagecolortransparent($this->gdimg_output, $TransparentColor); // scan through alpha channel image and note pixels with >50% transparency - $TransparentPixels = array(); for ($x = 0; $x < $this->thumbnail_width; $x++) { for ($y = 0; $y < $this->thumbnail_height; $y++) { $AlphaChannelPixel = phpthumb_functions::GetPixelColor($img_alpha_mixdown_dither, $x, $y); if ($AlphaChannelPixel['red'] > 127) { - ImageSetPixel($this->gdimg_output, $x, $y, $TransparentColor); + imagesetpixel($this->gdimg_output, $x, $y, $TransparentColor); } } } - ImageDestroy($img_alpha_mixdown_dither); + imagedestroy($img_alpha_mixdown_dither); $this->DebugMessage('AlphaChannelFlatten() set image to 255+1 colors with transparency for GIF output', __FILE__, __LINE__); return true; } else { - $this->DebugMessage('AlphaChannelFlatten() failed ImageCreate('.ImageSX($this->gdimg_output).', '.ImageSY($this->gdimg_output).')', __FILE__, __LINE__); + $this->DebugMessage('AlphaChannelFlatten() failed imagecreate('.imagesx($this->gdimg_output).', '.imagesy($this->gdimg_output).')', __FILE__, __LINE__); return false; } } else { // a single transparent color already defined, leave as-is - $this->DebugMessage('skipping AlphaChannelFlatten() because ($this->thumbnailFormat == "'.$this->thumbnailFormat.'") and ImageColorTransparent returned "'.$CurrentImageColorTransparent.'"', __FILE__, __LINE__); + $this->DebugMessage('skipping AlphaChannelFlatten() because ($this->thumbnailFormat == "'.$this->thumbnailFormat.'") and imagecolortransparent() returned "'.$CurrentImageColorTransparent.'"', __FILE__, __LINE__); return true; } break; @@ -2558,15 +2620,15 @@ function AlphaChannelFlatten() { return $this->ErrorImage('Invalid hex color string "'.$this->config_background_hexcolor.'" for parameter "bg"'); } $background_color = phpthumb_functions::ImageHexColorAllocate($this->gdimg_output, $this->config_background_hexcolor); - ImageFilledRectangle($gdimg_flatten_temp, 0, 0, $this->thumbnail_width, $this->thumbnail_height, $background_color); - ImageCopy($gdimg_flatten_temp, $this->gdimg_output, 0, 0, 0, 0, $this->thumbnail_width, $this->thumbnail_height); + imagefilledrectangle($gdimg_flatten_temp, 0, 0, $this->thumbnail_width, $this->thumbnail_height, $background_color); + imagecopy($gdimg_flatten_temp, $this->gdimg_output, 0, 0, 0, 0, $this->thumbnail_width, $this->thumbnail_height); - ImageAlphaBlending($this->gdimg_output, true); - ImageSaveAlpha($this->gdimg_output, false); - ImageColorTransparent($this->gdimg_output, -1); - ImageCopy($this->gdimg_output, $gdimg_flatten_temp, 0, 0, 0, 0, $this->thumbnail_width, $this->thumbnail_height); + imagealphablending($this->gdimg_output, true); + imagesavealpha($this->gdimg_output, false); + imagecolortransparent($this->gdimg_output, -1); + imagecopy($this->gdimg_output, $gdimg_flatten_temp, 0, 0, 0, 0, $this->thumbnail_width, $this->thumbnail_height); - ImageDestroy($gdimg_flatten_temp); + imagedestroy($gdimg_flatten_temp); return true; } else { @@ -2692,7 +2754,7 @@ function ApplyFilters() { $alignment = ($alignment ? $alignment : 'BR'); $opacity = ($opacity ? $opacity : 50); $margin_x = ($margin_x ? $margin_x : 5); - $margin_y = $margin_y; // just to note it wasn't forgotten, but let the value always pass unchanged + // $margin_y -- it wasn't forgotten, let the value always pass unchanged $phpthumbFilters->HistogramOverlay($this->gdimg_output, $bands, $colors, $width, $height, $alignment, $opacity, $margin_x, $margin_y); break; @@ -2727,11 +2789,11 @@ function ApplyFilters() { fclose($fp_mask); if ($gdimg_mask = $this->ImageCreateFromStringReplacement($MaskImageData)) { if ($invert && phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - ImageFilter($gdimg_mask, IMG_FILTER_NEGATE); + imagefilter($gdimg_mask, IMG_FILTER_NEGATE); } $this->is_alpha = true; $phpthumbFilters->ApplyMask($gdimg_mask, $this->gdimg_output); - ImageDestroy($gdimg_mask); + imagedestroy($gdimg_mask); } else { $this->DebugMessage('ImageCreateFromStringReplacement() failed for "'.$mask_filename.'"', __FILE__, __LINE__); } @@ -2740,13 +2802,13 @@ function ApplyFilters() { } break; - case 'elip': // Elipse cropping + case 'elip': // Ellipse cropping if (phpthumb_functions::gd_version() < 2) { - $this->DebugMessage('Skipping Elipse() because gd_version is "'.phpthumb_functions::gd_version().'"', __FILE__, __LINE__); + $this->DebugMessage('Skipping Ellipse() because gd_version is "'.phpthumb_functions::gd_version().'"', __FILE__, __LINE__); return false; } $this->is_alpha = true; - $phpthumbFilters->Elipse($this->gdimg_output); + $phpthumbFilters->Ellipse($this->gdimg_output); break; case 'ric': // RoundedImageCorners @@ -2794,48 +2856,48 @@ function ApplyFilters() { } while (strlen($buffer) > 0); fclose($fp_watermark); if ($img_watermark = $this->ImageCreateFromStringReplacement($WatermarkImageData)) { - if ($margin < 1) { - $resized_x = max(1, ImageSX($this->gdimg_output) - round(2 * (ImageSX($this->gdimg_output) * $margin))); - $resized_y = max(1, ImageSY($this->gdimg_output) - round(2 * (ImageSY($this->gdimg_output) * $margin))); + if (($margin > 0) && ($margin < 1)) { + $resized_x = max(1, imagesx($this->gdimg_output) - round(2 * (imagesx($this->gdimg_output) * $margin))); + $resized_y = max(1, imagesy($this->gdimg_output) - round(2 * (imagesy($this->gdimg_output) * $margin))); } else { - $resized_x = max(1, ImageSX($this->gdimg_output) - round(2 * $margin)); - $resized_y = max(1, ImageSY($this->gdimg_output) - round(2 * $margin)); + $resized_x = max(1, imagesx($this->gdimg_output) - round(2 * $margin)); + $resized_y = max(1, imagesy($this->gdimg_output) - round(2 * $margin)); } if ($underlay) { - if ($img_watermark_resized = phpthumb_functions::ImageCreateFunction(ImageSX($this->gdimg_output), ImageSY($this->gdimg_output))) { - ImageAlphaBlending($img_watermark_resized, false); - ImageSaveAlpha($img_watermark_resized, true); - $this->ImageResizeFunction($img_watermark_resized, $img_watermark, 0, 0, 0, 0, ImageSX($img_watermark_resized), ImageSY($img_watermark_resized), ImageSX($img_watermark), ImageSY($img_watermark)); + if ($img_watermark_resized = phpthumb_functions::ImageCreateFunction(imagesx($this->gdimg_output), imagesy($this->gdimg_output))) { + imagealphablending($img_watermark_resized, false); + imagesavealpha($img_watermark_resized, true); + $this->ImageResizeFunction($img_watermark_resized, $img_watermark, 0, 0, 0, 0, imagesx($img_watermark_resized), imagesy($img_watermark_resized), imagesx($img_watermark), imagesy($img_watermark)); if ($img_source_resized = phpthumb_functions::ImageCreateFunction($resized_x, $resized_y)) { - ImageAlphaBlending($img_source_resized, false); - ImageSaveAlpha($img_source_resized, true); - $this->ImageResizeFunction($img_source_resized, $this->gdimg_output, 0, 0, 0, 0, ImageSX($img_source_resized), ImageSY($img_source_resized), ImageSX($this->gdimg_output), ImageSY($this->gdimg_output)); + imagealphablending($img_source_resized, false); + imagesavealpha($img_source_resized, true); + $this->ImageResizeFunction($img_source_resized, $this->gdimg_output, 0, 0, 0, 0, imagesx($img_source_resized), imagesy($img_source_resized), imagesx($this->gdimg_output), imagesy($this->gdimg_output)); $phpthumbFilters->WatermarkOverlay($img_watermark_resized, $img_source_resized, 'C', $opacity, $margin); - ImageCopy($this->gdimg_output, $img_watermark_resized, 0, 0, 0, 0, ImageSX($this->gdimg_output), ImageSY($this->gdimg_output)); + imagecopy($this->gdimg_output, $img_watermark_resized, 0, 0, 0, 0, imagesx($this->gdimg_output), imagesy($this->gdimg_output)); } else { $this->DebugMessage('phpthumb_functions::ImageCreateFunction('.$resized_x.', '.$resized_y.')', __FILE__, __LINE__); } - ImageDestroy($img_watermark_resized); + imagedestroy($img_watermark_resized); } else { - $this->DebugMessage('phpthumb_functions::ImageCreateFunction('.ImageSX($this->gdimg_output).', '.ImageSY($this->gdimg_output).')', __FILE__, __LINE__); + $this->DebugMessage('phpthumb_functions::ImageCreateFunction('.imagesx($this->gdimg_output).', '.imagesy($this->gdimg_output).')', __FILE__, __LINE__); } } else { // overlay if ($img_watermark_resized = phpthumb_functions::ImageCreateFunction($resized_x, $resized_y)) { - ImageAlphaBlending($img_watermark_resized, false); - ImageSaveAlpha($img_watermark_resized, true); - $this->ImageResizeFunction($img_watermark_resized, $img_watermark, 0, 0, 0, 0, ImageSX($img_watermark_resized), ImageSY($img_watermark_resized), ImageSX($img_watermark), ImageSY($img_watermark)); + imagealphablending($img_watermark_resized, false); + imagesavealpha($img_watermark_resized, true); + $this->ImageResizeFunction($img_watermark_resized, $img_watermark, 0, 0, 0, 0, imagesx($img_watermark_resized), imagesy($img_watermark_resized), imagesx($img_watermark), imagesy($img_watermark)); $phpthumbFilters->WatermarkOverlay($this->gdimg_output, $img_watermark_resized, 'C', $opacity, $margin); - ImageDestroy($img_watermark_resized); + imagedestroy($img_watermark_resized); } else { $this->DebugMessage('phpthumb_functions::ImageCreateFunction('.$resized_x.', '.$resized_y.')', __FILE__, __LINE__); } } - ImageDestroy($img_watermark); + imagedestroy($img_watermark); } else { $this->DebugMessage('ImageCreateFromStringReplacement() failed for "'.$filename.'"', __FILE__, __LINE__); @@ -2867,31 +2929,31 @@ function ApplyFilters() { if (@is_readable($filename)) { if ($img_watermark = $this->ImageCreateFromFilename($filename)) { if ($rotate_angle !== 0) { - $phpthumbFilters->ImprovedImageRotate($img_watermark, $rotate_angle); + $phpthumbFilters->ImprovedImageRotate($img_watermark, $rotate_angle, 'FFFFFF', null, $this); } if (preg_match('#^([0-9\\.\\-]*)x([0-9\\.\\-]*)$#i', $alignment, $matches)) { - $watermark_max_width = intval($margin['x'] ? $margin['x'] : ImageSX($img_watermark)); - $watermark_max_height = intval($margin['y'] ? $margin['y'] : ImageSY($img_watermark)); - $scale = phpthumb_functions::ScaleToFitInBox(ImageSX($img_watermark), ImageSY($img_watermark), $watermark_max_width, $watermark_max_height, true, true); + $watermark_max_width = intval($margin['x'] ? $margin['x'] : imagesx($img_watermark)); + $watermark_max_height = intval($margin['y'] ? $margin['y'] : imagesy($img_watermark)); + $scale = phpthumb_functions::ScaleToFitInBox(imagesx($img_watermark), imagesy($img_watermark), $watermark_max_width, $watermark_max_height, true, true); $this->DebugMessage('Scaling watermark by a factor of '.number_format($scale, 4), __FILE__, __LINE__); if (($scale > 1) || ($scale < 1)) { - if ($img_watermark2 = phpthumb_functions::ImageCreateFunction($scale * ImageSX($img_watermark), $scale * ImageSY($img_watermark))) { - ImageAlphaBlending($img_watermark2, false); - ImageSaveAlpha($img_watermark2, true); - $this->ImageResizeFunction($img_watermark2, $img_watermark, 0, 0, 0, 0, ImageSX($img_watermark2), ImageSY($img_watermark2), ImageSX($img_watermark), ImageSY($img_watermark)); + if ($img_watermark2 = phpthumb_functions::ImageCreateFunction($scale * imagesx($img_watermark), $scale * imagesy($img_watermark))) { + imagealphablending($img_watermark2, false); + imagesavealpha($img_watermark2, true); + $this->ImageResizeFunction($img_watermark2, $img_watermark, 0, 0, 0, 0, imagesx($img_watermark2), imagesy($img_watermark2), imagesx($img_watermark), imagesy($img_watermark)); $img_watermark = $img_watermark2; } else { - $this->DebugMessage('ImageCreateFunction('.($scale * ImageSX($img_watermark)).', '.($scale * ImageSX($img_watermark)).') failed', __FILE__, __LINE__); + $this->DebugMessage('ImageCreateFunction('.($scale * imagesx($img_watermark)).', '.($scale * imagesx($img_watermark)).') failed', __FILE__, __LINE__); } } - $watermark_dest_x = round($matches[1] - (ImageSX($img_watermark) / 2)); - $watermark_dest_y = round($matches[2] - (ImageSY($img_watermark) / 2)); + $watermark_dest_x = round($matches[1] - (imagesx($img_watermark) / 2)); + $watermark_dest_y = round($matches[2] - (imagesy($img_watermark) / 2)); $alignment = $watermark_dest_x.'x'.$watermark_dest_y; } $phpthumbFilters->WatermarkOverlay($this->gdimg_output, $img_watermark, $alignment, $opacity, $margin['x'], $margin['y']); - ImageDestroy($img_watermark); + imagedestroy($img_watermark); if (isset($img_watermark2) && is_resource($img_watermark2)) { - ImageDestroy($img_watermark2); + imagedestroy($img_watermark2); } } else { $this->DebugMessage('ImageCreateFromFilename() failed for "'.$filename.'"', __FILE__, __LINE__); @@ -2916,7 +2978,7 @@ function ApplyFilters() { $fillextend = ($fillextend ? $fillextend : ''); if (basename($ttffont) == $ttffont) { - $ttffont = realpath($this->config_ttf_directory.DIRECTORY_SEPARATOR.$ttffont); + $ttffont = $this->realPathSafe($this->config_ttf_directory.DIRECTORY_SEPARATOR.$ttffont); } else { $ttffont = $this->ResolveFilenameToAbsolute($ttffont); } @@ -2975,38 +3037,37 @@ function ApplyFilters() { case 'size': // Resize @list($newwidth, $newheight, $stretch) = explode('|', $parameter); - $newwidth = (!$newwidth ? ImageSX($this->gdimg_output) : ((($newwidth > 0) && ($newwidth < 1)) ? round($newwidth * ImageSX($this->gdimg_output)) : round($newwidth))); - $newheight = (!$newheight ? ImageSY($this->gdimg_output) : ((($newheight > 0) && ($newheight < 1)) ? round($newheight * ImageSY($this->gdimg_output)) : round($newheight))); + $newwidth = (!$newwidth ? imagesx($this->gdimg_output) : ((($newwidth > 0) && ($newwidth < 1)) ? round($newwidth * imagesx($this->gdimg_output)) : round($newwidth))); + $newheight = (!$newheight ? imagesy($this->gdimg_output) : ((($newheight > 0) && ($newheight < 1)) ? round($newheight * imagesy($this->gdimg_output)) : round($newheight))); $stretch = ($stretch ? true : false); if ($stretch) { - $scale_x = phpthumb_functions::ScaleToFitInBox(ImageSX($this->gdimg_output), ImageSX($this->gdimg_output), $newwidth, $newwidth, true, true); - $scale_y = phpthumb_functions::ScaleToFitInBox(ImageSY($this->gdimg_output), ImageSY($this->gdimg_output), $newheight, $newheight, true, true); + $scale_x = phpthumb_functions::ScaleToFitInBox(imagesx($this->gdimg_output), imagesx($this->gdimg_output), $newwidth, $newwidth, true, true); + $scale_y = phpthumb_functions::ScaleToFitInBox(imagesy($this->gdimg_output), imagesy($this->gdimg_output), $newheight, $newheight, true, true); } else { - $scale_x = phpthumb_functions::ScaleToFitInBox(ImageSX($this->gdimg_output), ImageSY($this->gdimg_output), $newwidth, $newheight, true, true); + $scale_x = phpthumb_functions::ScaleToFitInBox(imagesx($this->gdimg_output), imagesy($this->gdimg_output), $newwidth, $newheight, true, true); $scale_y = $scale_x; } $this->DebugMessage('Scaling watermark ('.($stretch ? 'with' : 'without').' stretch) by a factor of "'.number_format($scale_x, 4).' x '.number_format($scale_y, 4).'"', __FILE__, __LINE__); if (($scale_x > 1) || ($scale_x < 1) || ($scale_y > 1) || ($scale_y < 1)) { - if ($img_temp = phpthumb_functions::ImageCreateFunction(ImageSX($this->gdimg_output), ImageSY($this->gdimg_output))) { - ImageCopy($img_temp, $this->gdimg_output, 0, 0, 0, 0, ImageSX($this->gdimg_output), ImageSY($this->gdimg_output)); - //ImageDestroy($this->gdimg_output); - if ($this->gdimg_output = phpthumb_functions::ImageCreateFunction($scale_x * ImageSX($img_temp), $scale_y * ImageSY($img_temp))) { - ImageAlphaBlending($this->gdimg_output, false); - ImageSaveAlpha($this->gdimg_output, true); - $this->ImageResizeFunction($this->gdimg_output, $img_temp, 0, 0, 0, 0, ImageSX($this->gdimg_output), ImageSY($this->gdimg_output), ImageSX($img_temp), ImageSY($img_temp)); + if ($img_temp = phpthumb_functions::ImageCreateFunction(imagesx($this->gdimg_output), imagesy($this->gdimg_output))) { + imagecopy($img_temp, $this->gdimg_output, 0, 0, 0, 0, imagesx($this->gdimg_output), imagesy($this->gdimg_output)); + if ($this->gdimg_output = phpthumb_functions::ImageCreateFunction($scale_x * imagesx($img_temp), $scale_y * imagesy($img_temp))) { + imagealphablending($this->gdimg_output, false); + imagesavealpha($this->gdimg_output, true); + $this->ImageResizeFunction($this->gdimg_output, $img_temp, 0, 0, 0, 0, imagesx($this->gdimg_output), imagesy($this->gdimg_output), imagesx($img_temp), imagesy($img_temp)); } else { - $this->DebugMessage('ImageCreateFunction('.($scale_x * ImageSX($img_temp)).', '.($scale_y * ImageSY($img_temp)).') failed', __FILE__, __LINE__); + $this->DebugMessage('ImageCreateFunction('.($scale_x * imagesx($img_temp)).', '.($scale_y * imagesy($img_temp)).') failed', __FILE__, __LINE__); } - ImageDestroy($img_temp); + imagedestroy($img_temp); } else { - $this->DebugMessage('ImageCreateFunction('.ImageSX($this->gdimg_output).', '.ImageSY($this->gdimg_output).') failed', __FILE__, __LINE__); + $this->DebugMessage('ImageCreateFunction('.imagesx($this->gdimg_output).', '.imagesy($this->gdimg_output).') failed', __FILE__, __LINE__); } } break; case 'rot': // ROTate @list($angle, $bgcolor) = explode('|', $parameter, 2); - $phpthumbFilters->ImprovedImageRotate($this->gdimg_output, $angle, $bgcolor); + $phpthumbFilters->ImprovedImageRotate($this->gdimg_output, $angle, $bgcolor, null, $this); break; case 'stc': // Source Transparent Color @@ -3020,9 +3081,9 @@ function ApplyFilters() { if ($gdimg_mask = $phpthumbFilters->SourceTransparentColorMask($this->gdimg_output, $hexcolor, $min_limit, $max_limit)) { $this->is_alpha = true; $phpthumbFilters->ApplyMask($gdimg_mask, $this->gdimg_output); - ImageDestroy($gdimg_mask); + imagedestroy($gdimg_mask); } else { - $this->DebugMessage('SourceTransparentColorMask() failed for "'.$mask_filename.'"', __FILE__, __LINE__); + $this->DebugMessage('SourceTransparentColorMask() failed for "'.$hexcolor.','.$min_limit.','.$max_limit.'"', __FILE__, __LINE__); } break; } @@ -3051,38 +3112,33 @@ function MaxFileSize() { if (strlen($imgdata) > $this->maxb) { for ($i = 8; $i >= 1; $i--) { - $tempIMG = ImageCreateTrueColor(ImageSX($this->gdimg_output), ImageSY($this->gdimg_output)); - ImageCopy($tempIMG, $this->gdimg_output, 0, 0, 0, 0, ImageSX($this->gdimg_output), ImageSY($this->gdimg_output)); - ImageTrueColorToPalette($tempIMG, true, pow(2, $i)); + $tempIMG = imagecreatetruecolor(imagesx($this->gdimg_output), imagesy($this->gdimg_output)); + imagecopy($tempIMG, $this->gdimg_output, 0, 0, 0, 0, imagesx($this->gdimg_output), imagesy($this->gdimg_output)); + imagetruecolortopalette($tempIMG, true, pow(2, $i)); ob_start(); $imgRenderFunction($tempIMG); $imgdata = ob_get_contents(); ob_end_clean(); if (strlen($imgdata) <= $this->maxb) { - ImageTrueColorToPalette($this->gdimg_output, true, pow(2, $i)); + imagetruecolortopalette($this->gdimg_output, true, pow(2, $i)); break; } } } - if (strlen($imgdata) > $this->maxb) { - ImageTrueColorToPalette($this->gdimg_output, true, pow(2, $i)); - return false; - } break; case 'jpeg': ob_start(); - ImageJPEG($this->gdimg_output); + imagejpeg($this->gdimg_output); $imgdata = ob_get_contents(); ob_end_clean(); - $OriginalJPEGquality = $this->thumbnailQuality; if (strlen($imgdata) > $this->maxb) { for ($i = 3; $i < 20; $i++) { $q = round(100 * (1 - log10($i / 2))); ob_start(); - ImageJPEG($this->gdimg_output, null, $q); + imagejpeg($this->gdimg_output, null, $q); $imgdata = ob_get_contents(); ob_end_clean(); @@ -3099,7 +3155,6 @@ function MaxFileSize() { default: return false; - break; } } return true; @@ -3204,21 +3259,20 @@ function CalculateThumbnailDimensions() { function CreateGDoutput() { $this->CalculateThumbnailDimensions(); - // Create the GD image (either true-color or 256-color, depending on GD version) + // create the GD image (either true-color or 256-color, depending on GD version) $this->gdimg_output = phpthumb_functions::ImageCreateFunction($this->thumbnail_width, $this->thumbnail_height); - // Images that have transparency must have the background filled with the configured 'bg' color - // otherwise the transparent color will appear as black - ImageSaveAlpha($this->gdimg_output, true); + // images that have transparency must have the background filled with the configured 'bg' color otherwise the transparent color will appear as black + imagesavealpha($this->gdimg_output, true); if ($this->is_alpha && phpthumb_functions::gd_version() >= 2) { - ImageAlphaBlending($this->gdimg_output, false); + imagealphablending($this->gdimg_output, false); $output_full_alpha = phpthumb_functions::ImageColorAllocateAlphaSafe($this->gdimg_output, 255, 255, 255, 127); - ImageFilledRectangle($this->gdimg_output, 0, 0, $this->thumbnail_width, $this->thumbnail_height, $output_full_alpha); + imagefilledrectangle($this->gdimg_output, 0, 0, $this->thumbnail_width, $this->thumbnail_height, $output_full_alpha); } else { - $current_transparent_color = ImageColorTransparent($this->gdimg_source); + $current_transparent_color = imagecolortransparent($this->gdimg_source); if ($this->bg || (@$current_transparent_color >= 0)) { $this->config_background_hexcolor = ($this->bg ? $this->bg : $this->config_background_hexcolor); @@ -3226,7 +3280,7 @@ function CreateGDoutput() { return $this->ErrorImage('Invalid hex color string "'.$this->config_background_hexcolor.'" for parameter "bg"'); } $background_color = phpthumb_functions::ImageHexColorAllocate($this->gdimg_output, $this->config_background_hexcolor); - ImageFilledRectangle($this->gdimg_output, 0, 0, $this->thumbnail_width, $this->thumbnail_height, $background_color); + imagefilledrectangle($this->gdimg_output, 0, 0, $this->thumbnail_width, $this->thumbnail_height, $background_color); } @@ -3260,47 +3314,47 @@ function ExtractEXIFgetImageSize() { $this->DebugMessage('starting ExtractEXIFgetImageSize()', __FILE__, __LINE__); if (preg_match('#^http:#i', $this->src) && !$this->sourceFilename && $this->rawImageData) { - !$this->SourceDataToTempFile(); + $this->SourceDataToTempFile(); } if (is_null($this->getimagesizeinfo)) { if ($this->sourceFilename) { - $this->getimagesizeinfo = @GetImageSize($this->sourceFilename); + $this->getimagesizeinfo = @getimagesize($this->sourceFilename); $this->source_width = $this->getimagesizeinfo[0]; $this->source_height = $this->getimagesizeinfo[1]; - $this->DebugMessage('GetImageSize('.$this->sourceFilename.') says image is '.$this->source_width.'x'.$this->source_height, __FILE__, __LINE__); + $this->DebugMessage('getimagesize('.$this->sourceFilename.') says image is '.$this->source_width.'x'.$this->source_height, __FILE__, __LINE__); } else { - $this->DebugMessage('skipping GetImageSize() because $this->sourceFilename is empty', __FILE__, __LINE__); + $this->DebugMessage('skipping getimagesize() because $this->sourceFilename is empty', __FILE__, __LINE__); } } else { - $this->DebugMessage('skipping GetImageSize() because !is_null($this->getimagesizeinfo)', __FILE__, __LINE__); + $this->DebugMessage('skipping getimagesize() because !is_null($this->getimagesizeinfo)', __FILE__, __LINE__); } if (is_resource($this->gdimg_source)) { - $this->source_width = ImageSX($this->gdimg_source); - $this->source_height = ImageSY($this->gdimg_source); + $this->source_width = imagesx($this->gdimg_source); + $this->source_height = imagesy($this->gdimg_source); $this->SetOrientationDependantWidthHeight(); } elseif ($this->rawImageData && !$this->sourceFilename) { if ($this->SourceImageIsTooLarge($this->source_width, $this->source_height)) { - $this->DebugMessage('NOT bypassing EXIF and GetImageSize sections because source image is too large for GD ('.$this->source_width.'x'.$this->source_width.'='.($this->source_width * $this->source_height * 5).'MB)', __FILE__, __LINE__); + $this->DebugMessage('NOT bypassing EXIF and getimagesize sections because source image is too large for GD ('.$this->source_width.'x'.$this->source_width.'='.($this->source_width * $this->source_height * 5).'MB)', __FILE__, __LINE__); } else { - $this->DebugMessage('bypassing EXIF and GetImageSize sections because $this->rawImageData is set, and $this->sourceFilename is not set, and source image is not too large for GD ('.$this->source_width.'x'.$this->source_width.'='.($this->source_width * $this->source_height * 5).'MB)', __FILE__, __LINE__); + $this->DebugMessage('bypassing EXIF and getimagesize sections because $this->rawImageData is set, and $this->sourceFilename is not set, and source image is not too large for GD ('.$this->source_width.'x'.$this->source_width.'='.($this->source_width * $this->source_height * 5).'MB)', __FILE__, __LINE__); } } if (is_null($this->getimagesizeinfo)) { - $this->getimagesizeinfo = @GetImageSize($this->sourceFilename); + $this->getimagesizeinfo = @getimagesize($this->sourceFilename); } if (!empty($this->getimagesizeinfo)) { // great $this->getimagesizeinfo['filesize'] = @filesize($this->sourceFilename); } elseif (!$this->rawImageData) { - $this->DebugMessage('GetImageSize("'.$this->sourceFilename.'") failed', __FILE__, __LINE__); + $this->DebugMessage('getimagesize("'.$this->sourceFilename.'") failed', __FILE__, __LINE__); } if ($this->config_prefer_imagemagick) { @@ -3346,8 +3400,8 @@ function ExtractEXIFgetImageSize() { if (!$exit_thumbnail_error && $this->exif_thumbnail_data) { if ($gdimg_exif_temp = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data, false)) { - $this->exif_thumbnail_width = ImageSX($gdimg_exif_temp); - $this->exif_thumbnail_height = ImageSY($gdimg_exif_temp); + $this->exif_thumbnail_width = imagesx($gdimg_exif_temp); + $this->exif_thumbnail_height = imagesy($gdimg_exif_temp); $this->exif_thumbnail_type = 2; // (2 == JPEG) before PHP v4.3.0 only JPEG format EXIF thumbnails are returned unset($gdimg_exif_temp); } else { @@ -3394,8 +3448,8 @@ function ExtractEXIFgetImageSize() { $this->DebugMessage('setting $this->gdimg_source = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data)', __FILE__, __LINE__); $this->gdimg_source = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data); - $this->source_width = ImageSX($this->gdimg_source); - $this->source_height = ImageSY($this->gdimg_source); + $this->source_width = imagesx($this->gdimg_source); + $this->source_height = imagesy($this->gdimg_source); return true; } } @@ -3450,7 +3504,6 @@ function SetCacheFilename() { } $this->cache_filename = ''; - $broad_directory_name = ''; if ($this->new) { $broad_directory_name = strtolower(md5($this->new)); $this->cache_filename .= '_new'.$broad_directory_name; @@ -3525,9 +3578,8 @@ function SourceImageIsTooLarge($width, $height) { if (!$this->config_max_source_pixels) { return false; } - if (function_exists('memory_get_usage')) { - $available_memory = max(intval(ini_get('memory_limit')), intval(get_cfg_var('memory_limit'))) * 1048576; - $available_memory -= memory_get_usage(); + if ($this->php_memory_limit && function_exists('memory_get_usage')) { + $available_memory = $this->php_memory_limit - memory_get_usage(); return (bool) (($width * $height * 5) > $available_memory); } return (bool) (($width * $height) > $this->config_max_source_pixels); @@ -3535,18 +3587,18 @@ function SourceImageIsTooLarge($width, $height) { function ImageCreateFromFilename($filename) { // try to create GD image source directly via GD, if possible, - // rather than buffering to memory and creating with ImageCreateFromString + // rather than buffering to memory and creating with imagecreatefromstring $ImageCreateWasAttempted = false; $gd_image = false; $this->DebugMessage('starting ImageCreateFromFilename('.$filename.')', __FILE__, __LINE__); - if ($filename && ($getimagesizeinfo = @GetImageSize($filename))) { + if ($filename && ($getimagesizeinfo = @getimagesize($filename))) { if (!$this->SourceImageIsTooLarge($getimagesizeinfo[0], $getimagesizeinfo[1])) { $ImageCreateFromFunction = array( - 1 => 'ImageCreateFromGIF', - 2 => 'ImageCreateFromJPEG', - 3 => 'ImageCreateFromPNG', - 15 => 'ImageCreateFromWBMP', + 1 => 'imagecreatefromgif', + 2 => 'imagecreatefromjpeg', + 3 => 'imagecreatefrompng', + 15 => 'imagecreatefromwbmp', ); $this->DebugMessage('ImageCreateFromFilename found ($getimagesizeinfo[2]=='.@$getimagesizeinfo[2].')', __FILE__, __LINE__); switch (@$getimagesizeinfo[2]) { @@ -3588,13 +3640,13 @@ function ImageCreateFromFilename($filename) { return false; } } else { - $this->DebugMessage('empty $filename or GetImageSize('.$filename.') failed', __FILE__, __LINE__); + $this->DebugMessage('empty $filename or getimagesize('.$filename.') failed', __FILE__, __LINE__); } if (!$gd_image) { - // cannot create from filename, attempt to create source image with ImageCreateFromString, if possible + // cannot create from filename, attempt to create source image with imagecreatefromstring, if possible if ($ImageCreateWasAttempted) { - $this->DebugMessage(@$ImageCreateFromFunctionName.'() was attempted but FAILED', __FILE__, __LINE__); + $this->DebugMessage($ImageCreateFromFunctionName.'() was attempted but FAILED', __FILE__, __LINE__); } $this->DebugMessage('Populating $rawimagedata', __FILE__, __LINE__); $rawimagedata = ''; @@ -3619,8 +3671,8 @@ function ImageCreateFromFilename($filename) { function SourceImageToGD() { if (is_resource($this->gdimg_source)) { - $this->source_width = ImageSX($this->gdimg_source); - $this->source_height = ImageSY($this->gdimg_source); + $this->source_width = imagesx($this->gdimg_source); + $this->source_height = imagesy($this->gdimg_source); $this->DebugMessage('skipping SourceImageToGD() because $this->gdimg_source is already a resource ('.$this->source_width.'x'.$this->source_height.')', __FILE__, __LINE__); return true; } @@ -3638,6 +3690,7 @@ function SourceImageToGD() { } else { $this->DebugMessage('ImageMagickThumbnailToGD() failed', __FILE__, __LINE__); } + @chmod($tempnam, $this->getParameter('config_file_create_mask')); } else { $this->DebugMessage('failed to put $this->rawImageData into temp file "'.$tempnam.'"', __FILE__, __LINE__); } @@ -3769,7 +3822,7 @@ function SourceImageToGD() { break; } if ($imageHeader) { - // cannot create image for whatever reason (maybe ImageCreateFromJPEG et al are not available?) + // cannot create image for whatever reason (maybe imagecreatefromjpeg et al are not available?) // and ImageMagick is not available either, no choice but to output original (not resized/modified) data and exit if ($this->config_error_die_on_source_failure) { $errormessages = array(); @@ -3845,7 +3898,6 @@ function SourceImageToGD() { } if (!$this->gdimg_source) { - $HeaderFourBytes = ''; if ($this->rawImageData) { $HeaderFourBytes = substr($this->rawImageData, 0, 4); } elseif ($this->sourceFilename) { @@ -3887,8 +3939,8 @@ function SourceImageToGD() { return false; } - $this->source_width = ImageSX($this->gdimg_source); - $this->source_height = ImageSY($this->gdimg_source); + $this->source_width = imagesx($this->gdimg_source); + $this->source_height = imagesy($this->gdimg_source); return true; } @@ -3922,7 +3974,7 @@ function phpThumbDebug($level='') { return $this->ErrorImage('phpThumbDebug disabled'); } - $FunctionsExistance = array('exif_thumbnail', 'gd_info', 'image_type_to_mime_type', 'GetImageSize', 'ImageCopyResampled', 'ImageCopyResized', 'ImageCreate', 'ImageCreateFromString', 'ImageCreateTrueColor', 'ImageIsTrueColor', 'ImageRotate', 'ImageTypes', 'version_compare', 'ImageCreateFromGIF', 'ImageCreateFromJPEG', 'ImageCreateFromPNG', 'ImageCreateFromWBMP', 'ImageCreateFromXBM', 'ImageCreateFromXPM', 'ImageCreateFromString', 'ImageCreateFromGD', 'ImageCreateFromGD2', 'ImageCreateFromGD2Part', 'ImageJPEG', 'ImageGIF', 'ImagePNG', 'ImageWBMP'); + $FunctionsExistance = array('exif_thumbnail', 'gd_info', 'image_type_to_mime_type', 'getimagesize', 'imagecopyresampled', 'imagecopyresized', 'imagecreate', 'imagecreatefromstring', 'imagecreatetruecolor', 'imageistruecolor', 'imagerotate', 'imagetypes', 'version_compare', 'imagecreatefromgif', 'imagecreatefromjpeg', 'imagecreatefrompng', 'imagecreatefromwbmp', 'imagecreatefromxbm', 'imagecreatefromxpm', 'imagecreatefromstring', 'imagecreatefromgd', 'imagecreatefromgd2', 'imagecreatefromgd2part', 'imagejpeg', 'imagegif', 'imagepng', 'imagewbmp'); $ParameterNames = array('src', 'new', 'w', 'h', 'f', 'q', 'sx', 'sy', 'sw', 'sh', 'far', 'bg', 'bc', 'file', 'goto', 'err', 'xto', 'ra', 'ar', 'aoe', 'iar', 'maxb'); $ConfigVariableNames = array('document_root', 'temp_directory', 'output_format', 'output_maxwidth', 'output_maxheight', 'error_message_image_default', 'error_bgcolor', 'error_textcolor', 'error_fontsize', 'error_die_on_error', 'error_silent_die_on_error', 'error_die_on_source_failure', 'nohotlink_enabled', 'nohotlink_valid_domains', 'nohotlink_erase_image', 'nohotlink_text_message', 'nooffsitelink_enabled', 'nooffsitelink_valid_domains', 'nooffsitelink_require_refer', 'nooffsitelink_erase_image', 'nooffsitelink_text_message', 'high_security_enabled', 'allow_src_above_docroot', 'allow_src_above_phpthumb', 'max_source_pixels', 'use_exif_thumbnail_for_speed', 'border_hexcolor', 'background_hexcolor', 'ttf_directory', 'disable_pathinfo_parsing', 'disable_imagecopyresampled'); $OtherVariableNames = array('phpThumbDebug', 'thumbnailQuality', 'thumbnailFormat', 'gdimg_output', 'gdimg_source', 'sourceFilename', 'source_width', 'source_height', 'thumbnailCropX', 'thumbnailCropY', 'thumbnailCropW', 'thumbnailCropH', 'exif_thumbnail_width', 'exif_thumbnail_height', 'exif_thumbnail_type', 'thumbnail_width', 'thumbnail_height', 'thumbnail_image_width', 'thumbnail_image_height'); @@ -4107,8 +4159,8 @@ function ErrorImage($text, $width=0, $height=0, $forcedisplay=false) { exit; } - $FontWidth = ImageFontWidth($this->config_error_fontsize); - $FontHeight = ImageFontHeight($this->config_error_fontsize); + $FontWidth = imagefontwidth($this->config_error_fontsize); + $FontHeight = imagefontheight($this->config_error_fontsize); $LinesOfText = explode("\n", @wordwrap($text, floor($width / $FontWidth), "\n", true)); $height = max($height, count($LinesOfText) * $FontHeight); @@ -4123,45 +4175,44 @@ function ErrorImage($text, $width=0, $height=0, $forcedisplay=false) { echo "\n".'**Headers already sent, dumping error message as text:**
'."\n\n".$text."\n".'
'; - } elseif ($gdimg_error = ImageCreate($width, $height)) { + } elseif ($gdimg_error = imagecreate($width, $height)) { $background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_bgcolor, true); $text_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_textcolor, true); - ImageFilledRectangle($gdimg_error, 0, 0, $width, $height, $background_color); + imagefilledrectangle($gdimg_error, 0, 0, $width, $height, $background_color); $lineYoffset = 0; foreach ($LinesOfText as $line) { - ImageString($gdimg_error, $this->config_error_fontsize, 2, $lineYoffset, $line, $text_color); + imagestring($gdimg_error, $this->config_error_fontsize, 2, $lineYoffset, $line, $text_color); $lineYoffset += $FontHeight; } - if (function_exists('ImageTypes')) { - $imagetypes = ImageTypes(); + if (function_exists('imagetypes')) { + $imagetypes = imagetypes(); if ($imagetypes & IMG_PNG) { header('Content-Type: image/png'); - ImagePNG($gdimg_error); + imagepng($gdimg_error); } elseif ($imagetypes & IMG_GIF) { header('Content-Type: image/gif'); - ImageGIF($gdimg_error); + imagegif($gdimg_error); } elseif ($imagetypes & IMG_JPG) { header('Content-Type: image/jpeg'); - ImageJPEG($gdimg_error); + imagejpeg($gdimg_error); } elseif ($imagetypes & IMG_WBMP) { header('Content-Type: image/vnd.wap.wbmp'); - ImageWBMP($gdimg_error); + imagewbmp($gdimg_error); } } - ImageDestroy($gdimg_error); + imagedestroy($gdimg_error); } if (!headers_sent()) { echo "\n".'**Failed to send graphical error image, dumping error message as text:**
'."\n\n".$text; } exit; - return true; } function ImageCreateFromStringReplacement(&$RawImageData, $DieOnErrors=false) { // there are serious bugs in the non-bundled versions of GD which may cause - // PHP to segfault when calling ImageCreateFromString() - avoid if at all possible + // PHP to segfault when calling imagecreatefromstring() - avoid if at all possible // when not using a bundled version of GD2 if (!phpthumb_functions::gd_version()) { if ($DieOnErrors) { @@ -4180,8 +4231,8 @@ function ImageCreateFromStringReplacement(&$RawImageData, $DieOnErrors=false) { } } if (phpthumb_functions::gd_is_bundled()) { - $this->DebugMessage('ImageCreateFromStringReplacement() calling built-in ImageCreateFromString()', __FILE__, __LINE__); - return @ImageCreateFromString($RawImageData); + $this->DebugMessage('ImageCreateFromStringReplacement() calling built-in imagecreatefromstring()', __FILE__, __LINE__); + return @imagecreatefromstring($RawImageData); } if ($this->issafemode) { $this->DebugMessage('ImageCreateFromStringReplacement() failed: cannot create temp file in SAFE_MODE', __FILE__, __LINE__); @@ -4190,26 +4241,28 @@ function ImageCreateFromStringReplacement(&$RawImageData, $DieOnErrors=false) { switch (substr($RawImageData, 0, 3)) { case 'GIF': - $ICFSreplacementFunctionName = 'ImageCreateFromGIF'; + $ICFSreplacementFunctionName = 'imagecreatefromgif'; break; case "\xFF\xD8\xFF": - $ICFSreplacementFunctionName = 'ImageCreateFromJPEG'; + $ICFSreplacementFunctionName = 'imagecreatefromjpeg'; break; case "\x89".'PN': - $ICFSreplacementFunctionName = 'ImageCreateFromPNG'; + $ICFSreplacementFunctionName = 'imagecreatefrompng'; break; default: $this->DebugMessage('ImageCreateFromStringReplacement() failed: unknown fileformat signature "'.phpthumb_functions::HexCharDisplay(substr($RawImageData, 0, 3)).'"', __FILE__, __LINE__); return false; break; } + $ErrorMessage = ''; if ($tempnam = $this->phpThumb_tempnam()) { if ($fp_tempnam = @fopen($tempnam, 'wb')) { fwrite($fp_tempnam, $RawImageData); fclose($fp_tempnam); - if (($ICFSreplacementFunctionName == 'ImageCreateFromGIF') && !function_exists($ICFSreplacementFunctionName)) { + @chmod($tempnam, $this->getParameter('config_file_create_mask')); + if (($ICFSreplacementFunctionName == 'imagecreatefromgif') && !function_exists($ICFSreplacementFunctionName)) { - // Need to create from GIF file, but ImageCreateFromGIF does not exist + // Need to create from GIF file, but imagecreatefromgif does not exist ob_start(); if (!@include_once(dirname(__FILE__).'/phpthumb.gif.php')) { $ErrorMessage = 'Failed to include required file "'.dirname(__FILE__).'/phpthumb.gif.php" in '.__FILE__.' on line '.__LINE__; @@ -4276,25 +4329,29 @@ function ImageCreateFromStringReplacement(&$RawImageData, $DieOnErrors=false) { function ImageResizeFunction(&$dst_im, &$src_im, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH) { $this->DebugMessage('ImageResizeFunction($o, $s, '.$dstX.', '.$dstY.', '.$srcX.', '.$srcY.', '.$dstW.', '.$dstH.', '.$srcW.', '.$srcH.')', __FILE__, __LINE__); if (($dstW == $srcW) && ($dstH == $srcH)) { - return ImageCopy($dst_im, $src_im, $dstX, $dstY, $srcX, $srcY, $srcW, $srcH); + return imagecopy($dst_im, $src_im, $dstX, $dstY, $srcX, $srcY, $srcW, $srcH); } if (phpthumb_functions::gd_version() >= 2.0) { if ($this->config_disable_imagecopyresampled) { return phpthumb_functions::ImageCopyResampleBicubic($dst_im, $src_im, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH); } - return ImageCopyResampled($dst_im, $src_im, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH); + return imagecopyresampled($dst_im, $src_im, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH); } - return ImageCopyResized($dst_im, $src_im, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH); + return imagecopyresized($dst_im, $src_im, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH); } function InitializeTempDirSetting() { - $this->config_temp_directory = realpath($this->config_temp_directory ? $this->config_temp_directory : (getenv('TMPDIR') ? getenv('TMPDIR') : getenv('TMP'))); + $this->config_temp_directory = ($this->config_temp_directory ? $this->config_temp_directory : (function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : '')); // sys_get_temp_dir added in PHP v5.2.1 + $this->config_temp_directory = ($this->config_temp_directory ? $this->config_temp_directory : getenv('TMPDIR')); + $this->config_temp_directory = ($this->config_temp_directory ? $this->config_temp_directory : getenv('TMP')); + $this->config_temp_directory = ($this->config_temp_directory ? $this->config_temp_directory : ini_get('upload_tmp_dir')); + $this->config_temp_directory = $this->realPathSafe($this->config_temp_directory); return true; } function phpThumb_tempnam() { $this->InitializeTempDirSetting(); - $tempnam = realpath(tempnam($this->config_temp_directory, 'pThumb')); + $tempnam = $this->realPathSafe(tempnam($this->config_temp_directory, 'pThumb')); $this->tempFilesToDelete[$tempnam] = $tempnam; $this->DebugMessage('phpThumb_tempnam() returning "'.$tempnam.'"', __FILE__, __LINE__); return $tempnam; diff --git a/external/phpThumb/phpthumb.filters.php b/external/phpThumb/phpthumb.filters.php index b3de870ac1..89c8b22836 100644 --- a/external/phpThumb/phpthumb.filters.php +++ b/external/phpThumb/phpthumb.filters.php @@ -11,11 +11,12 @@ class phpthumb_filters { + /** + * @var phpthumb + */ + var $phpThumbObject = null; - function __construct() { - return true; - } function DebugMessage($message, $file='', $line='') { if (is_object($this->phpThumbObject)) { @@ -25,7 +26,6 @@ function DebugMessage($message, $file='', $line='') { } - public function ApplyMask(&$gdimg_mask, &$gdimg_image) { if (phpthumb_functions::gd_version() < 2) { $this->DebugMessage('Skipping ApplyMask() because gd_version is "'.phpthumb_functions::gd_version().'"', __FILE__, __LINE__); @@ -34,34 +34,34 @@ public function ApplyMask(&$gdimg_mask, &$gdimg_image) { if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=')) { $this->DebugMessage('Using alpha ApplyMask() technique', __FILE__, __LINE__); - if ($gdimg_mask_resized = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg_image), ImageSY($gdimg_image))) { + if ($gdimg_mask_resized = phpthumb_functions::ImageCreateFunction(imagesx($gdimg_image), imagesy($gdimg_image))) { - ImageCopyResampled($gdimg_mask_resized, $gdimg_mask, 0, 0, 0, 0, ImageSX($gdimg_image), ImageSY($gdimg_image), ImageSX($gdimg_mask), ImageSY($gdimg_mask)); - if ($gdimg_mask_blendtemp = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg_image), ImageSY($gdimg_image))) { + imagecopyresampled($gdimg_mask_resized, $gdimg_mask, 0, 0, 0, 0, imagesx($gdimg_image), imagesy($gdimg_image), imagesx($gdimg_mask), imagesy($gdimg_mask)); + if ($gdimg_mask_blendtemp = phpthumb_functions::ImageCreateFunction(imagesx($gdimg_image), imagesy($gdimg_image))) { - $color_background = ImageColorAllocate($gdimg_mask_blendtemp, 0, 0, 0); - ImageFilledRectangle($gdimg_mask_blendtemp, 0, 0, ImageSX($gdimg_mask_blendtemp), ImageSY($gdimg_mask_blendtemp), $color_background); - ImageAlphaBlending($gdimg_mask_blendtemp, false); - ImageSaveAlpha($gdimg_mask_blendtemp, true); - for ($x = 0; $x < ImageSX($gdimg_image); $x++) { - for ($y = 0; $y < ImageSY($gdimg_image); $y++) { + $color_background = imagecolorallocate($gdimg_mask_blendtemp, 0, 0, 0); + imagefilledrectangle($gdimg_mask_blendtemp, 0, 0, imagesx($gdimg_mask_blendtemp), imagesy($gdimg_mask_blendtemp), $color_background); + imagealphablending($gdimg_mask_blendtemp, false); + imagesavealpha($gdimg_mask_blendtemp, true); + for ($x = 0; $x < imagesx($gdimg_image); $x++) { + for ($y = 0; $y < imagesy($gdimg_image); $y++) { //$RealPixel = phpthumb_functions::GetPixelColor($gdimg_mask_blendtemp, $x, $y); $RealPixel = phpthumb_functions::GetPixelColor($gdimg_image, $x, $y); $MaskPixel = phpthumb_functions::GrayscalePixel(phpthumb_functions::GetPixelColor($gdimg_mask_resized, $x, $y)); $MaskAlpha = 127 - (floor($MaskPixel['red'] / 2) * (1 - ($RealPixel['alpha'] / 127))); $newcolor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_mask_blendtemp, $RealPixel['red'], $RealPixel['green'], $RealPixel['blue'], $MaskAlpha); - ImageSetPixel($gdimg_mask_blendtemp, $x, $y, $newcolor); + imagesetpixel($gdimg_mask_blendtemp, $x, $y, $newcolor); } } - ImageAlphaBlending($gdimg_image, false); - ImageSaveAlpha($gdimg_image, true); - ImageCopy($gdimg_image, $gdimg_mask_blendtemp, 0, 0, 0, 0, ImageSX($gdimg_mask_blendtemp), ImageSY($gdimg_mask_blendtemp)); - ImageDestroy($gdimg_mask_blendtemp); + imagealphablending($gdimg_image, false); + imagesavealpha($gdimg_image, true); + imagecopy($gdimg_image, $gdimg_mask_blendtemp, 0, 0, 0, 0, imagesx($gdimg_mask_blendtemp), imagesy($gdimg_mask_blendtemp)); + imagedestroy($gdimg_mask_blendtemp); } else { $this->DebugMessage('ImageCreateFunction() failed', __FILE__, __LINE__); } - ImageDestroy($gdimg_mask_resized); + imagedestroy($gdimg_mask_resized); } else { $this->DebugMessage('ImageCreateFunction() failed', __FILE__, __LINE__); @@ -80,32 +80,32 @@ function Bevel(&$gdimg, $width, $hexcolor1, $hexcolor2) { $hexcolor1 = ($hexcolor1 ? $hexcolor1 : 'FFFFFF'); $hexcolor2 = ($hexcolor2 ? $hexcolor2 : '000000'); - ImageAlphaBlending($gdimg, true); + imagealphablending($gdimg, true); for ($i = 0; $i < $width; $i++) { $alpha = round(($i / $width) * 127); $color1 = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor1, false, $alpha); $color2 = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor2, false, $alpha); - ImageLine($gdimg, $i, $i + 1, $i, ImageSY($gdimg) - $i - 1, $color1); // left - ImageLine($gdimg, $i, $i , ImageSX($gdimg) - $i, $i , $color1); // top - ImageLine($gdimg, ImageSX($gdimg) - $i, ImageSY($gdimg) - $i - 1, ImageSX($gdimg) - $i, $i + 1, $color2); // right - ImageLine($gdimg, ImageSX($gdimg) - $i, ImageSY($gdimg) - $i , $i, ImageSY($gdimg) - $i , $color2); // bottom + imageline($gdimg, $i, $i + 1, $i, imagesy($gdimg) - $i - 1, $color1); // left + imageline($gdimg, $i, $i , imagesx($gdimg) - $i, $i , $color1); // top + imageline($gdimg, imagesx($gdimg) - $i, imagesy($gdimg) - $i - 1, imagesx($gdimg) - $i, $i + 1, $color2); // right + imageline($gdimg, imagesx($gdimg) - $i, imagesy($gdimg) - $i , $i, imagesy($gdimg) - $i , $color2); // bottom } return true; } public function Blur(&$gdimg, $radius=0.5) { - // Taken from Torstein H�nsi's phpUnsharpMask (see phpthumb.unsharp.php) + // Taken from Torstein Hønsi's phpUnsharpMask (see phpthumb.unsharp.php) $radius = round(max(0, min($radius, 50)) * 2); if (!$radius) { return false; } - $w = ImageSX($gdimg); - $h = ImageSY($gdimg); - if ($imgBlur = ImageCreateTrueColor($w, $h)) { + $w = imagesx($gdimg); + $h = imagesy($gdimg); + if ($imgBlur = imagecreatetruecolor($w, $h)) { // Gaussian blur matrix: // 1 2 1 // 2 4 2 @@ -114,16 +114,16 @@ public function Blur(&$gdimg, $radius=0.5) { // Move copies of the image around one pixel at the time and merge them with weight // according to the matrix. The same matrix is simply repeated for higher radii. for ($i = 0; $i < $radius; $i++) { - ImageCopy ($imgBlur, $gdimg, 0, 0, 1, 1, $w - 1, $h - 1); // up left - ImageCopyMerge($imgBlur, $gdimg, 1, 1, 0, 0, $w, $h, 50.00000); // down right - ImageCopyMerge($imgBlur, $gdimg, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left - ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 1, $w, $h - 1, 25.00000); // up right - ImageCopyMerge($imgBlur, $gdimg, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left - ImageCopyMerge($imgBlur, $gdimg, 1, 0, 0, 0, $w, $h, 25.00000); // right - ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 1, $w, $h - 1, 20.00000); // up - ImageCopyMerge($imgBlur, $gdimg, 0, 1, 0, 0, $w, $h, 16.666667); // down - ImageCopyMerge($imgBlur, $gdimg, 0, 0, 0, 0, $w, $h, 50.000000); // center - ImageCopy ($gdimg, $imgBlur, 0, 0, 0, 0, $w, $h); + imagecopy ($imgBlur, $gdimg, 0, 0, 1, 1, $w - 1, $h - 1); // up left + imagecopymerge($imgBlur, $gdimg, 1, 1, 0, 0, $w, $h, 50.00000); // down right + imagecopymerge($imgBlur, $gdimg, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left + imagecopymerge($imgBlur, $gdimg, 1, 0, 0, 1, $w, $h - 1, 25.00000); // up right + imagecopymerge($imgBlur, $gdimg, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left + imagecopymerge($imgBlur, $gdimg, 1, 0, 0, 0, $w, $h, 25.00000); // right + imagecopymerge($imgBlur, $gdimg, 0, 0, 0, 1, $w, $h - 1, 20.00000); // up + imagecopymerge($imgBlur, $gdimg, 0, 1, 0, 0, $w, $h, 16.666667); // down + imagecopymerge($imgBlur, $gdimg, 0, 0, 0, 0, $w, $h, 50.000000); // center + imagecopy ($gdimg, $imgBlur, 0, 0, 0, 0, $w, $h); } return true; } @@ -133,10 +133,10 @@ public function Blur(&$gdimg, $radius=0.5) { public function BlurGaussian(&$gdimg) { if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - if (ImageFilter($gdimg, IMG_FILTER_GAUSSIAN_BLUR)) { + if (imagefilter($gdimg, IMG_FILTER_GAUSSIAN_BLUR)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_GAUSSIAN_BLUR)', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_GAUSSIAN_BLUR)', __FILE__, __LINE__); // fall through and try it the hard way } $this->DebugMessage('FAILED: phpthumb_filters::BlurGaussian($gdimg) [using phpthumb_filters::Blur() instead]', __FILE__, __LINE__); @@ -146,10 +146,10 @@ public function BlurGaussian(&$gdimg) { public function BlurSelective(&$gdimg) { if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - if (ImageFilter($gdimg, IMG_FILTER_SELECTIVE_BLUR)) { + if (imagefilter($gdimg, IMG_FILTER_SELECTIVE_BLUR)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_SELECTIVE_BLUR)', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_SELECTIVE_BLUR)', __FILE__, __LINE__); // fall through and try it the hard way } // currently not implemented "the hard way" @@ -165,23 +165,24 @@ public function Brightness(&$gdimg, $amount=0) { $amount = max(-255, min(255, $amount)); if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - if (ImageFilter($gdimg, IMG_FILTER_BRIGHTNESS, $amount)) { + if (imagefilter($gdimg, IMG_FILTER_BRIGHTNESS, $amount)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_BRIGHTNESS, '.$amount.')', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_BRIGHTNESS, '.$amount.')', __FILE__, __LINE__); // fall through and try it the hard way } $scaling = (255 - abs($amount)) / 255; $baseamount = (($amount > 0) ? $amount : 0); - for ($x = 0; $x < ImageSX($gdimg); $x++) { - for ($y = 0; $y < ImageSY($gdimg); $y++) { + for ($x = 0; $x < imagesx($gdimg); $x++) { + for ($y = 0; $y < imagesy($gdimg); $y++) { $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y); + $NewPixel = array(); foreach ($OriginalPixel as $key => $value) { $NewPixel[$key] = round($baseamount + ($OriginalPixel[$key] * $scaling)); } - $newColor = ImageColorAllocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']); - ImageSetPixel($gdimg, $x, $y, $newColor); + $newColor = imagecolorallocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']); + imagesetpixel($gdimg, $x, $y, $newColor); } } return true; @@ -195,12 +196,12 @@ public function Contrast(&$gdimg, $amount=0) { $amount = max(-255, min(255, $amount)); if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - // ImageFilter(IMG_FILTER_CONTRAST) has range +100 to -100 (positive numbers make it darker!) + // imagefilter(IMG_FILTER_CONTRAST) has range +100 to -100 (positive numbers make it darker!) $amount = ($amount / 255) * -100; - if (ImageFilter($gdimg, IMG_FILTER_CONTRAST, $amount)) { + if (imagefilter($gdimg, IMG_FILTER_CONTRAST, $amount)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_CONTRAST, '.$amount.')', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_CONTRAST, '.$amount.')', __FILE__, __LINE__); // fall through and try it the hard way } @@ -209,16 +210,18 @@ public function Contrast(&$gdimg, $amount=0) { } else { $scaling = (255 - abs($amount)) / 255; } - for ($x = 0; $x < ImageSX($gdimg); $x++) { - for ($y = 0; $y < ImageSY($gdimg); $y++) { + for ($x = 0; $x < imagesx($gdimg); $x++) { + for ($y = 0; $y < imagesy($gdimg); $y++) { $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y); + $NewPixel = array(); foreach ($OriginalPixel as $key => $value) { $NewPixel[$key] = min(255, max(0, round($OriginalPixel[$key] * $scaling))); } - $newColor = ImageColorAllocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']); - ImageSetPixel($gdimg, $x, $y, $newColor); + $newColor = imagecolorallocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']); + imagesetpixel($gdimg, $x, $y, $newColor); } } + return true; } @@ -238,32 +241,34 @@ public function Colorize(&$gdimg, $amount, $targetColor) { $r = round($amountPct * hexdec(substr($targetColor, 0, 2))); $g = round($amountPct * hexdec(substr($targetColor, 2, 2))); $b = round($amountPct * hexdec(substr($targetColor, 4, 2))); - if (ImageFilter($gdimg, IMG_FILTER_COLORIZE, $r, $g, $b)) { + if (imagefilter($gdimg, IMG_FILTER_COLORIZE, $r, $g, $b)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_COLORIZE)', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_COLORIZE)', __FILE__, __LINE__); // fall through and try it the hard way } // overridden below for grayscale + $TargetPixel = array(); if ($targetColor != 'gray') { $TargetPixel['red'] = hexdec(substr($targetColor, 0, 2)); $TargetPixel['green'] = hexdec(substr($targetColor, 2, 2)); $TargetPixel['blue'] = hexdec(substr($targetColor, 4, 2)); } - for ($x = 0; $x < ImageSX($gdimg); $x++) { - for ($y = 0; $y < ImageSY($gdimg); $y++) { + for ($x = 0; $x < imagesx($gdimg); $x++) { + for ($y = 0; $y < imagesy($gdimg); $y++) { $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y); if ($targetColor == 'gray') { $TargetPixel = phpthumb_functions::GrayscalePixel($OriginalPixel); } + $NewPixel = array(); foreach ($TargetPixel as $key => $value) { $NewPixel[$key] = round(max(0, min(255, ($OriginalPixel[$key] * ((100 - $amount) / 100)) + ($TargetPixel[$key] * $amountPct)))); } //$newColor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue'], $OriginalPixel['alpha']); - $newColor = ImageColorAllocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']); - ImageSetPixel($gdimg, $x, $y, $newColor); + $newColor = imagecolorallocate($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue']); + imagesetpixel($gdimg, $x, $y, $newColor); } } return true; @@ -274,8 +279,8 @@ public function Crop(&$gdimg, $left=0, $right=0, $top=0, $bottom=0) { if (!$left && !$right && !$top && !$bottom) { return true; } - $oldW = ImageSX($gdimg); - $oldH = ImageSY($gdimg); + $oldW = imagesx($gdimg); + $oldH = imagesy($gdimg); if (($left > 0) && ($left < 1)) { $left = round($left * $oldW); } if (($right > 0) && ($right < 1)) { $right = round($right * $oldW); } if (($top > 0) && ($top < 1)) { $top = round($top * $oldH); } @@ -285,14 +290,14 @@ public function Crop(&$gdimg, $left=0, $right=0, $top=0, $bottom=0) { $newW = $oldW - $left - $right; $newH = $oldH - $top - $bottom; - if ($imgCropped = ImageCreateTrueColor($newW, $newH)) { - ImageCopy($imgCropped, $gdimg, 0, 0, $left, $top, $newW, $newH); - if ($gdimg = ImageCreateTrueColor($newW, $newH)) { - ImageCopy($gdimg, $imgCropped, 0, 0, 0, 0, $newW, $newH); - ImageDestroy($imgCropped); + if ($imgCropped = imagecreatetruecolor($newW, $newH)) { + imagecopy($imgCropped, $gdimg, 0, 0, $left, $top, $newW, $newH); + if ($gdimg = imagecreatetruecolor($newW, $newH)) { + imagecopy($gdimg, $imgCropped, 0, 0, 0, 0, $newW, $newH); + imagedestroy($imgCropped); return true; } - ImageDestroy($imgCropped); + imagedestroy($imgCropped); } return false; } @@ -325,29 +330,30 @@ public function DropShadow(&$gdimg, $distance, $width, $hexcolor, $angle, $alpha return true; } - $width_shadow = cos(deg2rad($angle)) * ($distance + $width); - $height_shadow = sin(deg2rad($angle)) * ($distance + $width); - - $scaling = min(ImageSX($gdimg) / (ImageSX($gdimg) + abs($width_shadow)), ImageSY($gdimg) / (ImageSY($gdimg) + abs($height_shadow))); + //$width_shadow = cos(deg2rad($angle)) * ($distance + $width); + //$height_shadow = sin(deg2rad($angle)) * ($distance + $width); + //$scaling = min(imagesx($gdimg) / (imagesx($gdimg) + abs($width_shadow)), imagesy($gdimg) / (imagesy($gdimg) + abs($height_shadow))); + $Offset = array(); for ($i = 0; $i < $width; $i++) { $WidthAlpha[$i] = (abs(($width / 2) - $i) / $width); $Offset['x'] = cos(deg2rad($angle)) * ($distance + $i); $Offset['y'] = sin(deg2rad($angle)) * ($distance + $i); } - $tempImageWidth = ImageSX($gdimg) + abs($Offset['x']); - $tempImageHeight = ImageSY($gdimg) + abs($Offset['y']); + $tempImageWidth = imagesx($gdimg) + abs($Offset['x']); + $tempImageHeight = imagesy($gdimg) + abs($Offset['y']); if ($gdimg_dropshadow_temp = phpthumb_functions::ImageCreateFunction($tempImageWidth, $tempImageHeight)) { - ImageAlphaBlending($gdimg_dropshadow_temp, false); - ImageSaveAlpha($gdimg_dropshadow_temp, true); + imagealphablending($gdimg_dropshadow_temp, false); + imagesavealpha($gdimg_dropshadow_temp, true); $transparent1 = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_dropshadow_temp, 0, 0, 0, 127); - ImageFill($gdimg_dropshadow_temp, 0, 0, $transparent1); + imagefill($gdimg_dropshadow_temp, 0, 0, $transparent1); - for ($x = 0; $x < ImageSX($gdimg); $x++) { - for ($y = 0; $y < ImageSY($gdimg); $y++) { + $PixelMap = array(); + for ($x = 0; $x < imagesx($gdimg); $x++) { + for ($y = 0; $y < imagesy($gdimg); $y++) { $PixelMap[$x][$y] = phpthumb_functions::GetPixelColor($gdimg, $x, $y); } } @@ -358,31 +364,31 @@ public function DropShadow(&$gdimg, $distance, $width, $hexcolor, $angle, $alpha if (!isset($PixelMap[$x][$y]['alpha']) || ($PixelMap[$x][$y]['alpha'] > 0)) { if (isset($PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha']) && ($PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha'] < 127)) { $thisColor = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor, false, $PixelMap[$x + $Offset['x']][$y + $Offset['y']]['alpha']); - ImageSetPixel($gdimg_dropshadow_temp, $x, $y, $thisColor); + imagesetpixel($gdimg_dropshadow_temp, $x, $y, $thisColor); } } } } } - ImageAlphaBlending($gdimg_dropshadow_temp, true); - for ($x = 0; $x < ImageSX($gdimg); $x++) { - for ($y = 0; $y < ImageSY($gdimg); $y++) { + imagealphablending($gdimg_dropshadow_temp, true); + for ($x = 0; $x < imagesx($gdimg); $x++) { + for ($y = 0; $y < imagesy($gdimg); $y++) { if ($PixelMap[$x][$y]['alpha'] < 127) { $thisColor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_dropshadow_temp, $PixelMap[$x][$y]['red'], $PixelMap[$x][$y]['green'], $PixelMap[$x][$y]['blue'], $PixelMap[$x][$y]['alpha']); - ImageSetPixel($gdimg_dropshadow_temp, $x, $y, $thisColor); + imagesetpixel($gdimg_dropshadow_temp, $x, $y, $thisColor); } } } - ImageSaveAlpha($gdimg, true); - ImageAlphaBlending($gdimg, false); + imagesavealpha($gdimg, true); + imagealphablending($gdimg, false); //$this->is_alpha = true; $transparent2 = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, 0, 0, 0, 127); - ImageFilledRectangle($gdimg, 0, 0, ImageSX($gdimg), ImageSY($gdimg), $transparent2); - ImageCopyResampled($gdimg, $gdimg_dropshadow_temp, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg), ImageSX($gdimg_dropshadow_temp), ImageSY($gdimg_dropshadow_temp)); + imagefilledrectangle($gdimg, 0, 0, imagesx($gdimg), imagesy($gdimg), $transparent2); + imagecopyresampled($gdimg, $gdimg_dropshadow_temp, 0, 0, 0, 0, imagesx($gdimg), imagesy($gdimg), imagesx($gdimg_dropshadow_temp), imagesy($gdimg_dropshadow_temp)); - ImageDestroy($gdimg_dropshadow_temp); + imagedestroy($gdimg_dropshadow_temp); } return true; } @@ -390,10 +396,10 @@ public function DropShadow(&$gdimg, $distance, $width, $hexcolor, $angle, $alpha public function EdgeDetect(&$gdimg) { if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - if (ImageFilter($gdimg, IMG_FILTER_EDGEDETECT)) { + if (imagefilter($gdimg, IMG_FILTER_EDGEDETECT)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_EDGEDETECT)', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_EDGEDETECT)', __FILE__, __LINE__); // fall through and try it the hard way } // currently not implemented "the hard way" @@ -402,28 +408,28 @@ public function EdgeDetect(&$gdimg) { } - public function Elipse($gdimg) { + public function Ellipse($gdimg) { if (phpthumb_functions::gd_version() < 2) { return false; } // generate mask at twice desired resolution and downsample afterwards for easy antialiasing - if ($gdimg_elipsemask_double = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg) * 2, ImageSY($gdimg) * 2)) { - if ($gdimg_elipsemask = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg), ImageSY($gdimg))) { + if ($gdimg_ellipsemask_double = phpthumb_functions::ImageCreateFunction(imagesx($gdimg) * 2, imagesy($gdimg) * 2)) { + if ($gdimg_ellipsemask = phpthumb_functions::ImageCreateFunction(imagesx($gdimg), imagesy($gdimg))) { - $color_transparent = ImageColorAllocate($gdimg_elipsemask_double, 255, 255, 255); - ImageFilledEllipse($gdimg_elipsemask_double, ImageSX($gdimg), ImageSY($gdimg), (ImageSX($gdimg) - 1) * 2, (ImageSY($gdimg) - 1) * 2, $color_transparent); - ImageCopyResampled($gdimg_elipsemask, $gdimg_elipsemask_double, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg), ImageSX($gdimg) * 2, ImageSY($gdimg) * 2); + $color_transparent = imagecolorallocate($gdimg_ellipsemask_double, 255, 255, 255); + imagefilledellipse($gdimg_ellipsemask_double, imagesx($gdimg), imagesy($gdimg), (imagesx($gdimg) - 1) * 2, (imagesy($gdimg) - 1) * 2, $color_transparent); + imagecopyresampled($gdimg_ellipsemask, $gdimg_ellipsemask_double, 0, 0, 0, 0, imagesx($gdimg), imagesy($gdimg), imagesx($gdimg) * 2, imagesy($gdimg) * 2); - phpthumb_filters::ApplyMask($gdimg_elipsemask, $gdimg); - ImageDestroy($gdimg_elipsemask); + phpthumb_filters::ApplyMask($gdimg_ellipsemask, $gdimg); + imagedestroy($gdimg_ellipsemask); return true; } else { - $this->DebugMessage('$gdimg_elipsemask = phpthumb_functions::ImageCreateFunction() failed', __FILE__, __LINE__); + $this->DebugMessage('$gdimg_ellipsemask = phpthumb_functions::ImageCreateFunction() failed', __FILE__, __LINE__); } - ImageDestroy($gdimg_elipsemask_double); + imagedestroy($gdimg_ellipsemask_double); } else { - $this->DebugMessage('$gdimg_elipsemask_double = phpthumb_functions::ImageCreateFunction() failed', __FILE__, __LINE__); + $this->DebugMessage('$gdimg_ellipsemask_double = phpthumb_functions::ImageCreateFunction() failed', __FILE__, __LINE__); } return false; } @@ -431,10 +437,10 @@ public function Elipse($gdimg) { public function Emboss(&$gdimg) { if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - if (ImageFilter($gdimg, IMG_FILTER_EMBOSS)) { + if (imagefilter($gdimg, IMG_FILTER_EMBOSS)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_EMBOSS)', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_EMBOSS)', __FILE__, __LINE__); // fall through and try it the hard way } // currently not implemented "the hard way" @@ -447,20 +453,20 @@ public function Flip(&$gdimg, $x=false, $y=false) { if (!$x && !$y) { return false; } - if ($tempImage = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg), ImageSY($gdimg))) { + if ($tempImage = phpthumb_functions::ImageCreateFunction(imagesx($gdimg), imagesy($gdimg))) { if ($x) { - ImageCopy($tempImage, $gdimg, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg)); - for ($x = 0; $x < ImageSX($gdimg); $x++) { - ImageCopy($gdimg, $tempImage, ImageSX($gdimg) - 1 - $x, 0, $x, 0, 1, ImageSY($gdimg)); + imagecopy($tempImage, $gdimg, 0, 0, 0, 0, imagesx($gdimg), imagesy($gdimg)); + for ($x = 0; $x < imagesx($gdimg); $x++) { + imagecopy($gdimg, $tempImage, imagesx($gdimg) - 1 - $x, 0, $x, 0, 1, imagesy($gdimg)); } } if ($y) { - ImageCopy($tempImage, $gdimg, 0, 0, 0, 0, ImageSX($gdimg), ImageSY($gdimg)); - for ($y = 0; $y < ImageSY($gdimg); $y++) { - ImageCopy($gdimg, $tempImage, 0, ImageSY($gdimg) - 1 - $y, 0, $y, ImageSX($gdimg), 1); + imagecopy($tempImage, $gdimg, 0, 0, 0, 0, imagesx($gdimg), imagesy($gdimg)); + for ($y = 0; $y < imagesy($gdimg); $y++) { + imagecopy($gdimg, $tempImage, 0, imagesy($gdimg) - 1 - $y, 0, $y, imagesx($gdimg), 1); } } - ImageDestroy($tempImage); + imagedestroy($tempImage); } return true; } @@ -478,21 +484,21 @@ public function Frame(&$gdimg, $frame_width, $edge_width, $hexcolor_frame, $hexc $color2 = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor2); for ($i = 0; $i < $edge_width; $i++) { // outer bevel - ImageLine($gdimg, $i, $i, $i, ImageSY($gdimg) - $i, $color1); // left - ImageLine($gdimg, $i, $i, ImageSX($gdimg) - $i, $i, $color1); // top - ImageLine($gdimg, ImageSX($gdimg) - $i, ImageSY($gdimg) - $i, ImageSX($gdimg) - $i, $i, $color2); // right - ImageLine($gdimg, ImageSX($gdimg) - $i, ImageSY($gdimg) - $i, $i, ImageSY($gdimg) - $i, $color2); // bottom + imageline($gdimg, $i, $i, $i, imagesy($gdimg) - $i, $color1); // left + imageline($gdimg, $i, $i, imagesx($gdimg) - $i, $i, $color1); // top + imageline($gdimg, imagesx($gdimg) - $i, imagesy($gdimg) - $i, imagesx($gdimg) - $i, $i, $color2); // right + imageline($gdimg, imagesx($gdimg) - $i, imagesy($gdimg) - $i, $i, imagesy($gdimg) - $i, $color2); // bottom } for ($i = 0; $i < $frame_width; $i++) { // actual frame - ImageRectangle($gdimg, $edge_width + $i, $edge_width + $i, ImageSX($gdimg) - $edge_width - $i, ImageSY($gdimg) - $edge_width - $i, $color_frame); + imagerectangle($gdimg, $edge_width + $i, $edge_width + $i, imagesx($gdimg) - $edge_width - $i, imagesy($gdimg) - $edge_width - $i, $color_frame); } for ($i = 0; $i < $edge_width; $i++) { // inner bevel - ImageLine($gdimg, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, $color2); // left - ImageLine($gdimg, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, ImageSX($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, $color2); // top - ImageLine($gdimg, ImageSX($gdimg) - $frame_width - $edge_width - $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, ImageSX($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, $color1); // right - ImageLine($gdimg, ImageSX($gdimg) - $frame_width - $edge_width - $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, ImageSY($gdimg) - $frame_width - $edge_width - $i, $color1); // bottom + imageline($gdimg, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, imagesy($gdimg) - $frame_width - $edge_width - $i, $color2); // left + imageline($gdimg, $frame_width + $edge_width + $i, $frame_width + $edge_width + $i, imagesx($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, $color2); // top + imageline($gdimg, imagesx($gdimg) - $frame_width - $edge_width - $i, imagesy($gdimg) - $frame_width - $edge_width - $i, imagesx($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, $color1); // right + imageline($gdimg, imagesx($gdimg) - $frame_width - $edge_width - $i, imagesy($gdimg) - $frame_width - $edge_width - $i, $frame_width + $edge_width + $i, imagesy($gdimg) - $frame_width - $edge_width - $i, $color1); // bottom } return true; } @@ -502,16 +508,16 @@ public function Gamma(&$gdimg, $amount) { if (number_format($amount, 4) == '1.0000') { return true; } - return ImageGammaCorrect($gdimg, 1.0, $amount); + return imagegammacorrect($gdimg, 1.0, $amount); } public function Grayscale(&$gdimg) { if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - if (ImageFilter($gdimg, IMG_FILTER_GRAYSCALE)) { + if (imagefilter($gdimg, IMG_FILTER_GRAYSCALE)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_GRAYSCALE)', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_GRAYSCALE)', __FILE__, __LINE__); // fall through and try it the hard way } return phpthumb_filters::Colorize($gdimg, 100, 'gray'); @@ -519,8 +525,9 @@ public function Grayscale(&$gdimg) { public function HistogramAnalysis(&$gdimg, $calculateGray=false) { - $ImageSX = ImageSX($gdimg); - $ImageSY = ImageSY($gdimg); + $ImageSX = imagesx($gdimg); + $ImageSY = imagesy($gdimg); + $Analysis = array(); for ($x = 0; $x < $ImageSX; $x++) { for ($y = 0; $y < $ImageSY; $y++) { $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y); @@ -562,49 +569,46 @@ public function HistogramStretch(&$gdimg, $band='*', $method=0, $threshold=0.1) // from the limit and allow (default = 0.1%) of brightest/darkest // pixels to be clipped to min/max $threshold = floatval($threshold) / 100; - $clip_threshold = ImageSX($gdimg) * ImageSX($gdimg) * $threshold; - //if ($min >= 0) { - // $range_min = min($min, 255); - //} else { - $countsum = 0; - for ($i = 0; $i <= 255; $i++) { - if ($method == 0) { - $countsum = max(@$Analysis['red'][$i], @$Analysis['green'][$i], @$Analysis['blue'][$i]); - } else { - $countsum += @$Analysis[$key][$i]; - } - if ($countsum >= $clip_threshold) { - $range_min = $i - 1; - break; - } + $clip_threshold = imagesx($gdimg) * imagesx($gdimg) * $threshold; + + $countsum = 0; + $range_min = 0; + for ($i = 0; $i <= 255; $i++) { + if ($method == 0) { + $countsum = max(@$Analysis['red'][$i], @$Analysis['green'][$i], @$Analysis['blue'][$i]); + } else { + $countsum += @$Analysis[$key][$i]; } - $range_min = max($range_min, 0); - //} - //if ($max > 0) { - // $range_max = max($max, 255); - //} else { - $countsum = 0; - for ($i = 255; $i >= 0; $i--) { - if ($method == 0) { - $countsum = max(@$Analysis['red'][$i], @$Analysis['green'][$i], @$Analysis['blue'][$i]); - } else { - $countsum += @$Analysis[$key][$i]; - } - if ($countsum >= $clip_threshold) { - $range_max = $i + 1; - break; - } + if ($countsum >= $clip_threshold) { + $range_min = $i - 1; + break; + } + } + $range_min = max($range_min, 0); + + $countsum = 0; + $range_max = 255; + for ($i = 255; $i >= 0; $i--) { + if ($method == 0) { + $countsum = max(@$Analysis['red'][$i], @$Analysis['green'][$i], @$Analysis['blue'][$i]); + } else { + $countsum += @$Analysis[$key][$i]; } - $range_max = min($range_max, 255); - //} + if ($countsum >= $clip_threshold) { + $range_max = $i + 1; + break; + } + } + $range_max = min($range_max, 255); + $range_scale = (($range_max == $range_min) ? 1 : (255 / ($range_max - $range_min))); if (($range_min == 0) && ($range_max == 255)) { // no adjustment neccesary - don't waste CPU time! return true; } - $ImageSX = ImageSX($gdimg); - $ImageSY = ImageSY($gdimg); + $ImageSX = imagesx($gdimg); + $ImageSY = imagesy($gdimg); for ($x = 0; $x < $ImageSX; $x++) { for ($y = 0; $y < $ImageSY; $y++) { $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y); @@ -618,7 +622,7 @@ public function HistogramStretch(&$gdimg, $band='*', $method=0, $threshold=0.1) $new[$key] = min(255, max(0, ($OriginalPixel[$key] - $range_min) * $range_scale)); } $newColor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, $new['red'], $new['green'], $new['blue'], $new['alpha']); - ImageSetPixel($gdimg, $x, $y, $newColor); + imagesetpixel($gdimg, $x, $y, $newColor); } } @@ -630,21 +634,21 @@ public function HistogramOverlay(&$gdimg, $bands='*', $colors='', $width=0.25, $ $margin_y = (is_null($margin_y) ? $margin_x : $margin_y); $Analysis = phpthumb_filters::HistogramAnalysis($gdimg, true); - $histW = round(($width > 1) ? min($width, ImageSX($gdimg)) : ImageSX($gdimg) * $width); - $histH = round(($width > 1) ? min($width, ImageSX($gdimg)) : ImageSX($gdimg) * $width); - if ($gdHist = ImageCreateTrueColor($histW, $histH)) { + $histW = round(($width > 1) ? min($width, imagesx($gdimg)) : imagesx($gdimg) * $width); + $histH = round(($width > 1) ? min($width, imagesx($gdimg)) : imagesx($gdimg) * $width); + if ($gdHist = imagecreatetruecolor($histW, $histH)) { $color_back = phpthumb_functions::ImageColorAllocateAlphaSafe($gdHist, 0, 0, 0, 127); - ImageFilledRectangle($gdHist, 0, 0, $histW, $histH, $color_back); - ImageAlphaBlending($gdHist, false); - ImageSaveAlpha($gdHist, true); + imagefilledrectangle($gdHist, 0, 0, $histW, $histH, $color_back); + imagealphablending($gdHist, false); + imagesavealpha($gdHist, true); $HistogramTempWidth = 256; $HistogramTempHeight = 100; - if ($gdHistTemp = ImageCreateTrueColor($HistogramTempWidth, $HistogramTempHeight)) { + if ($gdHistTemp = imagecreatetruecolor($HistogramTempWidth, $HistogramTempHeight)) { $color_back_temp = phpthumb_functions::ImageColorAllocateAlphaSafe($gdHistTemp, 255, 0, 255, 127); - ImageAlphaBlending($gdHistTemp, false); - ImageSaveAlpha($gdHistTemp, true); - ImageFilledRectangle($gdHistTemp, 0, 0, ImageSX($gdHistTemp), ImageSY($gdHistTemp), $color_back_temp); + imagealphablending($gdHistTemp, false); + imagesavealpha($gdHistTemp, true); + imagefilledrectangle($gdHistTemp, 0, 0, imagesx($gdHistTemp), imagesy($gdHistTemp), $color_back_temp); $DefaultColors = array('r'=>'FF0000', 'g'=>'00FF00', 'b'=>'0000FF', 'a'=>'999999', '*'=>'FFFFFF'); $Colors = explode(';', $colors); @@ -657,19 +661,19 @@ public function HistogramOverlay(&$gdimg, $bands='*', $colors='', $width=0.25, $ $PeakValue = max($Analysis[$keys[$band]]); $thisColor = phpthumb_functions::ImageHexColorAllocate($gdHistTemp, phpthumb_functions::IsHexColor(@$Colors[$key]) ? $Colors[$key] : $DefaultColors[$band]); for ($x = 0; $x < $HistogramTempWidth; $x++) { - ImageLine($gdHistTemp, $x, $HistogramTempHeight - 1, $x, $HistogramTempHeight - 1 - round(@$Analysis[$keys[$band]][$x] / $PeakValue * $HistogramTempHeight), $thisColor); + imageline($gdHistTemp, $x, $HistogramTempHeight - 1, $x, $HistogramTempHeight - 1 - round(@$Analysis[$keys[$band]][$x] / $PeakValue * $HistogramTempHeight), $thisColor); } - ImageLine($gdHistTemp, 0, $HistogramTempHeight - 1, $HistogramTempWidth - 1, $HistogramTempHeight - 1, $thisColor); - ImageLine($gdHistTemp, 0, $HistogramTempHeight - 2, $HistogramTempWidth - 1, $HistogramTempHeight - 2, $thisColor); + imageline($gdHistTemp, 0, $HistogramTempHeight - 1, $HistogramTempWidth - 1, $HistogramTempHeight - 1, $thisColor); + imageline($gdHistTemp, 0, $HistogramTempHeight - 2, $HistogramTempWidth - 1, $HistogramTempHeight - 2, $thisColor); } - ImageCopyResampled($gdHist, $gdHistTemp, 0, 0, 0, 0, ImageSX($gdHist), ImageSY($gdHist), ImageSX($gdHistTemp), ImageSY($gdHistTemp)); - ImageDestroy($gdHistTemp); + imagecopyresampled($gdHist, $gdHistTemp, 0, 0, 0, 0, imagesx($gdHist), imagesy($gdHist), imagesx($gdHistTemp), imagesy($gdHistTemp)); + imagedestroy($gdHistTemp); } else { return false; } phpthumb_filters::WatermarkOverlay($gdimg, $gdHist, $alignment, $opacity, $margin_x, $margin_y); - ImageDestroy($gdHist); + imagedestroy($gdHist); return true; } return false; @@ -681,68 +685,63 @@ public function ImageBorder(&$gdimg, $border_width, $radius_x, $radius_y, $hexco $radius_x = ($radius_x ? $radius_x : 0); $radius_y = ($radius_y ? $radius_y : 0); - $output_width = ImageSX($gdimg); - $output_height = ImageSY($gdimg); + $output_width = imagesx($gdimg); + $output_height = imagesy($gdimg); list($new_width, $new_height) = phpthumb_functions::ProportionalResize($output_width, $output_height, $output_width - max($border_width * 2, $radius_x), $output_height - max($border_width * 2, $radius_y)); $offset_x = ($radius_x ? $output_width - $new_width - $radius_x : 0); - $offset_y = ($radius_y ? $output_height - $new_height - $radius_y : 0); -//header('Content-Type: image/png'); -//ImagePNG($gdimg); -//exit; if ($gd_border_canvas = phpthumb_functions::ImageCreateFunction($output_width, $output_height)) { - ImageSaveAlpha($gd_border_canvas, true); - ImageAlphaBlending($gd_border_canvas, false); + imagesavealpha($gd_border_canvas, true); + imagealphablending($gd_border_canvas, false); $color_background = phpthumb_functions::ImageColorAllocateAlphaSafe($gd_border_canvas, 255, 255, 255, 127); - ImageFilledRectangle($gd_border_canvas, 0, 0, $output_width, $output_height, $color_background); + imagefilledrectangle($gd_border_canvas, 0, 0, $output_width, $output_height, $color_background); $color_border = phpthumb_functions::ImageHexColorAllocate($gd_border_canvas, (phpthumb_functions::IsHexColor($hexcolor_border) ? $hexcolor_border : '000000')); for ($i = 0; $i < $border_width; $i++) { - ImageLine($gd_border_canvas, floor($offset_x / 2) + $radius_x, $i, $output_width - $radius_x - ceil($offset_x / 2), $i, $color_border); // top - ImageLine($gd_border_canvas, floor($offset_x / 2) + $radius_x, $output_height - 1 - $i, $output_width - $radius_x - ceil($offset_x / 2), $output_height - 1 - $i, $color_border); // bottom - ImageLine($gd_border_canvas, floor($offset_x / 2) + $i, $radius_y, floor($offset_x / 2) + $i, $output_height - $radius_y, $color_border); // left - ImageLine($gd_border_canvas, $output_width - 1 - $i - ceil($offset_x / 2), $radius_y, $output_width - 1 - $i - ceil($offset_x / 2), $output_height - $radius_y, $color_border); // right + imageline($gd_border_canvas, floor($offset_x / 2) + $radius_x, $i, $output_width - $radius_x - ceil($offset_x / 2), $i, $color_border); // top + imageline($gd_border_canvas, floor($offset_x / 2) + $radius_x, $output_height - 1 - $i, $output_width - $radius_x - ceil($offset_x / 2), $output_height - 1 - $i, $color_border); // bottom + imageline($gd_border_canvas, floor($offset_x / 2) + $i, $radius_y, floor($offset_x / 2) + $i, $output_height - $radius_y, $color_border); // left + imageline($gd_border_canvas, $output_width - 1 - $i - ceil($offset_x / 2), $radius_y, $output_width - 1 - $i - ceil($offset_x / 2), $output_height - $radius_y, $color_border); // right } if ($radius_x && $radius_y) { - // PHP bug: ImageArc() with thicknesses > 1 give bad/undesirable/unpredicatable results + // PHP bug: imagearc() with thicknesses > 1 give bad/undesirable/unpredicatable results // Solution: Draw multiple 1px arcs side-by-side. // Problem: parallel arcs give strange/ugly antialiasing problems // Solution: draw non-parallel arcs, from one side of the line thickness at the start angle // to the opposite edge of the line thickness at the terminating angle for ($thickness_offset = 0; $thickness_offset < $border_width; $thickness_offset++) { - ImageArc($gd_border_canvas, floor($offset_x / 2) + 1 + $radius_x, $thickness_offset - 1 + $radius_y, $radius_x * 2, $radius_y * 2, 180, 270, $color_border); // top-left - ImageArc($gd_border_canvas, $output_width - $radius_x - 1 - ceil($offset_x / 2), $thickness_offset - 1 + $radius_y, $radius_x * 2, $radius_y * 2, 270, 360, $color_border); // top-right - ImageArc($gd_border_canvas, $output_width - $radius_x - 1 - ceil($offset_x / 2), $output_height - $thickness_offset - $radius_y, $radius_x * 2, $radius_y * 2, 0, 90, $color_border); // bottom-right - ImageArc($gd_border_canvas, floor($offset_x / 2) + 1 + $radius_x, $output_height - $thickness_offset - $radius_y, $radius_x * 2, $radius_y * 2, 90, 180, $color_border); // bottom-left + imagearc($gd_border_canvas, floor($offset_x / 2) + 1 + $radius_x, $thickness_offset - 1 + $radius_y, $radius_x * 2, $radius_y * 2, 180, 270, $color_border); // top-left + imagearc($gd_border_canvas, $output_width - $radius_x - 1 - ceil($offset_x / 2), $thickness_offset - 1 + $radius_y, $radius_x * 2, $radius_y * 2, 270, 360, $color_border); // top-right + imagearc($gd_border_canvas, $output_width - $radius_x - 1 - ceil($offset_x / 2), $output_height - $thickness_offset - $radius_y, $radius_x * 2, $radius_y * 2, 0, 90, $color_border); // bottom-right + imagearc($gd_border_canvas, floor($offset_x / 2) + 1 + $radius_x, $output_height - $thickness_offset - $radius_y, $radius_x * 2, $radius_y * 2, 90, 180, $color_border); // bottom-left } if ($border_width > 1) { for ($thickness_offset = 0; $thickness_offset < $border_width; $thickness_offset++) { - ImageArc($gd_border_canvas, floor($offset_x / 2) + $thickness_offset + $radius_x, $radius_y, $radius_x * 2, $radius_y * 2, 180, 270, $color_border); // top-left - ImageArc($gd_border_canvas, $output_width - $thickness_offset - $radius_x - 1 - ceil($offset_x / 2), $radius_y, $radius_x * 2, $radius_y * 2, 270, 360, $color_border); // top-right - ImageArc($gd_border_canvas, $output_width - $thickness_offset - $radius_x - 1 - ceil($offset_x / 2), $output_height - $radius_y, $radius_x * 2, $radius_y * 2, 0, 90, $color_border); // bottom-right - ImageArc($gd_border_canvas, floor($offset_x / 2) + $thickness_offset + $radius_x, $output_height - $radius_y, $radius_x * 2, $radius_y * 2, 90, 180, $color_border); // bottom-left + imagearc($gd_border_canvas, floor($offset_x / 2) + $thickness_offset + $radius_x, $radius_y, $radius_x * 2, $radius_y * 2, 180, 270, $color_border); // top-left + imagearc($gd_border_canvas, $output_width - $thickness_offset - $radius_x - 1 - ceil($offset_x / 2), $radius_y, $radius_x * 2, $radius_y * 2, 270, 360, $color_border); // top-right + imagearc($gd_border_canvas, $output_width - $thickness_offset - $radius_x - 1 - ceil($offset_x / 2), $output_height - $radius_y, $radius_x * 2, $radius_y * 2, 0, 90, $color_border); // bottom-right + imagearc($gd_border_canvas, floor($offset_x / 2) + $thickness_offset + $radius_x, $output_height - $radius_y, $radius_x * 2, $radius_y * 2, 90, 180, $color_border); // bottom-left } } } $this->phpThumbObject->ImageResizeFunction($gd_border_canvas, $gdimg, floor(($output_width - $new_width) / 2), round(($output_height - $new_height) / 2), 0, 0, $new_width, $new_height, $output_width, $output_height); - ImageDestroy($gdimg); + imagedestroy($gdimg); $gdimg = phpthumb_functions::ImageCreateFunction($output_width, $output_height); - ImageSaveAlpha($gdimg, true); - ImageAlphaBlending($gdimg, false); + imagesavealpha($gdimg, true); + imagealphablending($gdimg, false); $gdimg_color_background = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, 255, 255, 255, 127); - ImageFilledRectangle($gdimg, 0, 0, $output_width, $output_height, $gdimg_color_background); + imagefilledrectangle($gdimg, 0, 0, $output_width, $output_height, $gdimg_color_background); - ImageCopy($gdimg, $gd_border_canvas, 0, 0, 0, 0, $output_width, $output_height); - //$gdimg = $gd_border_canvas; - ImageDestroy($gd_border_canvas); + imagecopy($gdimg, $gd_border_canvas, 0, 0, 0, 0, $output_width, $output_height); + imagedestroy($gd_border_canvas); return true; @@ -753,7 +752,7 @@ public function ImageBorder(&$gdimg, $border_width, $radius_x, $radius_y, $hexco } - public function ImprovedImageRotate(&$gdimg_source, $rotate_angle=0, $config_background_hexcolor='FFFFFF', $bg=null) { + public static function ImprovedImageRotate(&$gdimg_source, $rotate_angle=0, $config_background_hexcolor='FFFFFF', $bg=null, &$phpThumbObject) { while ($rotate_angle < 0) { $rotate_angle += 360; } @@ -765,31 +764,33 @@ public function ImprovedImageRotate(&$gdimg_source, $rotate_angle=0, $config_bac if ((phpthumb_functions::gd_version() >= 2) && !$bg && ($rotate_angle % 90)) { //$this->DebugMessage('Using alpha rotate', __FILE__, __LINE__); - if ($gdimg_rotate_mask = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg_source), ImageSY($gdimg_source))) { + if ($gdimg_rotate_mask = phpthumb_functions::ImageCreateFunction(imagesx($gdimg_source), imagesy($gdimg_source))) { + $color_mask = array(); for ($i = 0; $i <= 255; $i++) { - $color_mask[$i] = ImageColorAllocate($gdimg_rotate_mask, $i, $i, $i); + $color_mask[$i] = imagecolorallocate($gdimg_rotate_mask, $i, $i, $i); } - ImageFilledRectangle($gdimg_rotate_mask, 0, 0, ImageSX($gdimg_rotate_mask), ImageSY($gdimg_rotate_mask), $color_mask[255]); - $imageX = ImageSX($gdimg_source); - $imageY = ImageSY($gdimg_source); + imagefilledrectangle($gdimg_rotate_mask, 0, 0, imagesx($gdimg_rotate_mask), imagesy($gdimg_rotate_mask), $color_mask[255]); + $imageX = imagesx($gdimg_source); + $imageY = imagesy($gdimg_source); for ($x = 0; $x < $imageX; $x++) { for ($y = 0; $y < $imageY; $y++) { $pixelcolor = phpthumb_functions::GetPixelColor($gdimg_source, $x, $y); - ImageSetPixel($gdimg_rotate_mask, $x, $y, $color_mask[255 - round($pixelcolor['alpha'] * 255 / 127)]); + imagesetpixel($gdimg_rotate_mask, $x, $y, $color_mask[255 - round($pixelcolor['alpha'] * 255 / 127)]); } } - $gdimg_rotate_mask = ImageRotate($gdimg_rotate_mask, $rotate_angle, $color_mask[0]); - $gdimg_source = ImageRotate($gdimg_source, $rotate_angle, $background_color); + $gdimg_rotate_mask = imagerotate($gdimg_rotate_mask, $rotate_angle, $color_mask[0]); + $gdimg_source = imagerotate($gdimg_source, $rotate_angle, $background_color); - ImageAlphaBlending($gdimg_source, false); - ImageSaveAlpha($gdimg_source, true); + imagealphablending($gdimg_source, false); + imagesavealpha($gdimg_source, true); //$this->is_alpha = true; $phpThumbFilters = new phpthumb_filters(); - $phpThumbFilters->phpThumbObject = $this; + //$phpThumbFilters->phpThumbObject = $this; + $phpThumbFilters->phpThumbObject = $phpThumbObject; $phpThumbFilters->ApplyMask($gdimg_rotate_mask, $gdimg_source); - ImageDestroy($gdimg_rotate_mask); + imagedestroy($gdimg_rotate_mask); } else { //$this->DebugMessage('ImageCreateFunction() failed', __FILE__, __LINE__); @@ -807,40 +808,40 @@ public function ImprovedImageRotate(&$gdimg_source, $rotate_angle=0, $config_bac //$this->DebugMessage('Using non-alpha rotate because $this->thumbnailFormat is "'.$this->thumbnailFormat.'"', __FILE__, __LINE__); } - if (ImageColorTransparent($gdimg_source) >= 0) { - // ImageRotate() forgets all about an image's transparency and sets the transparent color to black + if (imagecolortransparent($gdimg_source) >= 0) { + // imagerotate() forgets all about an image's transparency and sets the transparent color to black // To compensate, flood-fill the transparent color of the source image with the specified background color first // then rotate and the colors should match - if (!function_exists('ImageIsTrueColor') || !ImageIsTrueColor($gdimg_source)) { + if (!function_exists('imageistruecolor') || !imageistruecolor($gdimg_source)) { // convert paletted image to true-color before rotating to prevent nasty aliasing artifacts - //$this->source_width = ImageSX($gdimg_source); - //$this->source_height = ImageSY($gdimg_source); - $gdimg_newsrc = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg_source), ImageSY($gdimg_source)); + //$this->source_width = imagesx($gdimg_source); + //$this->source_height = imagesy($gdimg_source); + $gdimg_newsrc = phpthumb_functions::ImageCreateFunction(imagesx($gdimg_source), imagesy($gdimg_source)); $background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $config_background_hexcolor); - ImageFilledRectangle($gdimg_newsrc, 0, 0, ImageSX($gdimg_source), ImageSY($gdimg_source), phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $config_background_hexcolor)); - ImageCopy($gdimg_newsrc, $gdimg_source, 0, 0, 0, 0, ImageSX($gdimg_source), ImageSY($gdimg_source)); - ImageDestroy($gdimg_source); + imagefilledrectangle($gdimg_newsrc, 0, 0, imagesx($gdimg_source), imagesy($gdimg_source), phpthumb_functions::ImageHexColorAllocate($gdimg_newsrc, $config_background_hexcolor)); + imagecopy($gdimg_newsrc, $gdimg_source, 0, 0, 0, 0, imagesx($gdimg_source), imagesy($gdimg_source)); + imagedestroy($gdimg_source); unset($gdimg_source); $gdimg_source = $gdimg_newsrc; unset($gdimg_newsrc); } else { - ImageColorSet( + imagecolorset( $gdimg_source, - ImageColorTransparent($gdimg_source), + imagecolortransparent($gdimg_source), hexdec(substr($config_background_hexcolor, 0, 2)), hexdec(substr($config_background_hexcolor, 2, 2)), hexdec(substr($config_background_hexcolor, 4, 2))); - ImageColorTransparent($gdimg_source, -1); + imagecolortransparent($gdimg_source, -1); } } - $gdimg_source = ImageRotate($gdimg_source, $rotate_angle, $background_color); + $gdimg_source = imagerotate($gdimg_source, $rotate_angle, $background_color); } } @@ -850,10 +851,10 @@ public function ImprovedImageRotate(&$gdimg_source, $rotate_angle=0, $config_bac public function MeanRemoval(&$gdimg) { if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - if (ImageFilter($gdimg, IMG_FILTER_MEAN_REMOVAL)) { + if (imagefilter($gdimg, IMG_FILTER_MEAN_REMOVAL)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_MEAN_REMOVAL)', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_MEAN_REMOVAL)', __FILE__, __LINE__); // fall through and try it the hard way } // currently not implemented "the hard way" @@ -864,19 +865,19 @@ public function MeanRemoval(&$gdimg) { public function Negative(&$gdimg) { if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - if (ImageFilter($gdimg, IMG_FILTER_NEGATE)) { + if (imagefilter($gdimg, IMG_FILTER_NEGATE)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_NEGATE)', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_NEGATE)', __FILE__, __LINE__); // fall through and try it the hard way } - $ImageSX = ImageSX($gdimg); - $ImageSY = ImageSY($gdimg); + $ImageSX = imagesx($gdimg); + $ImageSY = imagesy($gdimg); for ($x = 0; $x < $ImageSX; $x++) { for ($y = 0; $y < $ImageSY; $y++) { $currentPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y); $newColor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, (~$currentPixel['red'] & 0xFF), (~$currentPixel['green'] & 0xFF), (~$currentPixel['blue'] & 0xFF), $currentPixel['alpha']); - ImageSetPixel($gdimg, $x, $y, $newColor); + imagesetpixel($gdimg, $x, $y, $newColor); } } return true; @@ -885,30 +886,30 @@ public function Negative(&$gdimg) { public function RoundedImageCorners(&$gdimg, $radius_x, $radius_y) { // generate mask at twice desired resolution and downsample afterwards for easy antialiasing - // mask is generated as a white double-size elipse on a triple-size black background and copy-paste-resampled + // mask is generated as a white double-size ellipse on a triple-size black background and copy-paste-resampled // onto a correct-size mask image as 4 corners due to errors when the entire mask is resampled at once (gray edges) if ($gdimg_cornermask_triple = phpthumb_functions::ImageCreateFunction($radius_x * 6, $radius_y * 6)) { - if ($gdimg_cornermask = phpthumb_functions::ImageCreateFunction(ImageSX($gdimg), ImageSY($gdimg))) { + if ($gdimg_cornermask = phpthumb_functions::ImageCreateFunction(imagesx($gdimg), imagesy($gdimg))) { - $color_transparent = ImageColorAllocate($gdimg_cornermask_triple, 255, 255, 255); - ImageFilledEllipse($gdimg_cornermask_triple, $radius_x * 3, $radius_y * 3, $radius_x * 4, $radius_y * 4, $color_transparent); + $color_transparent = imagecolorallocate($gdimg_cornermask_triple, 255, 255, 255); + imagefilledellipse($gdimg_cornermask_triple, $radius_x * 3, $radius_y * 3, $radius_x * 4, $radius_y * 4, $color_transparent); - ImageFilledRectangle($gdimg_cornermask, 0, 0, ImageSX($gdimg), ImageSY($gdimg), $color_transparent); + imagefilledrectangle($gdimg_cornermask, 0, 0, imagesx($gdimg), imagesy($gdimg), $color_transparent); - ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, 0, 0, $radius_x, $radius_y, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); - ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, 0, ImageSY($gdimg) - $radius_y, $radius_x, $radius_y * 3, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); - ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, ImageSX($gdimg) - $radius_x, ImageSY($gdimg) - $radius_y, $radius_x * 3, $radius_y * 3, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); - ImageCopyResampled($gdimg_cornermask, $gdimg_cornermask_triple, ImageSX($gdimg) - $radius_x, 0, $radius_x * 3, $radius_y, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); + imagecopyresampled($gdimg_cornermask, $gdimg_cornermask_triple, 0, 0, $radius_x, $radius_y, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); + imagecopyresampled($gdimg_cornermask, $gdimg_cornermask_triple, 0, imagesy($gdimg) - $radius_y, $radius_x, $radius_y * 3, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); + imagecopyresampled($gdimg_cornermask, $gdimg_cornermask_triple, imagesx($gdimg) - $radius_x, imagesy($gdimg) - $radius_y, $radius_x * 3, $radius_y * 3, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); + imagecopyresampled($gdimg_cornermask, $gdimg_cornermask_triple, imagesx($gdimg) - $radius_x, 0, $radius_x * 3, $radius_y, $radius_x, $radius_y, $radius_x * 2, $radius_y * 2); phpthumb_filters::ApplyMask($gdimg_cornermask, $gdimg); - ImageDestroy($gdimg_cornermask); + imagedestroy($gdimg_cornermask); $this->DebugMessage('RoundedImageCorners('.$radius_x.', '.$radius_y.') succeeded', __FILE__, __LINE__); return true; } else { - $this->DebugMessage('FAILED: $gdimg_cornermask = phpthumb_functions::ImageCreateFunction('.ImageSX($gdimg).', '.ImageSY($gdimg).')', __FILE__, __LINE__); + $this->DebugMessage('FAILED: $gdimg_cornermask = phpthumb_functions::ImageCreateFunction('.imagesx($gdimg).', '.imagesy($gdimg).')', __FILE__, __LINE__); } - ImageDestroy($gdimg_cornermask_triple); + imagedestroy($gdimg_cornermask_triple); } else { $this->DebugMessage('FAILED: $gdimg_cornermask_triple = phpthumb_functions::ImageCreateFunction('.($radius_x * 6).', '.($radius_y * 6).')', __FILE__, __LINE__); @@ -939,20 +940,20 @@ public function Sepia(&$gdimg, $amount, $targetColor) { } if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - if (ImageFilter($gdimg, IMG_FILTER_GRAYSCALE)) { + if (imagefilter($gdimg, IMG_FILTER_GRAYSCALE)) { $r = round($amountPct * hexdec(substr($targetColor, 0, 2))); $g = round($amountPct * hexdec(substr($targetColor, 2, 2))); $b = round($amountPct * hexdec(substr($targetColor, 4, 2))); - if (ImageFilter($gdimg, IMG_FILTER_COLORIZE, $r, $g, $b)) { + if (imagefilter($gdimg, IMG_FILTER_COLORIZE, $r, $g, $b)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_COLORIZE)', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_COLORIZE)', __FILE__, __LINE__); // fall through and try it the hard way } else { - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_GRAYSCALE)', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_GRAYSCALE)', __FILE__, __LINE__); // fall through and try it the hard way } @@ -962,8 +963,8 @@ public function Sepia(&$gdimg, $amount, $targetColor) { $TargetPixel['green'] = hexdec(substr($targetColor, 2, 2)); $TargetPixel['blue'] = hexdec(substr($targetColor, 4, 2)); - $ImageSX = ImageSX($gdimg); - $ImageSY = ImageSY($gdimg); + $ImageSX = imagesx($gdimg); + $ImageSY = imagesy($gdimg); for ($x = 0; $x < $ImageSX; $x++) { for ($y = 0; $y < $ImageSY; $y++) { $OriginalPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y); @@ -974,11 +975,12 @@ public function Sepia(&$gdimg, $amount, $targetColor) { // the mid-tones: the lighter and darker areas appear to be closer to B&W." $SepiaAmount = ((128 - abs($GrayPixel['red'] - 128)) / 128) * $amountPct; + $NewPixel = array(); foreach ($TargetPixel as $key => $value) { $NewPixel[$key] = round(max(0, min(255, $GrayPixel[$key] * (1 - $SepiaAmount) + ($TargetPixel[$key] * $SepiaAmount)))); } $newColor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, $NewPixel['red'], $NewPixel['green'], $NewPixel['blue'], $OriginalPixel['alpha']); - ImageSetPixel($gdimg, $x, $y, $newColor); + imagesetpixel($gdimg, $x, $y, $newColor); } } return true; @@ -991,10 +993,10 @@ public function Smooth(&$gdimg, $amount=6) { return true; } if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) { - if (ImageFilter($gdimg, IMG_FILTER_SMOOTH, $amount)) { + if (imagefilter($gdimg, IMG_FILTER_SMOOTH, $amount)) { return true; } - $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_SMOOTH, '.$amount.')', __FILE__, __LINE__); + $this->DebugMessage('FAILED: imagefilter($gdimg, IMG_FILTER_SMOOTH, '.$amount.')', __FILE__, __LINE__); // fall through and try it the hard way } // currently not implemented "the hard way" @@ -1004,9 +1006,9 @@ public function Smooth(&$gdimg, $amount=6) { public function SourceTransparentColorMask(&$gdimg, $hexcolor, $min_limit=5, $max_limit=10) { - $width = ImageSX($gdimg); - $height = ImageSY($gdimg); - if ($gdimg_mask = ImageCreateTrueColor($width, $height)) { + $width = imagesx($gdimg); + $height = imagesy($gdimg); + if ($gdimg_mask = imagecreatetruecolor($width, $height)) { $R = hexdec(substr($hexcolor, 0, 2)); $G = hexdec(substr($hexcolor, 2, 2)); $B = hexdec(substr($hexcolor, 4, 2)); @@ -1016,9 +1018,9 @@ public function SourceTransparentColorMask(&$gdimg, $hexcolor, $min_limit=5, $ma for ($y = 0; $y < $height; $y++) { $currentPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y); $colorDiff = phpthumb_functions::PixelColorDifferencePercent($currentPixel, $targetPixel); - $grayLevel = min($cutoffRange, MAX(0, -$min_limit + $colorDiff)) * (255 / MAX(1, $cutoffRange)); - $newColor = ImageColorAllocate($gdimg_mask, $grayLevel, $grayLevel, $grayLevel); - ImageSetPixel($gdimg_mask, $x, $y, $newColor); + $grayLevel = min($cutoffRange, max(0, -$min_limit + $colorDiff)) * (255 / max(1, $cutoffRange)); + $newColor = imagecolorallocate($gdimg_mask, $grayLevel, $grayLevel, $grayLevel); + imagesetpixel($gdimg_mask, $x, $y, $newColor); } } return $gdimg_mask; @@ -1028,8 +1030,8 @@ public function SourceTransparentColorMask(&$gdimg, $hexcolor, $min_limit=5, $ma public function Threshold(&$gdimg, $cutoff) { - $width = ImageSX($gdimg); - $height = ImageSY($gdimg); + $width = imagesx($gdimg); + $height = imagesy($gdimg); $cutoff = min(255, max(0, ($cutoff ? $cutoff : 128))); for ($x = 0; $x < $width; $x++) { for ($y = 0; $y < $height; $y++) { @@ -1040,7 +1042,7 @@ public function Threshold(&$gdimg, $cutoff) { } else { $newColor = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg, 0xFF, 0xFF, 0xFF, $currentPixel['alpha']); } - ImageSetPixel($gdimg, $x, $y, $newColor); + imagesetpixel($gdimg, $x, $y, $newColor); } } return true; @@ -1050,21 +1052,21 @@ public function Threshold(&$gdimg, $cutoff) { public function ImageTrueColorToPalette2(&$image, $dither, $ncolors) { // http://www.php.net/manual/en/function.imagetruecolortopalette.php // zmorris at zsculpt dot com (17-Aug-2004 06:58) - $width = ImageSX($image); - $height = ImageSY($image); - $image_copy = ImageCreateTrueColor($width, $height); - //ImageCopyMerge($image_copy, $image, 0, 0, 0, 0, $width, $height, 100); - ImageCopy($image_copy, $image, 0, 0, 0, 0, $width, $height); - ImageTrueColorToPalette($image, $dither, $ncolors); - ImageColorMatch($image_copy, $image); - ImageDestroy($image_copy); + $width = imagesx($image); + $height = imagesy($image); + $image_copy = imagecreatetruecolor($width, $height); + //imagecopymerge($image_copy, $image, 0, 0, 0, 0, $width, $height, 100); + imagecopy($image_copy, $image, 0, 0, 0, 0, $width, $height); + imagetruecolortopalette($image, $dither, $ncolors); + imagecolormatch($image_copy, $image); + imagedestroy($image_copy); return true; } public function ReduceColorDepth(&$gdimg, $colors=256, $dither=true) { $colors = max(min($colors, 256), 2); - // ImageTrueColorToPalette usually makes ugly colors, the replacement is a bit better - //ImageTrueColorToPalette($gdimg, $dither, $colors); + // imagetruecolortopalette usually makes ugly colors, the replacement is a bit better + //imagetruecolortopalette($gdimg, $dither, $colors); phpthumb_filters::ImageTrueColorToPalette2($gdimg, $dither, $colors); return true; } @@ -1090,8 +1092,8 @@ public function WhiteBalance(&$gdimg, $targetColor='') { $scaleG = $grayValue / $targetPixel['green']; $scaleB = $grayValue / $targetPixel['blue']; - for ($x = 0; $x < ImageSX($gdimg); $x++) { - for ($y = 0; $y < ImageSY($gdimg); $y++) { + for ($x = 0; $x < imagesx($gdimg); $x++) { + for ($y = 0; $y < imagesy($gdimg); $y++) { $currentPixel = phpthumb_functions::GetPixelColor($gdimg, $x, $y); $newColor = phpthumb_functions::ImageColorAllocateAlphaSafe( $gdimg, @@ -1100,7 +1102,7 @@ public function WhiteBalance(&$gdimg, $targetColor='') { max(0, min(255, round($currentPixel['blue'] * $scaleB))), $currentPixel['alpha'] ); - ImageSetPixel($gdimg, $x, $y, $newColor); + imagesetpixel($gdimg, $x, $y, $newColor); } } return true; @@ -1112,7 +1114,7 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 if (!$text) { return false; } - ImageAlphaBlending($gdimg, true); + imagealphablending($gdimg, true); if (preg_match('#^([0-9\\.\\-]*)x([0-9\\.\\-]*)(@[LCR])?$#i', $alignment, $matches)) { $originOffsetX = intval($matches[1]); @@ -1130,8 +1132,8 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 '^Fm' => round($this->phpThumbObject->getimagesizeinfo['filesize'] / 1048576), '^X' => $this->phpThumbObject->getimagesizeinfo[0], '^Y' => $this->phpThumbObject->getimagesizeinfo[1], - '^x' => ImageSX($gdimg), - '^y' => ImageSY($gdimg), + '^x' => imagesx($gdimg), + '^y' => imagesy($gdimg), '^^' => '^', ); $text = strtr($text, $metaTextArray); @@ -1148,7 +1150,7 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 $this->DebugMessage('Using TTF font "'.$ttffont.'"', __FILE__, __LINE__); - $TTFbox = ImageTTFbBox($size, $angle, $ttffont, $text); + $TTFbox = imagettfbbox($size, $angle, $ttffont, $text); $min_x = min($TTFbox[0], $TTFbox[2], $TTFbox[4], $TTFbox[6]); $max_x = max($TTFbox[0], $TTFbox[2], $TTFbox[4], $TTFbox[6]); @@ -1160,7 +1162,7 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 //$text_height = round($max_y - $min_y + ($size * 0.5)); $text_height = round($max_y - $min_y); - $TTFboxChar = ImageTTFbBox($size, $angle, $ttffont, 'jH'); + $TTFboxChar = imagettfbbox($size, $angle, $ttffont, 'jH'); $char_min_y = min($TTFboxChar[1], $TTFboxChar[3], $TTFboxChar[5], $TTFboxChar[7]); $char_max_y = max($TTFboxChar[1], $TTFboxChar[3], $TTFboxChar[5], $TTFboxChar[7]); $char_height = round($char_max_y - $char_min_y); @@ -1168,10 +1170,10 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 if ($alignment == '*') { $text_origin_y = $char_height + $margin; - while (($text_origin_y - $text_height) < ImageSY($gdimg)) { + while (($text_origin_y - $text_height) < imagesy($gdimg)) { $text_origin_x = $margin; - while ($text_origin_x < ImageSX($gdimg)) { - ImageTTFtext($gdimg, $size, $angle, $text_origin_x, $text_origin_y, $letter_color_text, $ttffont, $text); + while ($text_origin_x < imagesx($gdimg)) { + imagettftext($gdimg, $size, $angle, $text_origin_x, $text_origin_y, $letter_color_text, $ttffont, $text); $text_origin_x += ($text_width + $margin); } $text_origin_y += ($text_height + $margin); @@ -1181,34 +1183,36 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 // this block for background color only + $text_origin_x = 0; + $text_origin_y = 0; switch ($alignment) { case '*': // handled separately break; case 'T': - $text_origin_x = ($originOffsetX ? $originOffsetX - round($text_width / 2) : round((ImageSX($gdimg) - $text_width) / 2)); + $text_origin_x = ($originOffsetX ? $originOffsetX - round($text_width / 2) : round((imagesx($gdimg) - $text_width) / 2)); $text_origin_y = $char_height + $margin + $originOffsetY; break; case 'B': - $text_origin_x = ($originOffsetX ? $originOffsetX - round($text_width / 2) : round((ImageSX($gdimg) - $text_width) / 2)); - $text_origin_y = ImageSY($gdimg) + $TTFbox[1] - $margin + $originOffsetY; + $text_origin_x = ($originOffsetX ? $originOffsetX - round($text_width / 2) : round((imagesx($gdimg) - $text_width) / 2)); + $text_origin_y = imagesy($gdimg) + $TTFbox[1] - $margin + $originOffsetY; break; case 'L': $text_origin_x = $margin + $originOffsetX; - $text_origin_y = ($originOffsetY ? $originOffsetY : round((ImageSY($gdimg) - $text_height) / 2) + $char_height); + $text_origin_y = ($originOffsetY ? $originOffsetY : round((imagesy($gdimg) - $text_height) / 2) + $char_height); break; case 'R': - $text_origin_x = ($originOffsetX ? $originOffsetX - $text_width : ImageSX($gdimg) - $text_width + $TTFbox[0] - $min_x + round($size * 0.25) - $margin); - $text_origin_y = ($originOffsetY ? $originOffsetY : round((ImageSY($gdimg) - $text_height) / 2) + $char_height); + $text_origin_x = ($originOffsetX ? $originOffsetX - $text_width : imagesx($gdimg) - $text_width + $TTFbox[0] - $min_x + round($size * 0.25) - $margin); + $text_origin_y = ($originOffsetY ? $originOffsetY : round((imagesy($gdimg) - $text_height) / 2) + $char_height); break; case 'C': - $text_origin_x = ($originOffsetX ? $originOffsetX - round($text_width / 2) : round((ImageSX($gdimg) - $text_width) / 2)); - $text_origin_y = ($originOffsetY ? $originOffsetY : round((ImageSY($gdimg) - $text_height) / 2) + $char_height); + $text_origin_x = ($originOffsetX ? $originOffsetX - round($text_width / 2) : round((imagesx($gdimg) - $text_width) / 2)); + $text_origin_y = ($originOffsetY ? $originOffsetY : round((imagesy($gdimg) - $text_height) / 2) + $char_height); break; case 'TL': @@ -1217,23 +1221,22 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 break; case 'TR': - $text_origin_x = ($originOffsetX ? $originOffsetX - $text_width : ImageSX($gdimg) - $text_width + $TTFbox[0] - $min_x + round($size * 0.25) - $margin); + $text_origin_x = ($originOffsetX ? $originOffsetX - $text_width : imagesx($gdimg) - $text_width + $TTFbox[0] - $min_x + round($size * 0.25) - $margin); $text_origin_y = $char_height + $margin + $originOffsetY; break; case 'BL': $text_origin_x = $margin + $originOffsetX; - $text_origin_y = ImageSY($gdimg) + $TTFbox[1] - $margin + $originOffsetY; + $text_origin_y = imagesy($gdimg) + $TTFbox[1] - $margin + $originOffsetY; break; case 'BR': default: - $text_origin_x = ($originOffsetX ? $originOffsetX - $text_width : ImageSX($gdimg) - $text_width + $TTFbox[0] - $min_x + round($size * 0.25) - $margin); - $text_origin_y = ImageSY($gdimg) + $TTFbox[1] - $margin + $originOffsetY; + $text_origin_x = ($originOffsetX ? $originOffsetX - $text_width : imagesx($gdimg) - $text_width + $TTFbox[0] - $min_x + round($size * 0.25) - $margin); + $text_origin_y = imagesy($gdimg) + $TTFbox[1] - $margin + $originOffsetY; break; } - //ImageRectangle($gdimg, $text_origin_x + $min_x, $text_origin_y + $TTFbox[1], $text_origin_x + $min_x + $text_width, $text_origin_y + $TTFbox[1] - $text_height, $letter_color_text); if (phpthumb_functions::IsHexColor($bg_color)) { $text_background_alpha = round(127 * ((100 - min(max(0, $bg_opacity), 100)) / 100)); $text_color_background = phpthumb_functions::ImageHexColorAllocate($gdimg, $bg_color, false, $text_background_alpha); @@ -1246,15 +1249,10 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 $y2 = $text_origin_y + $TTFbox[1] - $text_height; $x_TL = preg_match('#x#i', $fillextend) ? 0 : min($x1, $x2); $y_TL = preg_match('#y#i', $fillextend) ? 0 : min($y1, $y2); - $x_BR = preg_match('#x#i', $fillextend) ? ImageSX($gdimg) : max($x1, $x2); - $y_BR = preg_match('#y#i', $fillextend) ? ImageSY($gdimg) : max($y1, $y2); - //while ($y_BR > ImageSY($gdimg)) { - // $y_TL--; - // $y_BR--; - // $text_origin_y--; - //} - $this->DebugMessage('WatermarkText() calling ImageFilledRectangle($gdimg, '.$x_TL.', '.$y_TL.', '.$x_BR.', '.$y_BR.', $text_color_background)', __FILE__, __LINE__); - ImageFilledRectangle($gdimg, $x_TL, $y_TL, $x_BR, $y_BR, $text_color_background); + $x_BR = preg_match('#x#i', $fillextend) ? imagesx($gdimg) : max($x1, $x2); + $y_BR = preg_match('#y#i', $fillextend) ? imagesy($gdimg) : max($y1, $y2); + $this->DebugMessage('WatermarkText() calling imagefilledrectangle($gdimg, '.$x_TL.', '.$y_TL.', '.$x_BR.', '.$y_BR.', $text_color_background)', __FILE__, __LINE__); + imagefilledrectangle($gdimg, $x_TL, $y_TL, $x_BR, $y_BR, $text_color_background); // end block for background color only @@ -1262,17 +1260,11 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 $y_offset = 0; foreach ($textlines as $dummy => $line) { - $TTFboxLine = ImageTTFbBox($size, $angle, $ttffont, $line); + $TTFboxLine = imagettfbbox($size, $angle, $ttffont, $line); $min_x_line = min($TTFboxLine[0], $TTFboxLine[2], $TTFboxLine[4], $TTFboxLine[6]); $max_x_line = max($TTFboxLine[0], $TTFboxLine[2], $TTFboxLine[4], $TTFboxLine[6]); - //$text_width = round($max_x - $min_x + ($size * 0.5)); $text_width_line = round($max_x_line - $min_x_line); - $min_y_line = min($TTFboxLine[1], $TTFboxLine[3], $TTFboxLine[5], $TTFboxLine[7]); - $max_y_line = max($TTFboxLine[1], $TTFboxLine[3], $TTFboxLine[5], $TTFboxLine[7]); - //$text_height = round($max_y - $min_y + ($size * 0.5)); - $text_height_line = round($max_y_line - $min_y_line); - switch ($alignment) { // $text_origin_y set above, just re-set $text_origin_x here as needed @@ -1285,19 +1277,19 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 case 'C': case 'T': case 'B': - $text_origin_x = ($originOffsetX ? $originOffsetX - round($text_width_line / 2) : round((ImageSX($gdimg) - $text_width_line) / 2)); + $text_origin_x = ($originOffsetX ? $originOffsetX - round($text_width_line / 2) : round((imagesx($gdimg) - $text_width_line) / 2)); break; case 'R': case 'TR': case 'BR': - $text_origin_x = ($originOffsetX ? $originOffsetX - $text_width_line : ImageSX($gdimg) - $text_width_line + $TTFbox[0] - $min_x + round($size * 0.25) - $margin); + $text_origin_x = ($originOffsetX ? $originOffsetX - $text_width_line : imagesx($gdimg) - $text_width_line + $TTFbox[0] - $min_x + round($size * 0.25) - $margin); break; } - //ImageTTFtext($gdimg, $size, $angle, $text_origin_x, $text_origin_y, $letter_color_text, $ttffont, $text); - $this->DebugMessage('WatermarkText() calling ImageTTFtext($gdimg, '.$size.', '.$angle.', '.$text_origin_x.', '.($text_origin_y + $y_offset).', $letter_color_text, '.$ttffont.', '.$line.')', __FILE__, __LINE__); - ImageTTFtext($gdimg, $size, $angle, $text_origin_x, $text_origin_y + $y_offset, $letter_color_text, $ttffont, $line); + //imagettftext($gdimg, $size, $angle, $text_origin_x, $text_origin_y, $letter_color_text, $ttffont, $text); + $this->DebugMessage('WatermarkText() calling imagettftext($gdimg, '.$size.', '.$angle.', '.$text_origin_x.', '.($text_origin_y + $y_offset).', $letter_color_text, '.$ttffont.', '.$line.')', __FILE__, __LINE__); + imagettftext($gdimg, $size, $angle, $text_origin_x, $text_origin_y + $y_offset, $letter_color_text, $ttffont, $line); $y_offset += $char_height; } @@ -1313,55 +1305,59 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 $text_width = 0; $text_height = 0; foreach ($textlines as $dummy => $line) { - $text_width = max($text_width, ImageFontWidth($size) * strlen($line)); - $text_height += ImageFontHeight($size); + $text_width = max($text_width, imagefontwidth($size) * strlen($line)); + $text_height += imagefontheight($size); } if ($img_watermark = phpthumb_functions::ImageCreateFunction($text_width, $text_height)) { - ImageAlphaBlending($img_watermark, false); + imagealphablending($img_watermark, false); if (phpthumb_functions::IsHexColor($bg_color)) { $text_background_alpha = round(127 * ((100 - min(max(0, $bg_opacity), 100)) / 100)); $text_color_background = phpthumb_functions::ImageHexColorAllocate($img_watermark, $bg_color, false, $text_background_alpha); } else { $text_color_background = phpthumb_functions::ImageHexColorAllocate($img_watermark, 'FFFFFF', false, 127); } - $this->DebugMessage('WatermarkText() calling ImageFilledRectangle($img_watermark, 0, 0, '.ImageSX($img_watermark).', '.ImageSY($img_watermark).', $text_color_background)', __FILE__, __LINE__); - ImageFilledRectangle($img_watermark, 0, 0, ImageSX($img_watermark), ImageSY($img_watermark), $text_color_background); - - if ($angle && function_exists('ImageRotate')) { - // using $img_watermark_mask is pointless if ImageRotate function isn't available + $this->DebugMessage('WatermarkText() calling imagefilledrectangle($img_watermark, 0, 0, '.imagesx($img_watermark).', '.imagesy($img_watermark).', $text_color_background)', __FILE__, __LINE__); + imagefilledrectangle($img_watermark, 0, 0, imagesx($img_watermark), imagesy($img_watermark), $text_color_background); + + $img_watermark_mask = false; + $mask_color_background = false; + $mask_color_watermark = false; + if ($angle && function_exists('imagerotate')) { + // using $img_watermark_mask is pointless if imagerotate function isn't available if ($img_watermark_mask = phpthumb_functions::ImageCreateFunction($text_width, $text_height)) { - $mask_color_background = ImageColorAllocate($img_watermark_mask, 0, 0, 0); - ImageAlphaBlending($img_watermark_mask, false); - ImageFilledRectangle($img_watermark_mask, 0, 0, ImageSX($img_watermark_mask), ImageSY($img_watermark_mask), $mask_color_background); - $mask_color_watermark = ImageColorAllocate($img_watermark_mask, 255, 255, 255); + $mask_color_background = imagecolorallocate($img_watermark_mask, 0, 0, 0); + imagealphablending($img_watermark_mask, false); + imagefilledrectangle($img_watermark_mask, 0, 0, imagesx($img_watermark_mask), imagesy($img_watermark_mask), $mask_color_background); + $mask_color_watermark = imagecolorallocate($img_watermark_mask, 255, 255, 255); } } $text_color_watermark = phpthumb_functions::ImageHexColorAllocate($img_watermark, $hex_color); + $x_offset = 0; foreach ($textlines as $key => $line) { switch ($alignment) { case 'C': - $x_offset = round(($text_width - (ImageFontWidth($size) * strlen($line))) / 2); - $originOffsetX = (ImageSX($gdimg) - ImageSX($img_watermark)) / 2; - $originOffsetY = (ImageSY($gdimg) - ImageSY($img_watermark)) / 2; + $x_offset = round(($text_width - (imagefontwidth($size) * strlen($line))) / 2); + $originOffsetX = (imagesx($gdimg) - imagesx($img_watermark)) / 2; + $originOffsetY = (imagesy($gdimg) - imagesy($img_watermark)) / 2; break; case 'T': - $x_offset = round(($text_width - (ImageFontWidth($size) * strlen($line))) / 2); - $originOffsetX = (ImageSX($gdimg) - ImageSX($img_watermark)) / 2; + $x_offset = round(($text_width - (imagefontwidth($size) * strlen($line))) / 2); + $originOffsetX = (imagesx($gdimg) - imagesx($img_watermark)) / 2; $originOffsetY = $margin; break; case 'B': - $x_offset = round(($text_width - (ImageFontWidth($size) * strlen($line))) / 2); - $originOffsetX = (ImageSX($gdimg) - ImageSX($img_watermark)) / 2; - $originOffsetY = ImageSY($gdimg) - ImageSY($img_watermark) - $margin; + $x_offset = round(($text_width - (imagefontwidth($size) * strlen($line))) / 2); + $originOffsetX = (imagesx($gdimg) - imagesx($img_watermark)) / 2; + $originOffsetY = imagesy($gdimg) - imagesy($img_watermark) - $margin; break; case 'L': $x_offset = 0; $originOffsetX = $margin; - $originOffsetY = (ImageSY($gdimg) - ImageSY($img_watermark)) / 2; + $originOffsetY = (imagesy($gdimg) - imagesy($img_watermark)) / 2; break; case 'TL': @@ -1373,18 +1369,18 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 case 'BL': $x_offset = 0; $originOffsetX = $margin; - $originOffsetY = ImageSY($gdimg) - ImageSY($img_watermark) - $margin; + $originOffsetY = imagesy($gdimg) - imagesy($img_watermark) - $margin; break; case 'R': - $x_offset = $text_width - (ImageFontWidth($size) * strlen($line)); - $originOffsetX = ImageSX($gdimg) - ImageSX($img_watermark) - $margin; - $originOffsetY = (ImageSY($gdimg) - ImageSY($img_watermark)) / 2; + $x_offset = $text_width - (imagefontwidth($size) * strlen($line)); + $originOffsetX = imagesx($gdimg) - imagesx($img_watermark) - $margin; + $originOffsetY = (imagesy($gdimg) - imagesy($img_watermark)) / 2; break; case 'TR': - $x_offset = $text_width - (ImageFontWidth($size) * strlen($line)); - $originOffsetX = ImageSX($gdimg) - ImageSX($img_watermark) - $margin; + $x_offset = $text_width - (imagefontwidth($size) * strlen($line)); + $originOffsetX = imagesx($gdimg) - imagesx($img_watermark) - $margin; $originOffsetY = $margin; break; @@ -1393,28 +1389,28 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 if (!empty($originOffsetX) || !empty($originOffsetY)) { // absolute pixel positioning } else { - $x_offset = $text_width - (ImageFontWidth($size) * strlen($line)); - $originOffsetX = ImageSX($gdimg) - ImageSX($img_watermark) - $margin; - $originOffsetY = ImageSY($gdimg) - ImageSY($img_watermark) - $margin; + $x_offset = $text_width - (imagefontwidth($size) * strlen($line)); + $originOffsetX = imagesx($gdimg) - imagesx($img_watermark) - $margin; + $originOffsetY = imagesy($gdimg) - imagesy($img_watermark) - $margin; } break; } - $this->DebugMessage('WatermarkText() calling ImageString($img_watermark, '.$size.', '.$x_offset.', '.($key * ImageFontHeight($size)).', '.$line.', $text_color_watermark)', __FILE__, __LINE__); - ImageString($img_watermark, $size, $x_offset, $key * ImageFontHeight($size), $line, $text_color_watermark); + $this->DebugMessage('WatermarkText() calling imagestring($img_watermark, '.$size.', '.$x_offset.', '.($key * imagefontheight($size)).', '.$line.', $text_color_watermark)', __FILE__, __LINE__); + imagestring($img_watermark, $size, $x_offset, $key * imagefontheight($size), $line, $text_color_watermark); if ($angle && $img_watermark_mask) { - $this->DebugMessage('WatermarkText() calling ImageString($img_watermark_mask, '.$size.', '.$x_offset.', '.($key * ImageFontHeight($size)).', '.$text.', $mask_color_watermark)', __FILE__, __LINE__); - ImageString($img_watermark_mask, $size, $x_offset, $key * ImageFontHeight($size), $text, $mask_color_watermark); + $this->DebugMessage('WatermarkText() calling imagestring($img_watermark_mask, '.$size.', '.$x_offset.', '.($key * imagefontheight($size)).', '.$text.', $mask_color_watermark)', __FILE__, __LINE__); + imagestring($img_watermark_mask, $size, $x_offset, $key * imagefontheight($size), $text, $mask_color_watermark); } } if ($angle && $img_watermark_mask) { - $img_watermark = ImageRotate($img_watermark, $angle, $text_color_background); - $img_watermark_mask = ImageRotate($img_watermark_mask, $angle, $mask_color_background); + $img_watermark = imagerotate($img_watermark, $angle, $text_color_background); + $img_watermark_mask = imagerotate($img_watermark_mask, $angle, $mask_color_background); phpthumb_filters::ApplyMask($img_watermark_mask, $img_watermark); } //phpthumb_filters::WatermarkOverlay($gdimg, $img_watermark, $alignment, $opacity, $margin); $this->DebugMessage('WatermarkText() calling phpthumb_filters::WatermarkOverlay($gdimg, $img_watermark, '.($originOffsetX.'x'.$originOffsetY).', '.$opacity.', 0)', __FILE__, __LINE__); phpthumb_filters::WatermarkOverlay($gdimg, $img_watermark, $originOffsetX.'x'.$originOffsetY, $opacity, 0); - ImageDestroy($img_watermark); + imagedestroy($img_watermark); return true; } @@ -1426,16 +1422,16 @@ public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000 public function WatermarkOverlay(&$gdimg_dest, &$img_watermark, $alignment='*', $opacity=50, $margin_x=5, $margin_y=null) { if (is_resource($gdimg_dest) && is_resource($img_watermark)) { - $watermark_source_x = 0; - $watermark_source_y = 0; - $img_source_width = ImageSX($gdimg_dest); - $img_source_height = ImageSY($gdimg_dest); - $watermark_source_width = ImageSX($img_watermark); - $watermark_source_height = ImageSY($img_watermark); + $img_source_width = imagesx($gdimg_dest); + $img_source_height = imagesy($gdimg_dest); + $watermark_source_width = imagesx($img_watermark); + $watermark_source_height = imagesy($img_watermark); $watermark_opacity_percent = max(0, min(100, $opacity)); $margin_y = (is_null($margin_y) ? $margin_x : $margin_y); $watermark_margin_x = ((($margin_x > 0) && ($margin_x < 1)) ? round((1 - $margin_x) * $img_source_width) : $margin_x); $watermark_margin_y = ((($margin_y > 0) && ($margin_y < 1)) ? round((1 - $margin_y) * $img_source_height) : $margin_y); + $watermark_destination_x = 0; + $watermark_destination_y = 0; if (preg_match('#^([0-9\\.\\-]*)x([0-9\\.\\-]*)$#i', $alignment, $matches)) { $watermark_destination_x = intval($matches[1]); $watermark_destination_y = intval($matches[2]); @@ -1444,24 +1440,24 @@ public function WatermarkOverlay(&$gdimg_dest, &$img_watermark, $alignment='*', case '*': if ($gdimg_tiledwatermark = phpthumb_functions::ImageCreateFunction($img_source_width, $img_source_height)) { - ImageAlphaBlending($gdimg_tiledwatermark, false); - ImageSaveAlpha($gdimg_tiledwatermark, true); + imagealphablending($gdimg_tiledwatermark, false); + imagesavealpha($gdimg_tiledwatermark, true); $text_color_transparent = phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_tiledwatermark, 255, 0, 255, 127); - ImageFill($gdimg_tiledwatermark, 0, 0, $text_color_transparent); + imagefill($gdimg_tiledwatermark, 0, 0, $text_color_transparent); // set the tiled image transparent color to whatever the untiled image transparency index is - // ImageColorTransparent($gdimg_tiledwatermark, ImageColorTransparent($img_watermark)); + // imagecolortransparent($gdimg_tiledwatermark, imagecolortransparent($img_watermark)); // a "cleaner" way of doing it, but can't handle the margin feature :( - // ImageSetTile($gdimg_tiledwatermark, $img_watermark); - // ImageFill($gdimg_tiledwatermark, 0, 0, IMG_COLOR_TILED); + // imagesettile($gdimg_tiledwatermark, $img_watermark); + // imagefill($gdimg_tiledwatermark, 0, 0, IMG_COLOR_TILED); // break; - // ImageFill($gdimg_tiledwatermark, 0, 0, ImageColorTransparent($gdimg_tiledwatermark)); + // imagefill($gdimg_tiledwatermark, 0, 0, imagecolortransparent($gdimg_tiledwatermark)); // tile the image as many times as can fit for ($x = $watermark_margin_x; $x < ($img_source_width + $watermark_source_width); $x += ($watermark_source_width + $watermark_margin_x)) { for ($y = $watermark_margin_y; $y < ($img_source_height + $watermark_source_height); $y += ($watermark_source_height + $watermark_margin_y)) { - ImageCopy( + imagecopy( $gdimg_tiledwatermark, $img_watermark, $x, @@ -1474,12 +1470,12 @@ public function WatermarkOverlay(&$gdimg_dest, &$img_watermark, $alignment='*', } } - $watermark_source_width = ImageSX($gdimg_tiledwatermark); - $watermark_source_height = ImageSY($gdimg_tiledwatermark); + $watermark_source_width = imagesx($gdimg_tiledwatermark); + $watermark_source_height = imagesy($gdimg_tiledwatermark); $watermark_destination_x = 0; $watermark_destination_y = 0; - ImageDestroy($img_watermark); + imagedestroy($img_watermark); $img_watermark = $gdimg_tiledwatermark; } break; @@ -1520,13 +1516,6 @@ public function WatermarkOverlay(&$gdimg_dest, &$img_watermark, $alignment='*', break; case 'BL': - //echo '
';
-	////var_dump($watermark_destination_x);
-	////var_dump($watermark_destination_y);
-	//var_dump($watermark_margin_x);
-	//var_dump($img_source_height);
-	//var_dump($watermark_source_height);
-	//var_dump($watermark_margin_y);
 						$watermark_destination_x = $watermark_margin_x;
 						$watermark_destination_y = $img_source_height - $watermark_source_height - $watermark_margin_y;
 						break;
@@ -1538,9 +1527,9 @@ public function WatermarkOverlay(&$gdimg_dest, &$img_watermark, $alignment='*',
 						break;
 				}
 			}
-			ImageAlphaBlending($gdimg_dest, false);
-			ImageSaveAlpha($gdimg_dest, true);
-			ImageSaveAlpha($img_watermark, true);
+			imagealphablending($gdimg_dest, false);
+			imagesavealpha($gdimg_dest, true);
+			imagesavealpha($img_watermark, true);
 			phpthumb_functions::ImageCopyRespectAlpha($gdimg_dest, $img_watermark, $watermark_destination_x, $watermark_destination_y, 0, 0, $watermark_source_width, $watermark_source_height, $watermark_opacity_percent);
 
 			return true;
diff --git a/external/phpThumb/phpthumb.functions.php b/external/phpThumb/phpthumb.functions.php
index 5920dc6eda..ee2e55ed9a 100644
--- a/external/phpThumb/phpthumb.functions.php
+++ b/external/phpThumb/phpthumb.functions.php
@@ -229,9 +229,9 @@ static function IsHexColor($HexColorString) {
 
 	static function ImageColorAllocateAlphaSafe(&$gdimg_hexcolorallocate, $R, $G, $B, $alpha=false) {
 		if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=') && ($alpha !== false)) {
-			return ImageColorAllocateAlpha($gdimg_hexcolorallocate, $R, $G, $B, intval($alpha));
+			return imagecolorallocatealpha($gdimg_hexcolorallocate, $R, $G, $B, intval($alpha));
 		} else {
-			return ImageColorAllocate($gdimg_hexcolorallocate, $R, $G, $B);
+			return imagecolorallocate($gdimg_hexcolorallocate, $R, $G, $B);
 		}
 	}
 
@@ -248,7 +248,7 @@ static function ImageHexColorAllocate(&$gdimg_hexcolorallocate, $HexColorString,
 		if ($dieOnInvalid) {
 			die('Invalid hex color string: "'.$HexColorString.'"');
 		}
-		return ImageColorAllocate($gdimg_hexcolorallocate, 0x00, 0x00, 0x00);
+		return imagecolorallocate($gdimg_hexcolorallocate, 0x00, 0x00, 0x00);
 	}
 
 
@@ -261,7 +261,7 @@ static function GetPixelColor(&$img, $x, $y) {
 		if (!is_resource($img)) {
 			return false;
 		}
-		return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
+		return @imagecolorsforindex($img, @imagecolorat($img, $x, $y));
 	}
 
 
@@ -323,7 +323,7 @@ static function ImageCopyResampleBicubic($dst_img, $src_img, $dst_x, $dst_y, $sr
 		$scaleX2 = $scaleX / 2.0;
 		$scaleY2 = $scaleY / 2.0;
 
-		$isTrueColor = ImageIsTrueColor($src_img);
+		$isTrueColor = imageistruecolor($src_img);
 
 		for ($y = $src_y; $y < $src_y + $dst_h; $y++) {
 			$sY   = $y * $scaleY;
@@ -337,10 +337,10 @@ static function ImageCopyResampleBicubic($dst_img, $src_img, $dst_x, $dst_y, $sr
 
 				if ($isTrueColor) {
 
-					$c1 = ImageColorAt($src_img, $siX, $siY2);
-					$c2 = ImageColorAt($src_img, $siX, $siY);
-					$c3 = ImageColorAt($src_img, $siX2, $siY2);
-					$c4 = ImageColorAt($src_img, $siX2, $siY);
+					$c1 = imagecolorat($src_img, $siX, $siY2);
+					$c2 = imagecolorat($src_img, $siX, $siY);
+					$c3 = imagecolorat($src_img, $siX2, $siY2);
+					$c4 = imagecolorat($src_img, $siX2, $siY);
 
 					$r = (( $c1             +  $c2             +  $c3             +  $c4            ) >> 2) & 0xFF0000;
 					$g = ((($c1 & 0x00FF00) + ($c2 & 0x00FF00) + ($c3 & 0x00FF00) + ($c4 & 0x00FF00)) >> 2) & 0x00FF00;
@@ -348,17 +348,17 @@ static function ImageCopyResampleBicubic($dst_img, $src_img, $dst_x, $dst_y, $sr
 
 				} else {
 
-					$c1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX, $siY2));
-					$c2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX, $siY));
-					$c3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX2, $siY2));
-					$c4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX2, $siY));
+					$c1 = imagecolorsforindex($src_img, imagecolorat($src_img, $siX, $siY2));
+					$c2 = imagecolorsforindex($src_img, imagecolorat($src_img, $siX, $siY));
+					$c3 = imagecolorsforindex($src_img, imagecolorat($src_img, $siX2, $siY2));
+					$c4 = imagecolorsforindex($src_img, imagecolorat($src_img, $siX2, $siY));
 
 					$r = ($c1['red']   + $c2['red']   + $c3['red']   + $c4['red'] )  << 14;
 					$g = ($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) <<  6;
 					$b = ($c1['blue']  + $c2['blue']  + $c3['blue']  + $c4['blue'] ) >>  2;
 
 				}
-				ImageSetPixel($dst_img, $dst_x + $x - $src_x, $dst_y + $y - $src_y, $r+$g+$b);
+				imagesetpixel($dst_img, $dst_x + $x - $src_x, $dst_y + $y - $src_y, $r+$g+$b);
 			}
 		}
 		return true;
@@ -366,9 +366,9 @@ static function ImageCopyResampleBicubic($dst_img, $src_img, $dst_x, $dst_y, $sr
 
 
 	static function ImageCreateFunction($x_size, $y_size) {
-		$ImageCreateFunction = 'ImageCreate';
+		$ImageCreateFunction = 'imagecreate';
 		if (phpthumb_functions::gd_version() >= 2.0) {
-			$ImageCreateFunction = 'ImageCreateTrueColor';
+			$ImageCreateFunction = 'imagecreatetruecolor';
 		}
 		if (!function_exists($ImageCreateFunction)) {
 			return phpthumb::ErrorImage($ImageCreateFunction.'() does not exist - no GD support?');
@@ -397,7 +397,7 @@ static function ImageCopyRespectAlpha(&$dst_im, &$src_im, $dst_x, $dst_y, $src_x
 					//$RealPixel['alpha']);
 					0);
 
-				ImageSetPixel($dst_im, $dst_x + $x, $dst_y + $y, $newcolor);
+				imagesetpixel($dst_im, $dst_x + $x, $dst_y + $y, $newcolor);
 			}
 		}
 		return true;
@@ -640,7 +640,8 @@ static function URLreadFsock($host, $file, &$errstr, $successonly=true, $port=80
 			$errstr = 'fsockopen() unavailable';
 			return false;
 		}
-		if ($fp = @fsockopen($host, $port, $errno, $errstr, $timeout)) {
+		//if ($fp = @fsockopen($host, $port, $errno, $errstr, $timeout)) {
+		if ($fp = @fsockopen((($port == 443) ? 'ssl://' : '').$host, $port, $errno, $errstr, $timeout)) { // https://github.com/JamesHeinrich/phpThumb/issues/39
 			$out  = 'GET '.$file.' HTTP/1.0'."\r\n";
 			$out .= 'Host: '.$host."\r\n";
 			$out .= 'Connection: Close'."\r\n\r\n";
@@ -658,7 +659,7 @@ static function URLreadFsock($host, $file, &$errstr, $successonly=true, $port=80
 					$Data_body .= $line;
 				}
 				if (preg_match('#^HTTP/[\\.0-9]+ ([0-9]+) (.+)$#i', rtrim($line), $matches)) {
-					list($dummy, $errno, $errstr) = $matches;
+					list( , $errno, $errstr) = $matches;
 					$errno = intval($errno);
 				} elseif (preg_match('#^Location: (.*)$#i', rtrim($line), $matches)) {
 					$header_newlocation = $matches[1];
@@ -743,7 +744,9 @@ static function ParseURLbetter($url) {
 	}
 
 	static function SafeURLread($url, &$error, $timeout=10, $followredirects=true) {
-		$error = '';
+		$error   = '';
+		$errstr  = '';
+		$rawData = '';
 
 		$parsed_url = phpthumb_functions::ParseURLbetter($url);
 		$alreadyLookedAtURLs[trim($url)] = true;
@@ -751,7 +754,7 @@ static function SafeURLread($url, &$error, $timeout=10, $followredirects=true) {
 		while (true) {
 			$tryagain = false;
 			$rawData = phpthumb_functions::URLreadFsock(@$parsed_url['host'], @$parsed_url['path'].'?'.@$parsed_url['query'], $errstr, true, (@$parsed_url['port'] ? @$parsed_url['port'] : 80), $timeout);
-			if (preg_match('#302 [a-z ]+; Location\\: (http.*)#i', $errstr, $matches)) {
+			if ($followredirects && preg_match('#302 [a-z ]+; Location\\: (http.*)#i', $errstr, $matches)) {
 				$matches[1] = trim(@$matches[1]);
 				if (!@$alreadyLookedAtURLs[$matches[1]]) {
 					// loop through and examine new URL
@@ -783,6 +786,9 @@ static function SafeURLread($url, &$error, $timeout=10, $followredirects=true) {
 			curl_setopt($ch, CURLOPT_HEADER, false);
 			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 			curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
+			curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, (bool) $followredirects);
 			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
 			$rawData = curl_exec($ch);
 			curl_close($ch);
@@ -825,7 +831,7 @@ static function SafeURLread($url, &$error, $timeout=10, $followredirects=true) {
 		return false;
 	}
 
-	static function EnsureDirectoryExists($dirname) {
+	static function EnsureDirectoryExists($dirname, $mask = 0755) {
 		$directory_elements = explode(DIRECTORY_SEPARATOR, $dirname);
 		$startoffset = (!$directory_elements[0] ? 2 : 1);  // unix with leading "/" then start with 2nd element; Windows with leading "c:\" then start with 1st element
 		$open_basedirs = preg_split('#[;:]#', ini_get('open_basedir'));
@@ -847,8 +853,8 @@ static function EnsureDirectoryExists($dirname) {
 					// directory name already exists as a file
 					return false;
 				}
-				@mkdir($test_directory, 0755);
-				@chmod($test_directory, 0755);
+				@mkdir($test_directory, $mask);
+				@chmod($test_directory, $mask);
 				if (!@is_dir($test_directory) || !@is_writeable($test_directory)) {
 					return false;
 				}
@@ -899,6 +905,15 @@ static function SanitizeFilename($filename) {
 		return $filename;
 	}
 
+	static function PasswordStrength($password) {
+		$strength = 0;
+		$strength += strlen(preg_replace('#[^a-z]#',       '', $password)) * 0.5; // lowercase characters are weak
+		$strength += strlen(preg_replace('#[^A-Z]#',       '', $password)) * 0.8; // uppercase characters are somewhat better
+		$strength += strlen(preg_replace('#[^0-9]#',       '', $password)) * 1.0; // numbers are somewhat better
+		$strength += strlen(preg_replace('#[a-zA-Z0-9]#',  '', $password)) * 2.0; // other non-alphanumeric characters are best
+		return $strength;
+	}
+
 }
 
 
@@ -937,8 +952,8 @@ function gd_info() {
 			}
 			if (empty($gd_info['GD Version'])) {
 				// probable cause: "phpinfo() disabled for security reasons"
-				if (function_exists('ImageTypes')) {
-					$imagetypes = ImageTypes();
+				if (function_exists('imagetypes')) {
+					$imagetypes = imagetypes();
 					if ($imagetypes & IMG_PNG) {
 						$gd_info['PNG Support'] = true;
 					}
@@ -952,22 +967,23 @@ function gd_info() {
 						$gd_info['WBMP Support'] = true;
 					}
 				}
-				// to determine capability of GIF creation, try to use ImageCreateFromGIF on a 1px GIF
-				if (function_exists('ImageCreateFromGIF')) {
+				// to determine capability of GIF creation, try to use imagecreatefromgif on a 1px GIF
+				if (function_exists('imagecreatefromgif')) {
 					if ($tempfilename = phpthumb::phpThumb_tempnam()) {
 						if ($fp_tempfile = @fopen($tempfilename, 'wb')) {
 							fwrite($fp_tempfile, base64_decode('R0lGODlhAQABAIAAAH//AP///ywAAAAAAQABAAACAUQAOw==')); // very simple 1px GIF file base64-encoded as string
 							fclose($fp_tempfile);
+							@chmod($tempfilename, $this->getParameter('config_file_create_mask'));
 
 							// if we can convert the GIF file to a GD image then GIF create support must be enabled, otherwise it's not
-							$gd_info['GIF Read Support'] = (bool) @ImageCreateFromGIF($tempfilename);
+							$gd_info['GIF Read Support'] = (bool) @imagecreatefromgif($tempfilename);
 						}
 						unlink($tempfilename);
 					}
 				}
-				if (function_exists('ImageCreateTrueColor') && @ImageCreateTrueColor(1, 1)) {
+				if (function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) {
 					$gd_info['GD Version'] = '2.0.1 or higher (assumed)';
-				} elseif (function_exists('ImageCreate') && @ImageCreate(1, 1)) {
+				} elseif (function_exists('imagecreate') && @imagecreate(1, 1)) {
 					$gd_info['GD Version'] = '1.6.0 or higher (assumed)';
 				}
 			}
@@ -1049,5 +1065,3 @@ function imagesavealpha(&$img, $blendmode=true) {
 		return true;
 	}
 }
-
-?>
\ No newline at end of file
diff --git a/external/phpThumb/phpthumb.gif.php b/external/phpThumb/phpthumb.gif.php
index 7ed33880c7..06387d68bd 100644
--- a/external/phpThumb/phpthumb.gif.php
+++ b/external/phpThumb/phpthumb.gif.php
@@ -43,14 +43,14 @@ function gif_loadFileToGDimageResource($gifFilename, $bgColor = -1)
 		}
 		// general strategy: convert raw data to PNG then convert PNG data to GD image resource
 		$PNGdata = $gif->getPng($bgColor);
-		if ($img = @ImageCreateFromString($PNGdata)) {
+		if ($img = @imagecreatefromstring($PNGdata)) {
 
 			// excellent - PNG image data successfully converted to GD image
 			return $img;
 
 		} elseif ($img = $gif->getGD_PixelPlotterVersion()) {
 
-			// problem: ImageCreateFromString() didn't like the PNG image data.
+			// problem: imagecreatefromstring() didn't like the PNG image data.
 			//   This has been known to happen in PHP v4.0.6
 			// solution: take the raw image data and create a new GD image and plot
 			//   pixel-by-pixel on the GD image. This is extremely slow, but it does
@@ -66,7 +66,7 @@ function gif_loadFileToGDimageResource($gifFilename, $bgColor = -1)
 
 function gif_outputAsBmp($gif, $lpszFileName, $bgColor = -1)
 {
-	if (!isSet($gif) || (@get_class($gif) <> 'cgif') || !$gif->loaded() || ($lpszFileName == '')) {
+	if (!isset($gif) || (@get_class($gif) <> 'cgif') || !$gif->loaded() || ($lpszFileName == '')) {
 		return false;
 	}
 
@@ -115,22 +115,22 @@ function gif_outputAsJpeg($gif, $lpszFileName, $bgColor = -1)
 
 		if (gif_outputAsBmp($gif, $lpszFileName.'.bmp', $bgColor)) {
 			exec('cjpeg '.$lpszFileName.'.bmp >'.$lpszFileName.' 2>/dev/null');
-			@unLink($lpszFileName.'.bmp');
+			@unlink($lpszFileName.'.bmp');
 
 			if (@file_exists($lpszFileName)) {
-				if (@fileSize($lpszFileName) > 0) {
+				if (@filesize($lpszFileName) > 0) {
 					return true;
 				}
 
-				@unLink($lpszFileName);
+				@unlink($lpszFileName);
 			}
 		}
 
 	} else {
 
 		// either Windows, or cjpeg not found in path
-		if ($img = @ImageCreateFromString($gif->getPng($bgColor))) {
-			if (@ImageJPEG($img, $lpszFileName)) {
+		if ($img = @imagecreatefromstring($gif->getPng($bgColor))) {
+			if (@imagejpeg($img, $lpszFileName)) {
 				return true;
 			}
 		}
@@ -447,11 +447,12 @@ function toRGBQuad()
 
 	function colorIndex($rgb)
 	{
-		$rgb  = intval($rgb) & 0xFFFFFF;
-		$r1   = ($rgb & 0x0000FF);
-		$g1   = ($rgb & 0x00FF00) >>  8;
-		$b1   = ($rgb & 0xFF0000) >> 16;
-		$idx  = -1;
+		$rgb = intval($rgb) & 0xFFFFFF;
+		$r1  = ($rgb & 0x0000FF);
+		$g1  = ($rgb & 0x00FF00) >>  8;
+		$b1  = ($rgb & 0xFF0000) >> 16;
+		$idx = -1;
+		$dif = 0;
 
 		for ($i = 0; $i < $this->m_nColors; $i++) {
 			$r2 = ($this->m_arColors[$i] & 0x000000FF);
@@ -750,6 +751,8 @@ function w2i($str)
 	function deInterlace()
 	{
 		$data = $this->m_data;
+		$s = 0;
+		$y = 0;
 
 		for ($i = 0; $i < 4; $i++) {
 			switch($i) {
@@ -821,7 +824,7 @@ function loadFile($lpszFileName, $iIndex)
 		if (!($fh = @fopen($lpszFileName, 'rb'))) {
 			return false;
 		}
-		$this->m_lpData = @fRead($fh, @fileSize($lpszFileName));
+		$this->m_lpData = @fread($fh, @filesize($lpszFileName));
 		fclose($fh);
 
 		// GET FILE HEADER
@@ -849,7 +852,7 @@ function getSize($lpszFileName, &$width, &$height)
 		if (!($fh = @fopen($lpszFileName, 'rb'))) {
 			return false;
 		}
-		$data = @fRead($fh, @fileSize($lpszFileName));
+		$data = @fread($fh, @filesize($lpszFileName));
 		@fclose($fh);
 
 		$gfh = new CGIFFILEHEADER();
@@ -887,6 +890,7 @@ function getBmp($bgColor)
 			}
 		} else {
 			$nColors =  0;
+			$rgbq    = '';
 			$bgColor = -1;
 		}
 
@@ -986,6 +990,7 @@ function getPng($bgColor)
 			}
 		} else {
 			$nColors =  0;
+			$pal     = '';
 			$bgColor = -1;
 		}
 
@@ -1066,7 +1071,7 @@ function getPng($bgColor)
 	// Added by James Heinrich  - January 5, 2003
 
 	// Takes raw image data and plots it pixel-by-pixel on a new GD image and returns that
-	// It's extremely slow, but the only solution when ImageCreateFromString() fails
+	// It's extremely slow, but the only solution when imagecreatefromstring() fails
 	function getGD_PixelPlotterVersion()
 	{
 		if (!$this->m_bLoaded) {
@@ -1082,10 +1087,11 @@ function getGD_PixelPlotterVersion()
 			die('No color table available in getGD_PixelPlotterVersion()');
 		}
 
-		$PlottingIMG = ImageCreate($this->m_gfh->m_nWidth, $this->m_gfh->m_nHeight);
+		$PlottingIMG = imagecreate($this->m_gfh->m_nWidth, $this->m_gfh->m_nHeight);
 		$NumColorsInPal = floor(strlen($pal) / 3);
+		$ThisImageColor = array();
 		for ($i = 0; $i < $NumColorsInPal; $i++) {
-			$ThisImageColor[$i] = ImageColorAllocate(
+			$ThisImageColor[$i] = imagecolorallocate(
 									$PlottingIMG,
 									ord($pal{(($i * 3) + 0)}),
 									ord($pal{(($i * 3) + 1)}),
@@ -1107,13 +1113,13 @@ function getGD_PixelPlotterVersion()
 					($y <  ($this->m_img->m_gih->m_nTop  + $this->m_img->m_gih->m_nHeight))) {
 					// PART OF IMAGE
 					if (@$this->m_img->m_bTrans && (ord($data{$nPxl}) == $this->m_img->m_nTrans)) {
-						ImageSetPixel($PlottingIMG, $x, $this->m_gfh->m_nHeight - $y - 1, $ThisImageColor[$this->m_gfh->m_nBgColor]);
+						imagesetpixel($PlottingIMG, $x, $this->m_gfh->m_nHeight - $y - 1, $ThisImageColor[$this->m_gfh->m_nBgColor]);
 					} else {
-						ImageSetPixel($PlottingIMG, $x, $this->m_gfh->m_nHeight - $y - 1, $ThisImageColor[ord($data{$nPxl})]);
+						imagesetpixel($PlottingIMG, $x, $this->m_gfh->m_nHeight - $y - 1, $ThisImageColor[ord($data{$nPxl})]);
 					}
 				} else {
 					// BACKGROUND
-					ImageSetPixel($PlottingIMG, $x, $this->m_gfh->m_nHeight - $y - 1, $ThisImageColor[$this->m_gfh->m_nBgColor]);
+					imagesetpixel($PlottingIMG, $x, $this->m_gfh->m_nHeight - $y - 1, $ThisImageColor[$this->m_gfh->m_nBgColor]);
 				}
 			}
 			$nPxl -= $this->m_gfh->m_nWidth << 1;
@@ -1167,7 +1173,3 @@ function loaded()
 		return $this->m_bLoaded;
 	}
 }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-?>
\ No newline at end of file
diff --git a/external/phpThumb/phpthumb.ico.php b/external/phpThumb/phpthumb.ico.php
index 0daff8ab24..8b7233362f 100644
--- a/external/phpThumb/phpthumb.ico.php
+++ b/external/phpThumb/phpthumb.ico.php
@@ -12,18 +12,20 @@
 
 class phpthumb_ico {
 
-	function __construct() {
-		return true;
-	}
-
-
 	function GD2ICOstring(&$gd_image_array) {
+		$ImageWidths  = array();
+		$ImageHeights = array();
+		$bpp          = array();
+		$totalcolors  = array();
+		$icXOR        = array();
+		$icAND        = array();
+		$icANDmask    = array();
 		foreach ($gd_image_array as $key => $gd_image) {
 
-			$ImageWidths[$key]  = ImageSX($gd_image);
-			$ImageHeights[$key] = ImageSY($gd_image);
-	    	$bpp[$key]          = ImageIsTrueColor($gd_image) ? 32 : 24;
-	    	$totalcolors[$key]  = ImageColorsTotal($gd_image);
+			$ImageWidths[$key]  = imagesx($gd_image);
+			$ImageHeights[$key] = imagesy($gd_image);
+			$bpp[$key]          = imageistruecolor($gd_image) ? 32 : 24;
+			$totalcolors[$key]  = imagecolorstotal($gd_image);
 
 			$icXOR[$key] = '';
 			for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
@@ -60,24 +62,24 @@ function GD2ICOstring(&$gd_image_array) {
 
 		}
 
-	    foreach ($gd_image_array as $key => $gd_image) {
+		foreach ($gd_image_array as $key => $gd_image) {
 			$biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
 
-	    	// BITMAPINFOHEADER - 40 bytes
+			// BITMAPINFOHEADER - 40 bytes
 			$BitmapInfoHeader[$key]  = '';
 			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                              // DWORD  biSize;
 			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);      // LONG   biWidth;
 			// The biHeight member specifies the combined
 			// height of the XOR and AND masks.
 			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
-	    	$BitmapInfoHeader[$key] .= "\x01\x00";                                      // WORD   biPlanes;
-	   		$BitmapInfoHeader[$key] .= chr($bpp[$key])."\x00";                          // wBitCount;
+			$BitmapInfoHeader[$key] .= "\x01\x00";                                      // WORD   biPlanes;
+			$BitmapInfoHeader[$key] .= chr($bpp[$key])."\x00";                          // wBitCount;
 			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // DWORD  biCompression;
 			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);            // DWORD  biSizeImage;
-	    	$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // LONG   biXPelsPerMeter;
-	    	$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // LONG   biYPelsPerMeter;
-	    	$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // DWORD  biClrUsed;
-	    	$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // DWORD  biClrImportant;
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // LONG   biXPelsPerMeter;
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // LONG   biYPelsPerMeter;
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // DWORD  biClrUsed;
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // DWORD  biClrImportant;
 		}
 
 
@@ -87,34 +89,32 @@ function GD2ICOstring(&$gd_image_array) {
 
 		$dwImageOffset = 6 + (count($gd_image_array) * 16);
 		foreach ($gd_image_array as $key => $gd_image) {
-	    	// ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
+			// ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
 
-	    	$icondata .= chr($ImageWidths[$key]);                     // bWidth;          // Width, in pixels, of the image
-	    	$icondata .= chr($ImageHeights[$key]);                    // bHeight;         // Height, in pixels, of the image
-	    	$icondata .= chr($totalcolors[$key]);                     // bColorCount;     // Number of colors in image (0 if >=8bpp)
-	    	$icondata .= "\x00";                                      // bReserved;       // Reserved ( must be 0)
+			$icondata .= chr($ImageWidths[$key]);                     // bWidth;          // Width, in pixels, of the image
+			$icondata .= chr($ImageHeights[$key]);                    // bHeight;         // Height, in pixels, of the image
+			$icondata .= chr($totalcolors[$key]);                     // bColorCount;     // Number of colors in image (0 if >=8bpp)
+			$icondata .= "\x00";                                      // bReserved;       // Reserved ( must be 0)
 
-	    	$icondata .= "\x01\x00";                                  // wPlanes;         // Color Planes
+			$icondata .= "\x01\x00";                                  // wPlanes;         // Color Planes
 			$icondata .= chr($bpp[$key])."\x00";                      // wBitCount;       // Bits per pixel
 
 			$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
 			$icondata .= phpthumb_functions::LittleEndian2String($dwBytesInRes, 4);       // dwBytesInRes;    // How many bytes in this resource?
 
-		    $icondata .= phpthumb_functions::LittleEndian2String($dwImageOffset, 4);      // dwImageOffset;   // Where in the file is this image?
+			$icondata .= phpthumb_functions::LittleEndian2String($dwImageOffset, 4);      // dwImageOffset;   // Where in the file is this image?
 			$dwImageOffset += strlen($BitmapInfoHeader[$key]);
 			$dwImageOffset += strlen($icXOR[$key]);
 			$dwImageOffset += strlen($icAND[$key]);
-	    }
+		}
 
-	    foreach ($gd_image_array as $key => $gd_image) {
+		foreach ($gd_image_array as $key => $gd_image) {
 			$icondata .= $BitmapInfoHeader[$key];
 			$icondata .= $icXOR[$key];
 			$icondata .= $icAND[$key];
-	    }
+		}
 
-	    return $icondata;
+		return $icondata;
 	}
 
 }
-
-?>
\ No newline at end of file
diff --git a/external/phpThumb/phpthumb.unsharp.php b/external/phpThumb/phpthumb.unsharp.php
index 411baa95df..0e63b00c4c 100644
--- a/external/phpThumb/phpthumb.unsharp.php
+++ b/external/phpThumb/phpthumb.unsharp.php
@@ -55,10 +55,10 @@ static function applyUnsharpMask(&$img, $amount, $radius, $threshold) {
 		if ($radius == 0) {
 			return true;
 		}
-		$w = ImageSX($img);
-		$h = ImageSY($img);
-		$imgCanvas = ImageCreateTrueColor($w, $h);
-		$imgBlur   = ImageCreateTrueColor($w, $h);
+		$w = imagesx($img);
+		$h = imagesy($img);
+		$imgCanvas = imagecreatetruecolor($w, $h);
+		$imgBlur   = imagecreatetruecolor($w, $h);
 
 		// Gaussian blur matrix:
 		//
@@ -74,20 +74,20 @@ static function applyUnsharpMask(&$img, $amount, $radius, $threshold) {
 				array(2, 4, 2),
 				array(1, 2, 1)
 			);
-			ImageCopy($imgBlur, $img, 0, 0, 0, 0, $w, $h);
-			ImageConvolution($imgBlur, $matrix, 16, 0);
+			imagecopy($imgBlur, $img, 0, 0, 0, 0, $w, $h);
+			imageconvolution($imgBlur, $matrix, 16, 0);
 
 		} else {
 
 			// Move copies of the image around one pixel at the time and merge them with weight
 			// according to the matrix. The same matrix is simply repeated for higher radii.
 			for ($i = 0; $i < $radius; $i++)    {
-				ImageCopy(     $imgBlur,   $img,       0, 0, 1, 0, $w - 1, $h);               // left
-				ImageCopyMerge($imgBlur,   $img,       1, 0, 0, 0, $w    , $h,     50);       // right
-				ImageCopyMerge($imgBlur,   $img,       0, 0, 0, 0, $w    , $h,     50);       // center
-				ImageCopy(     $imgCanvas, $imgBlur,   0, 0, 0, 0, $w    , $h);
-				ImageCopyMerge($imgBlur,   $imgCanvas, 0, 0, 0, 1, $w    , $h - 1, 33.33333); // up
-				ImageCopyMerge($imgBlur,   $imgCanvas, 0, 1, 0, 0, $w    , $h,     25);       // down
+				imagecopy(     $imgBlur,   $img,       0, 0, 1, 0, $w - 1, $h);               // left
+				imagecopymerge($imgBlur,   $img,       1, 0, 0, 0, $w    , $h,     50);       // right
+				imagecopymerge($imgBlur,   $img,       0, 0, 0, 0, $w    , $h,     50);       // center
+				imagecopy(     $imgCanvas, $imgBlur,   0, 0, 0, 0, $w    , $h);
+				imagecopymerge($imgBlur,   $imgCanvas, 0, 0, 0, 1, $w    , $h - 1, 33.33333); // up
+				imagecopymerge($imgBlur,   $imgCanvas, 0, 1, 0, 0, $w    , $h,     25);       // down
 			}
 		}
 
@@ -97,12 +97,12 @@ static function applyUnsharpMask(&$img, $amount, $radius, $threshold) {
 			for ($x = 0; $x < $w-1; $x++)    { // each row
 				for ($y = 0; $y < $h; $y++)    { // each pixel
 
-					$rgbOrig = ImageColorAt($img, $x, $y);
+					$rgbOrig = imagecolorat($img, $x, $y);
 					$rOrig = (($rgbOrig >> 16) & 0xFF);
 					$gOrig = (($rgbOrig >>  8) & 0xFF);
 					$bOrig =  ($rgbOrig        & 0xFF);
 
-					$rgbBlur = ImageColorAt($imgBlur, $x, $y);
+					$rgbBlur = imagecolorat($imgBlur, $x, $y);
 
 					$rBlur = (($rgbBlur >> 16) & 0xFF);
 					$gBlur = (($rgbBlur >>  8) & 0xFF);
@@ -115,20 +115,20 @@ static function applyUnsharpMask(&$img, $amount, $radius, $threshold) {
 					$bNew = ((abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig);
 
 					if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) {
-						$pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew);
-						ImageSetPixel($img, $x, $y, $pixCol);
+						$pixCol = imagecolorallocate($img, $rNew, $gNew, $bNew);
+						imagesetpixel($img, $x, $y, $pixCol);
 					}
 				}
 			}
 		} else {
 			for ($x = 0; $x < $w; $x++)    { // each row
 				for ($y = 0; $y < $h; $y++)    { // each pixel
-					$rgbOrig = ImageColorAt($img, $x, $y);
+					$rgbOrig = imagecolorat($img, $x, $y);
 					$rOrig = (($rgbOrig >> 16) & 0xFF);
 					$gOrig = (($rgbOrig >>  8) & 0xFF);
 					$bOrig =  ($rgbOrig        & 0xFF);
 
-					$rgbBlur = ImageColorAt($imgBlur, $x, $y);
+					$rgbBlur = imagecolorat($imgBlur, $x, $y);
 
 					$rBlur = (($rgbBlur >> 16) & 0xFF);
 					$gBlur = (($rgbBlur >>  8) & 0xFF);
@@ -138,13 +138,12 @@ static function applyUnsharpMask(&$img, $amount, $radius, $threshold) {
 					$gNew = min(255, max(0, ($amount * ($gOrig - $gBlur)) + $gOrig));
 					$bNew = min(255, max(0, ($amount * ($bOrig - $bBlur)) + $bOrig));
 					$rgbNew = ($rNew << 16) + ($gNew <<8) + $bNew;
-					ImageSetPixel($img, $x, $y, $rgbNew);
+					imagesetpixel($img, $x, $y, $rgbNew);
 				}
 			}
 		}
-		ImageDestroy($imgCanvas);
-		ImageDestroy($imgBlur);
+		imagedestroy($imgCanvas);
+		imagedestroy($imgBlur);
 		return true;
 	}
 }
-?>
\ No newline at end of file