Fifth pass at adding key files
This commit is contained in:
4
site/racecalendar/phpthumb/cache/index.php
vendored
Normal file
4
site/racecalendar/phpthumb/cache/index.php
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
header('Location: /');
|
||||
exit;
|
||||
?>
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
4
site/racecalendar/phpthumb/cache/source/index.php
vendored
Normal file
4
site/racecalendar/phpthumb/cache/source/index.php
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
header('Location: /');
|
||||
exit;
|
||||
?>
|
4
site/racecalendar/phpthumb/demo/index.php
Normal file
4
site/racecalendar/phpthumb/demo/index.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
header('Location: phpThumb.demo.demo.php');
|
||||
exit;
|
||||
?>
|
278
site/racecalendar/phpthumb/demo/phpThumb.demo.check.php
Normal file
278
site/racecalendar/phpthumb/demo/phpThumb.demo.check.php
Normal file
@ -0,0 +1,278 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// //
|
||||
// phpThumb.demo.check.php //
|
||||
// James Heinrich <info@silisoftware.com> //
|
||||
// //
|
||||
// Configuration analyzer for phpThumb settings and server //
|
||||
// settings that may affect phpThumb performance //
|
||||
// Live demo is at http://phpthumb.sourceforge.net/demo/ //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
$ServerInfo['gd_string'] = 'unknown';
|
||||
$ServerInfo['gd_numeric'] = 0;
|
||||
ob_start();
|
||||
if (!@include_once('../phpthumb.functions.php')) {
|
||||
ob_end_flush();
|
||||
die('failed to include_once("../phpthumb.functions.php")');
|
||||
}
|
||||
if (!@include_once('../phpthumb.class.php')) {
|
||||
ob_end_flush();
|
||||
die('failed to include_once("../phpthumb.class.php")');
|
||||
}
|
||||
ob_end_clean();
|
||||
$phpThumb = new phpThumb();
|
||||
if (include_once('../phpThumb.config.php')) {
|
||||
foreach ($PHPTHUMB_CONFIG as $key => $value) {
|
||||
$keyname = 'config_'.$key;
|
||||
$phpThumb->setParameter($keyname, $value);
|
||||
}
|
||||
}
|
||||
$ServerInfo['gd_string'] = phpthumb_functions::gd_version(true);
|
||||
$ServerInfo['gd_numeric'] = phpthumb_functions::gd_version(false);
|
||||
$ServerInfo['im_version'] = $phpThumb->ImageMagickVersion();
|
||||
$gd_info = gd_info();
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>phpThumb configuration analyzer</title>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css" title="style sheet">
|
||||
</head>
|
||||
<body bgcolor="#C5C5C5">
|
||||
|
||||
This demo analyzes your settings (phpThumb.config.php and server/PHP) for <a href="http://phpthumb.sourceforge.net"><b>phpThumb()</b></a>.<br>
|
||||
<br>
|
||||
<table border="1">
|
||||
<tr><th colspan="8"><-- bad to good --></th></tr>
|
||||
<tr>
|
||||
<td bgcolor="red"> </td>
|
||||
<td bgcolor="orange"> </td>
|
||||
<td bgcolor="yellow"> </td>
|
||||
<td bgcolor="olive"> </td>
|
||||
<td bgcolor="darkgreen"> </td>
|
||||
<td bgcolor="green"> </td>
|
||||
<td bgcolor="lightgreen"> </td>
|
||||
<td bgcolor="lime"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border="1">
|
||||
<?php
|
||||
|
||||
$versions['raw'] = array(
|
||||
'latest' => phpthumb_functions::SafeURLread('http://phpthumb.sourceforge.net/?latestversion=1', $dummy),
|
||||
'this' => $phpThumb->phpthumb_version,
|
||||
);
|
||||
foreach ($versions['raw'] as $key => $value) {
|
||||
eregi('^([0-9\.]+)\-?(([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}))?', $value, $matches);
|
||||
@list($huge, $major, $minor) = @explode('.', @$matches[1]);
|
||||
@list($year, $month, $day, $hour, $min) = @$matches[3];
|
||||
$versions['base'][$key] = $matches[1];
|
||||
$versions['huge'][$key] = $huge;
|
||||
$versions['major'][$key] = $major;
|
||||
$versions['minor'][$key] = $minor;
|
||||
$versions['stamp'][$key] = $matches[2];
|
||||
$versions['year'][$key] = $year;
|
||||
$versions['month'][$key] = $month;
|
||||
$versions['day'][$key] = $day;
|
||||
$versions['hour'][$key] = $hour;
|
||||
$versions['min'][$key] = $min;
|
||||
$versions['date'][$key] = @mktime($hour, $min, 0, $month, $day, $year);
|
||||
}
|
||||
|
||||
$downloadlatest = 'Download the latest version from <a href="http://phpthumb.sourceforge.net">http://phpthumb.sourceforge.net</a>';
|
||||
echo '<tr><th nowrap>Latest phpThumb version:</th><th>'.$versions['raw']['latest'].'</th><td>'.$downloadlatest.'</td></tr>';
|
||||
echo '<tr><th nowrap>This phpThumb version:</th><th bgcolor="';
|
||||
|
||||
if (!$versions['base']['latest']) {
|
||||
// failed to get latest version number
|
||||
echo 'white';
|
||||
$message = 'Latest version unknown.<br>'.$downloadlatest;
|
||||
} elseif (phpthumb_functions::version_compare_replacement($versions['base']['this'], $versions['base']['latest'], '>')) {
|
||||
// new than latest, must be beta version
|
||||
echo 'lightblue';
|
||||
$message = 'This must be a pre-release beta version. Please report bugs to <a href="mailto:info@silisoftware.com">info@silisoftware.com</a>';
|
||||
} elseif (($versions['base']['latest'] == $versions['base']['this']) && ($versions['stamp']['this'] > $versions['stamp']['latest'])) {
|
||||
// new than latest, must be beta version
|
||||
echo 'lightblue';
|
||||
$message = 'You must be using a pre-release beta version. Please report bugs to <a href="mailto:info@silisoftware.com">info@silisoftware.com</a>';
|
||||
} elseif ($versions['base']['latest'] == $versions['base']['this']) {
|
||||
// latest version
|
||||
echo 'lime';
|
||||
$message = 'You are using the latest released version.';
|
||||
} elseif ($versions['huge']['latest'].$versions['major']['latest'] == $versions['huge']['this'].$versions['major']['this']) {
|
||||
echo 'olive';
|
||||
$message = 'One (or more) minor version(s) have been released since this version.<br>'.$downloadlatest;
|
||||
} elseif (floatval($versions['huge']['latest'].str_pad($versions['major']['latest'], 2, '0', STR_PAD_LEFT)) < floatval($versions['huge']['this'].str_pad($t_major, 2, '0', STR_PAD_LEFT))) {
|
||||
echo 'yellow';
|
||||
$message = 'One (or more) major version(s) have been released since this version, you really should upgrade.<br>'.$downloadlatest;
|
||||
} else {
|
||||
echo 'orange';
|
||||
$message = 'Fundamental changes have been made since this version.<br>'.$downloadlatest;
|
||||
}
|
||||
echo '">'.$phpThumb->phpthumb_version;
|
||||
echo '</td><td>'.$message.'.<br></td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>PHP version:</th><th bgcolor="';
|
||||
if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=')) {
|
||||
echo 'lime';
|
||||
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.3', '>=')) {
|
||||
echo 'lightgreen';
|
||||
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.2.0', '>=')) {
|
||||
echo 'green';
|
||||
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.1.0', '>=')) {
|
||||
echo 'yellow';
|
||||
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.0.6', '>=')) {
|
||||
echo 'orange';
|
||||
} else {
|
||||
echo 'red';
|
||||
}
|
||||
echo '">'.phpversion();
|
||||
echo '</td><td>PHP5 is ideal (support for numerous built-in filters which are much faster than my code).<br>PHP v4.3.2+ supports ImageSaveAlpha which is required for proper PNG/ICO output.<br>ImageRotate requires PHP v4.3.0+ (but buggy before v4.3.3).<br>EXIF thumbnail extraction requires PHP v4.2.0+.<br>Most things will work back to PHP v4.1.0, and mostly (perhaps buggy) back to v4.0.6, but no guarantees for any version older than that.</td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>GD version:</th><th bgcolor="';
|
||||
if ($ServerInfo['gd_numeric'] >= 2) {
|
||||
if (eregi('bundled', @$ServerInfo['gd_string'])) {
|
||||
echo 'lime';
|
||||
} else {
|
||||
echo 'yellow';
|
||||
}
|
||||
} elseif ($ServerInfo['im_version']) {
|
||||
echo 'orange';
|
||||
} else {
|
||||
echo 'red';
|
||||
}
|
||||
echo '">'.@$ServerInfo['gd_string'];
|
||||
echo '</td><td>GD2-bundled version is ideal.<br>GD2 (non-bundled) is second choice, but there are a number of bugs in the non-bundled version.<br>GD1 will also (mostly) work, at much-reduced image quality and several features disabled. phpThumb can perform basic resizing with ImageMagick only, even if GD is not available.</td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>ImageMagick version:</th><th bgcolor="';
|
||||
if ($ServerInfo['im_version']) {
|
||||
echo 'lime';
|
||||
} elseif (@$ServerInfo['gd_string']) {
|
||||
echo 'yellow';
|
||||
} else {
|
||||
echo 'red';
|
||||
}
|
||||
echo '">'.($ServerInfo['im_version'] ? $ServerInfo['im_version'] : 'n/a');
|
||||
echo '</td><td>ImageMagick is faster than GD, can process larger images without PHP memory_limit issues, can resize animated GIFs. phpThumb can perform basic resizing with ImageMagick only, even if GD is not available.</td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>GD features:</th><th>';
|
||||
$GDfeatures['red'] = array('JPG Support', 'PNG Support');
|
||||
$GDfeatures['orange'] = array('GIF Read Support', 'GIF Create Support', 'FreeType Support');
|
||||
foreach ($GDfeatures as $missingcolor => $features) {
|
||||
foreach ($features as $dummy => $feature) {
|
||||
echo '<div style="background-color: '.($gd_info[$feature] ? 'lime' : $missingcolor).';">'.htmlentities($feature).'</div>';
|
||||
}
|
||||
}
|
||||
echo '</td><td>PNG support is required for watermarks, overlays, calls to ImageMagick and other internal operations.<br>JPG support is obviously quite useful, but ImageMagick can substitute<br>GIF read support can be bypassed with ImageMagick and/or internal GIF routines.<br>GIF create support can be bypassed with ImageMagick (if no filters are applied)<br>FreeType support is needed for TTF overlays.</td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>GD extension "EXIF"</th><th bgcolor="';
|
||||
if (extension_loaded('exif')) {
|
||||
echo 'lime';
|
||||
} elseif (@$ServerInfo['gd_string']) {
|
||||
echo 'orange';
|
||||
}
|
||||
echo '">'.(extension_loaded('exif') ? 'TRUE' : 'FALSE');
|
||||
echo '</td><td>EXIF extension required for auto-rotate images. Also required to extract EXIF thumbnail to use as source if source image is too large for PHP memory_limit and ImageMagick is unavailable.</td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>magic_quotes_runtime:</th><th bgcolor="';
|
||||
if (@ini_get('magic_quotes_runtime')) {
|
||||
echo 'red';
|
||||
} else {
|
||||
echo 'lime';
|
||||
}
|
||||
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @get_magic_quotes_runtime());
|
||||
echo '</td><td>This setting is evil. Turn it off.</td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>magic_quotes_gpc:</th><th bgcolor="';
|
||||
if (@ini_get('magic_quotes_runtime')) {
|
||||
echo 'orange';
|
||||
} else {
|
||||
echo 'lime';
|
||||
}
|
||||
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @get_magic_quotes_gpc());
|
||||
echo '</td><td>This setting is bad. Turn it off, if possible. phpThumb will attempt to work around it if it is enabled</td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>safe_mode:</th><th bgcolor="';
|
||||
if (@ini_get('safe_mode')) {
|
||||
echo 'yellow';
|
||||
} else {
|
||||
echo 'lime';
|
||||
}
|
||||
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @ini_get('safe_mode'));
|
||||
echo '</td><td>Best if off. Calls to ImageMagick will be disabled if on (limiting max image resolution, no animated GIF resize).</td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>allow_url_fopen:</th><th bgcolor="';
|
||||
if (@ini_get('allow_url_fopen')) {
|
||||
echo 'lime';
|
||||
} else {
|
||||
echo 'yellow';
|
||||
}
|
||||
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @ini_get('allow_url_fopen'));
|
||||
echo '</td><td>Best if on. HTTP source images will be unavailable if disabled and CURL is unavailable.</td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>curl_version:</th><th bgcolor="';
|
||||
if (function_exists('curl_version')) {
|
||||
echo 'lime';
|
||||
} else {
|
||||
echo 'yellow';
|
||||
}
|
||||
echo '">'.(function_exists('curl_version') ? curl_version() : 'n/a') ;
|
||||
echo '</td><td>Best if available. HTTP source images will be unavailable if CURL unavailable and <i>allow_url_fopen</i> is also disabled.</td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>disable_functions:</th><th bgcolor="';
|
||||
$disable_functions = @ini_get('disable_functions');
|
||||
if (!$disable_functions) {
|
||||
echo 'lime';
|
||||
} else {
|
||||
echo 'yellow';
|
||||
}
|
||||
echo '">'.eregi_replace('(shell_exec|system|passthru|exec)(,|$)', '<span style="background-color: red;">\\1</span>(\\2)', $disable_functions);
|
||||
echo '</td><td>Best if nothing disabled. Calls to ImageMagick will be prevented if exec+system+shell_exec+passthru are disabled.</td></tr>';
|
||||
|
||||
|
||||
echo '<tr><th>memory_limit:</th><th bgcolor="';
|
||||
$memory_limit = @ini_get('memory_limit');
|
||||
if (!$memory_limit) {
|
||||
echo 'lime';
|
||||
} elseif ($memory_limit >= 32) {
|
||||
echo 'lime';
|
||||
} elseif ($memory_limit >= 24) {
|
||||
echo 'lightgreen';
|
||||
} elseif ($memory_limit >= 16) {
|
||||
echo 'green';
|
||||
} elseif ($memory_limit >= 12) {
|
||||
echo 'darkgreen';
|
||||
} elseif ($memory_limit >= 8) {
|
||||
echo 'olive';
|
||||
} elseif ($memory_limit >= 4) {
|
||||
echo 'yellow';
|
||||
} elseif ($memory_limit >= 2) {
|
||||
echo 'orange';
|
||||
} else {
|
||||
echo 'red';
|
||||
}
|
||||
echo '">'.($memory_limit ? $memory_limit : '<i>unlimited</i>');
|
||||
echo '</td><td>The higher the better. Divide by 5 to get maximum megapixels of source image that can be thumbnailed (without ImageMagick).'.($memory_limit ? ' Your setting ('.$memory_limit.') allows images up to approximately '.number_format($memory_limit / 5, 1).' megapixels' : '').'</td></tr>';
|
||||
|
||||
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
249
site/racecalendar/phpthumb/demo/phpThumb.demo.demo.php
Normal file
249
site/racecalendar/phpthumb/demo/phpThumb.demo.demo.php
Normal file
@ -0,0 +1,249 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// //
|
||||
// phpThumb.demo.demo.php //
|
||||
// James Heinrich <info@silisoftware.com> //
|
||||
// //
|
||||
// Demo showing a wide variety of parameters that can be //
|
||||
// passed to phpThumb.php //
|
||||
// Live demo is at http://phpthumb.sourceforge.net/demo/ //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////
|
||||
$ServerInfo['gd_string'] = 'unknown';
|
||||
$ServerInfo['gd_numeric'] = 0;
|
||||
ob_start();
|
||||
if (!@include_once('../phpthumb.functions.php')) {
|
||||
ob_end_flush();
|
||||
die('failed to include_once("../phpthumb.functions.php")');
|
||||
}
|
||||
if (!@include_once('../phpthumb.class.php')) {
|
||||
ob_end_flush();
|
||||
die('failed to include_once("../phpthumb.class.php")');
|
||||
}
|
||||
ob_end_clean();
|
||||
$phpThumb = new phpThumb();
|
||||
if (include_once('../phpThumb.config.php')) {
|
||||
foreach ($PHPTHUMB_CONFIG as $key => $value) {
|
||||
$keyname = 'config_'.$key;
|
||||
$phpThumb->setParameter($keyname, $value);
|
||||
}
|
||||
}
|
||||
$ServerInfo['phpthumb_version'] = $phpThumb->phpthumb_version;
|
||||
$ServerInfo['im_version'] = $phpThumb->ImageMagickVersion();;
|
||||
$ServerInfo['gd_string'] = phpthumb_functions::gd_version(true);
|
||||
$ServerInfo['gd_numeric'] = phpthumb_functions::gd_version(false);
|
||||
unset($phpThumb);
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Demo of phpThumb() - thumbnails created by PHP using GD and/or ImageMagick</title>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css" title="style sheet">
|
||||
</head>
|
||||
<body bgcolor="#C5C5C5">
|
||||
|
||||
This is a demo of <a href="http://phpthumb.sourceforge.net"><b>phpThumb()</b></a> (current version: v<?php echo @$ServerInfo['phpthumb_version']; ?>)<br>
|
||||
<br>
|
||||
<b>Note:</b> this server is working on GD "<?php
|
||||
echo $ServerInfo['gd_string'].'"';
|
||||
if ($ServerInfo['gd_numeric'] >= 2) {
|
||||
echo ', so images should be of optimal quality.';
|
||||
} else {
|
||||
echo ', so images (especially watermarks) do not look as good as they would on GD v2.';
|
||||
}
|
||||
?><br>
|
||||
|
||||
<hr size="1">
|
||||
<a href="#showpic">phpThumb.demo.showpic.php demo here</a><br>
|
||||
<a href="#gd1vs2">Difference between GD1 and GD2</a><br>
|
||||
<hr size="1">
|
||||
<table border="5" align="center" width="500" cellpadding="5"><tr><td>
|
||||
<b>The following images have the textured background behind them to illustrate transparency effects.
|
||||
Note that some browsers, notably Internet Explorer, are incapable of displaying alpha-channel PNGs.
|
||||
See my page on the <a href="http://www.silisoftware.com/png_alpha_transparency/" target="_blank">PNG transparency problem</a>.
|
||||
Other modern browsers such as <a href="http://www.mozilla.org">Mozilla/Firefox</a> display alpha-transparent PNGs with no problems.</b>
|
||||
</td></tr></table><br>
|
||||
<script language="Javascript" defer>
|
||||
<!--
|
||||
var agt = navigator.userAgent.toLowerCase();
|
||||
if ((agt.indexOf("opera") == -1) && (navigator.product != "Gecko")) {
|
||||
alert("You are (probably) using Internet Explorer and PNG transparency is (probably) broken");
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
|
||||
|
||||
<?php
|
||||
$phpThumbBase = '../phpThumb.php?';
|
||||
|
||||
$img['background'] = 'images/lrock011.jpg';
|
||||
|
||||
$img['square'] = 'images/disk.jpg';
|
||||
$img['landscape'] = 'images/loco.jpg';
|
||||
$img['portrait'] = 'images/pineapple.jpg';
|
||||
$img['unrotated'] = 'images/monkey.jpg';
|
||||
$img['watermark'] = 'images/watermark.png';
|
||||
$img['levels'] = 'images/bunnies.jpg';
|
||||
$img['anigif'] = 'images/animaple.gif';
|
||||
$img['alpha'] = 'images/alpha.png';
|
||||
//$img['alpha'] = 'images/North15.gif';
|
||||
|
||||
$img['mask1'] = 'images/mask04.png';
|
||||
$img['mask2'] = 'images/mask05.png';
|
||||
$img['mask3'] = 'images/mask06.png';
|
||||
|
||||
$img['frame1'] = 'images/frame1.png';
|
||||
$img['frame2'] = 'images/frame2.png';
|
||||
|
||||
$img['bmp'] = 'images/winnt.bmp';
|
||||
$img['tiff'] = 'images/1024-none.tiff';
|
||||
$img['wmf'] = 'images/computer.wmf';
|
||||
|
||||
$img['small'] = 'images/small.jpg';
|
||||
$img['big'] = 'images/big.jpg';
|
||||
|
||||
$png_alpha = 'Note: PNG/ICO output is 32-bit with alpha transparency, subject to <a href="http://www.silisoftware.com/png_alpha_transparency/" target="_blank">PNG transparency problem</a> in Internet Explorer';
|
||||
$only_gd = '<br>(only works with GD (any version), this server is '.($ServerInfo['gd_string'] ? 'running GD "<i>'.$ServerInfo['gd_string'].'</i>" so it <b><font color="green">will</font>' : 'not running any recognized version of GD so it <b><font color="red">will not</font>').'</b> work)';
|
||||
$only_gd2 = '<br>(only works with GD v2.0+, this server is running GD "<i>'.($ServerInfo['gd_string'] ? $ServerInfo['gd_string'] : 'n/a').'</i>" so it <b>'.(($ServerInfo['gd_numeric'] >= 2) ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
|
||||
$only_php42 = '<br>(only works with PHP v4.2.0+, this server is running PHP v'.phpversion().' so it <b>'.(version_compare(phpversion(), '4.2.0', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
|
||||
$only_php43 = '<br>(only works with PHP v4.3.0+, this server is running PHP v'.phpversion().' so it <b>'.(version_compare(phpversion(), '4.3.0', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
|
||||
$only_php432 = '<br>(only works with PHP v4.3.2+, this server is running PHP v'.phpversion().' so it <b>'.(version_compare(phpversion(), '4.3.2', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work (correctly))';
|
||||
$only_php500 = '<br>(only works with PHP v5.0.0+, this server is running PHP v'.phpversion().' so it <b>'.(version_compare(phpversion(), '5.0.0', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work (correctly))';
|
||||
$php5_or_IM = '<br>(only works with PHP v5.0.0+ <i>or</i> ImageMagick, this server is running PHP v'.phpversion().' and "<i>'.($ServerInfo['im_version'] ? $ServerInfo['im_version'] : 'n/a').'</i>" so it <b>'.(($ServerInfo['im_version'] && version_compare(phpversion(), '5.0.0', '>=')) ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work (correctly))';
|
||||
$only_exif = '<br>(only works when the EXIF extension is loaded, so on this server it <b>'.(extension_loaded('exif') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
|
||||
$only_im = '<br>(requires ImageMagick, this server is running "<i>'.($ServerInfo['im_version'] ? $ServerInfo['im_version'] : 'n/a').'</i>" so it <b>'.($ServerInfo['im_version'] ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
|
||||
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['square'].'&w=200'), 'description' => 'width=200px');
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['square'].'&w=200&q=10'), 'description' => 'width=200px, JPEGquality=10%');
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['watermark'].'&w=400&aoe=1&bg=ffffff'), 'description' => 'width=400px, AllowOutputEnlargement enabled');
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['square'].'&w=250&sx=600&sy=5&sw=100&sh=100&aoe=1'), 'description' => 'section from (600x5 - 700x105) cropped and enlarged by 250%, AllowOutputEnlargement enabled');
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.urlencode('http://silisoftware.com/images/SiliSoft.gif').'&w=100'), 'description' => 'HTTP source image'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['square'].'&w=200&fltr[]=wmi|'.$img['watermark'].'|BL'), 'description' => 'width=200px, watermark (bottom-left, 75% opacity)'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['square'].'&w=200&fltr[]=wmi|'.$img['watermark'].'|*|25'), 'description' => 'width=200px, watermark (tiled, 25% opacity)'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['watermark'].'&bg=00FFFF&f=png', $phpThumbBase.'src='.$img['watermark'].'&bg=00FFFF&f=gif', $phpThumbBase.'src='.$img['watermark'].'&bg=00FFFF&f=jpeg'), 'description' => 'source image (GIF) transpancy with transparent output (PNG, GIF) vs. specified background color (JPEG)');
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['anigif'], $phpThumbBase.'src='.$img['anigif'].'&w=25&f=gif', $phpThumbBase.'src='.$img['anigif'].'&w=25&f=png', $phpThumbBase.'src='.$img['anigif'].'&w=25&f=ico', $phpThumbBase.'src='.$img['anigif'].'&w=25&f=bmp', $phpThumbBase.'src='.$img['anigif'].'&w=25&f=jpeg'), 'description' => 'resize animated GIF. Notice how output format affects the result: GIF is animated and transparent; PNG and ICO are tranparent but not animated (first frame is rendered as a still image); JPEG and BMP are neither transparent nor animated. Any filters will disable animated resizing (may be fixed in a future version).<br>'.$only_im);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['alpha'].'&f=png', $phpThumbBase.'src='.$img['alpha'].'&f=ico', $phpThumbBase.'src='.$img['alpha'].'&f=gif', $phpThumbBase.'src='.$img['alpha'].'&f=jpeg'), 'description' => 'PNG alpha transparency test, using test image from the <a href="http://trific.ath.cx/web/png/">PNG transparency test page</a>'.$only_php432);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=usm|80|0.5|3'), 'description' => 'normal vs. unsharp masking at default settings'.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=blur|1', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=blur|5'), 'description' => 'normal vs. blur at default (1) and heavy (5)'.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=gblr', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=sblr'), 'description' => 'normal vs. gaussian blur vs. selective blur'.$only_php500.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&w=100&h=100&far=L&bg=0000FF&f=png&fltr[]=bord|1', $phpThumbBase.'src='.$img['landscape'].'&w=100&h=100&far=T&bg=FF0000&f=png&fltr[]=bord|1', $phpThumbBase.'src='.$img['portrait'].'&w=100&h=100&far=C&bg=0000FF&f=png&fltr[]=bord|1', $phpThumbBase.'src='.$img['landscape'].'&w=100&h=100&far=B&bg=FF0000&f=png&fltr[]=bord|1', $phpThumbBase.'src='.$img['portrait'].'&w=100&h=100&far=R&bg=0000FF&f=png&fltr[]=bord|1'), 'description' => 'Forced Aspect Ratio, colored background, PNG output'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&w=150&ar=L', $phpThumbBase.'src='.$img['landscape'].'&w=150&ar=L'), 'description' => 'auto-rotate counter-clockwise to landscape from portrait & lanscape'.$only_php42.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&hp=100&wl=200', $phpThumbBase.'src='.$img['landscape'].'&hp=100&wl=200'), 'description' => 'auto-selection of W and H based on source image orientation');
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['unrotated'].'&w=150&h=150', $phpThumbBase.'src='.$img['unrotated'].'&w=150&h=150&ar=x'), 'description' => 'original image vs. auto-rotated based on EXIF data'.$only_php42.$only_exif.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&ra=30&bg=0000FF', $phpThumbBase.'src='.$img['landscape'].'&w=200&ra=30&f=png', $phpThumbBase.'src='.$img['alpha'].'&ra=30&f=png', $phpThumbBase.'src='.$img['alpha'].'&ra=30&f=gif'), 'description' => 'Rotated 30<33> (counter-clockwise), width=200px, blue background vs. transparent background vs. rotated image with pre-existing alpha'.$only_php42.$only_gd);
|
||||
//$Examples[] = array('getstrings' => array($phpThumbBase.'src=images/1-bit.gif&ra=30&f=png', $phpThumbBase.'src=images/4-bit.gif&ra=30&f=png', $phpThumbBase.'src=images/8-bit.gif&ra=30&f=png'), 'description' => '2-color, 16-color, 256-color transparent GIFs'.$only_php42.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&h=300&far=1&bg=CCCCCC', $phpThumbBase.'src='.$img['landscape'].'&w=200&h=300&iar=1'), 'description' => 'Normal resize behavior (left) vs. Forced non-proportional resize (right)'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=150&h=150&zc=1', $phpThumbBase.'src='.$img['portrait'].'&w=150&h=150&zc=1'), 'description' => 'Zoom-Crop');
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=bord|2|20|10|009900&f=png'), 'description' => '2px border, curved border corners (20px horizontal radius, 10px vertical radius)'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=ric|50|20&f=png'), 'description' => 'curved border corners (20px vertical radius, 50px horizontal radius)<br>'.$png_alpha.$only_gd2.$only_php432);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=sat|75', $phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=sat|-100'), 'description' => 'saturation -75% vs. normal vs. -100%'.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=ds|75', $phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=ds|-100'), 'description' => 'desaturated 75% vs. normal vs. -100%'.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=clr|25|00FF00'), 'description' => 'colorized 25% to green (#00FF00)'.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=gray', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=sep'), 'description' => 'grayscale vs. sepia'.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=mask|'.$img['mask3'].'&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=mask|'.$img['mask1'].'&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=mask|'.$img['mask2'].'&f=jpeg&bg=9900CC&q=100'), 'description' => 'Assorted alpha masks (seen below) applied<br>'.$png_alpha.$only_php432.'<br>JPEG/GIF output is flattened to "bg" background color'.$only_gd2.'<br><img src="../'.$img['mask3'].'"> <img src="../'.$img['mask1'].'"> <img src="../'.$img['mask2'].'">');
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=drop|5|10|000000|225&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=mask|'.$img['mask3'].'&fltr[]=drop|5|10|000000|225&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=drop|5|10|000000|225&fltr[]=elip&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=elip&fltr[]=drop|5|10|000000|225&f=png'), 'description' => 'Drop shadow. Note how the order in which filters are applied matters.'.$only_php432.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=elip&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=elip&f=jpeg&bg=00FFFF'), 'description' => 'Elipse<br>'.$png_alpha.$only_php432.'<br>JPEG/GIF output is flattened to "bg" background color'.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=flip|x', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=flip|y', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=flip|xy'), 'description' => 'flipped on X, Y and X+Y axes'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=bvl|10|FFFFFF|000000', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=bvl|10|000000|FFFFFF'), 'description' => '10px bevel edge filter'.$only_php432.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=fram|3|2|CCCCCC|FFFFFF|000000', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=fram|3|2|CC9966|333333|CCCCCC'), 'description' => '3+2px frame filter'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=neg'), 'description' => 'Negative filter (inverted color)'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=th|105', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=mask|'.$img['mask1'].'&fltr[]=th|105&f=png'), 'description' => 'Threshold filter; showing preserved alpha channel'.$only_php432.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&w=150', $phpThumbBase.'src='.$img['portrait'].'&w=150&fltr[]=rcd|16|1', $phpThumbBase.'src='.$img['portrait'].'&w=150&fltr[]=rcd|16|0', $phpThumbBase.'src='.$img['portrait'].'&w=150&fltr[]=gray&fltr[]=rcd|8|1'), 'description' => 'ReduceColorDepth filter; original vs. 16-color dither vs. 16-color nodither vs. 4-gray dither'.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['levels'].'&w=200', $phpThumbBase.'src='.$img['levels'].'&w=200&fltr[]=lvl'), 'description' => 'original vs. Levels filter (default settings)'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&w=200', $phpThumbBase.'src='.$img['portrait'].'&w=200&fltr[]=wb', $phpThumbBase.'src='.$img['portrait'].'&w=200&fltr[]=wb&fltr[]=lvl'), 'description' => 'original vs. White Balance vs. White Balance + Levels'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=300&fltr[]=hist|rgb', $phpThumbBase.'src='.$img['levels'].'&w=200&fltr[]=hist|*'), 'description' => 'histograms of RGB vs. grayscale'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=300&fltr[]=edge'), 'description' => 'Edge Detect filter'.$php5_or_IM.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=300&fltr[]=emb'), 'description' => 'Emboss filter'.$php5_or_IM.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=300&fltr[]=mean'), 'description' => 'Mean Removal filter'.$only_php500.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=300&fltr[]=smth'), 'description' => 'Smooth filter'.$only_php500.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=gam|0.6', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=gam|1.6'), 'description' => 'Gamma corrected to 0.6 vs. 1.6'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=brit|50', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=brit|-50'), 'description' => 'Brightness filter (original vs. +50 vs. -50)'.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=cont|50', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=cont|-50'), 'description' => 'Contrast filter (original vs. +50 vs. -50)'.$only_gd2);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&w=200&fltr[]=over|'.$img['frame1'].'|0', $phpThumbBase.'src='.$img['portrait'].'&w=200&fltr[]=over|'.$img['frame2'].'|1'), 'description' => 'Overlay vs. Underlay<br><br>Original over/under images:<br><table border="0"><tr><td style="padding: 20px; background-image: url(../'.$img['background'].');"><img src="../'.$img['frame1'].'"> <img src="../'.$img['frame2'].'"></td></tr></table>'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|phpThumb|18|C|FF0000|loki.ttf|100|5|20&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|copyright+'.date('Y').'|3|BR|00FFFF||50&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|copyright+'.date('Y').'%0AphpThumb()|3|L|00FFFF&f=png'), 'description' => 'Text overlay, TTF and built-in fonts, multiple lines, metacharacters (height, width)'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|thumbnail+=+^Xx^Y|3|BR|00FFFF||50&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|click%0Ahere%0A^FkkB|10|L|FF00FF|arial.ttf|100|0||333399|50|y&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|resized:+^Xx^Y+to+^xx^y|10|B|FFFFFF|arial.ttf|100|0||000000|100|x&f=png'), 'description' => 'metacharacters (height, width), background color, background extend'.$only_gd);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'new=FF0000&w=100&h=50&fltr[]=bvl|10&fltr[]=wmt|hello|14|C|00FFFF|arial.ttf&f=png', $phpThumbBase.'new=FF0000|25&w=150&h=50&fltr[]=bvl|10&fltr[]=wmt|25%+opaque|14|C|0066FF|arial.ttf&f=png'), 'description' => 'Image created with "new", red background, bevel, TTF text'.$only_gd);
|
||||
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['bmp'].'&w=200'), 'description' => 'BMP source, width=200px');
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['tiff'], $phpThumbBase.'src='.$img['tiff'].'&w=200&aoe=1'), 'description' => 'TIFF source, width=200px'.$only_im);
|
||||
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['wmf'].'&w=200'), 'description' => 'WMF source, width=200px'.$only_im);
|
||||
//$Examples[] = array('getstrings' => array(''), 'description' => '');
|
||||
|
||||
foreach ($Examples as $key => $ExamplesArray) {
|
||||
echo '<a href="#" name="'.$key.'" title="click to get URL link for example #'.$key.'" onClick="prompt(\'Here is the link to example #'.$key.'\', \'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'#'.$key.'\'); return false;">#'.$key.'</a>';
|
||||
echo '<table border="0"><tr><td style="padding: 20px; background-image: url(../'.$img['background'].');">';
|
||||
foreach ($ExamplesArray['getstrings'] as $dummy => $GETstring) {
|
||||
echo '<a href="'.$GETstring.'&down='.urlencode($GETstring).'" title="'.htmlentities(str_replace($phpThumbBase, '', $GETstring), ENT_QUOTES).'">';
|
||||
echo '<img border="0" src="'.$GETstring.'">';
|
||||
echo '</a> ';
|
||||
}
|
||||
echo '</td></tr></table>';
|
||||
echo '<xmp><img src="'.implode('">'."\n".'<img src="', $ExamplesArray['getstrings']).'"></xmp>';
|
||||
echo $ExamplesArray['description'].'<br>';
|
||||
echo '<br><br><hr size="1">';
|
||||
}
|
||||
|
||||
echo '<a href="#" name="pathinfo" title="click to get URL link for PATH_INFO example" onClick="prompt(\'Here is the link to the PATH_INFO example\', \'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'#pathinfo\'); return false;">#pathinfo</a>';
|
||||
echo '<table border="0"><tr><td style="padding: 20px; background-image: url(../'.$img['background'].');">';
|
||||
echo '<img src="../phpThumb.php/fltr[]=sep;200x200;'.$img['portrait'].'">';
|
||||
echo '</td></tr></table>';
|
||||
echo '<xmp><img src="../phpThumb.php/fltr[]=sep;200x200;'.$img['portrait'].'"></xmp>';
|
||||
echo 'PATH_INFO example<br>';
|
||||
echo '<br><br><hr size="1">';
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<a name="gd1vs2"></a><br>
|
||||
<table border="5" cellspacing="0" cellpadding="3" width="500">
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<b>Illustration of potential difference between GD1.x and GD2.x</b><br>
|
||||
In most cases the thumbnails produced by phpThumb() on GD v1.x are perfectly
|
||||
acceptable, but in some cases it may look ugly. Diagonal lines and reducing a
|
||||
very large source image increase chance for bad results (the house/sky picture
|
||||
has both problems). Here are three static examples:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>GD v2.0.15</b></td>
|
||||
<td><img src="../images/PHP-GD2-kayak.jpg" width="200" height="133" border="0" alt="kayak.jpg generated with phpThumb() on GD v2.0.15"></td>
|
||||
<td><img src="../images/PHP-GD2-bottle.jpg" width="100" height="152" border="0" alt="bottle.jpg generated with phpThumb() on GD v2.0.15"></td>
|
||||
<td><img src="../images/PHP-GD2-sky.jpg" width="200" height="150" border="0" alt="sky.jpg generated with phpThumb() on GD v2.0.15"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>GD v1.6.2</b></td>
|
||||
<td><img src="../images/PHP-GD1-kayak.jpg" width="200" height="133" border="0" alt="kayak.jpg generated with phpThumb() on GD v1.6.2"></td>
|
||||
<td><img src="../images/PHP-GD1-bottle.jpg" width="100" height="152" border="0" alt="bottle.jpg generated with phpThumb() on GD v1.6.2"></td>
|
||||
<td><img src="../images/PHP-GD1-sky.jpg" width="200" height="150" border="0" alt="sky.jpg generated with phpThumb() on GD v1.6.2"></td>
|
||||
</tr>
|
||||
</table><br>
|
||||
<hr size="1">
|
||||
<br>
|
||||
<a name="showpic"></a>
|
||||
<b>Demo of <i>phpThumb.demo.showpic.php</i></b><br>
|
||||
<br>
|
||||
Small picture (400x300), window opened at wrong size (640x480):<br>
|
||||
<a href="javascript:void(0);" onClick="window.open('phpThumb.demo.showpic.php?src=../<?php echo $img['small']; ?>&title=This+is+a+small+picture', 'showpic1', 'width=640,height=480,resizable=no,status=no,menubar=no,toolbar=no,scrollbars=no');">
|
||||
<img src="<?php echo $phpThumbBase.'src='.$img['small']; ?>&w=100" border="2"></a><br>
|
||||
<br>
|
||||
Big picture (2272x1704), window opened at wrong size (640x480):<br>
|
||||
<a href="javascript:void(0);" onClick="window.open('phpThumb.demo.showpic.php?src=../<?php echo $img['big']; ?>&title=This+is+a+big+picture', 'showpic2', 'width=640,height=480,resizable=yes,status=no,menubar=no,toolbar=no,scrollbars=no');">
|
||||
<img src="<?php echo $phpThumbBase.'src='.$img['big']; ?>&w=100" border="2"></a><br>
|
||||
<br>
|
||||
<hr size="1">
|
||||
|
||||
<?php
|
||||
|
||||
echo 'The source images, without manipulation:<ul>';
|
||||
foreach ($img as $key => $value) {
|
||||
echo '<li><a href="../'.$value.'">'.basename($value).'</a></li>';
|
||||
}
|
||||
echo '</ul><hr>';
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
72
site/racecalendar/phpthumb/demo/phpThumb.demo.object.php
Normal file
72
site/racecalendar/phpthumb/demo/phpThumb.demo.object.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// //
|
||||
// phpThumb.demo.object.php //
|
||||
// James Heinrich <info@silisoftware.com> //
|
||||
// //
|
||||
// Example of how to use phpthumb.class.php as an object //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// 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.
|
||||
|
||||
|
||||
|
||||
require_once('../phpthumb.class.php');
|
||||
|
||||
// create 3 sizes of thumbnail
|
||||
$thumbnail_widths = array(160, 320, 640);
|
||||
foreach ($thumbnail_widths as $thumbnail_width) {
|
||||
|
||||
// Note: If you want to loop through and create multiple
|
||||
// thumbnails from different image sources, you should
|
||||
// create and dispose an instance of phpThumb() each time
|
||||
// through the loop and not reuse the object.
|
||||
$phpThumb = new phpThumb();
|
||||
|
||||
// set data
|
||||
$phpThumb->setSourceFilename($_FILES['userfile']['tmp_name']);
|
||||
// or $phpThumb->setSourceData($binary_image_data);
|
||||
// or $phpThumb->setSourceImageResource($gd_image_resource);
|
||||
|
||||
// set parameters (see "URL Parameters" in phpthumb.readme.txt)
|
||||
$phpThumb->w = $thumbnail_width;
|
||||
//$phpThumb->h = 100;
|
||||
//$phpThumb->fltr[] = 'gam|1.2';
|
||||
|
||||
// set options (see phpThumb.config.php)
|
||||
// here you must preface each option with "config_"
|
||||
$phpThumb->config_output_format = 'jpeg';
|
||||
$phpThumb->config_imagemagick_path = '/usr/local/bin/convert';
|
||||
//$phpThumb->config_allow_src_above_docroot = true; // needed if you're working outside DOCUMENT_ROOT, in a temp dir for example
|
||||
|
||||
// generate & output thumbnail
|
||||
$output_filename = './thumbnails/'.basename($_FILES['userfile']['name']).'_'.$thumbnail_width.'.'.$phpThumb->config_output_format;
|
||||
if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it!
|
||||
if ($output_filename) {
|
||||
if ($phpThumb->RenderToFile($output_filename)) {
|
||||
// do something on success
|
||||
echo 'Successfully rendered:<br><img src="'.$output_filename.'">';
|
||||
} else {
|
||||
// do something with debug/error messages
|
||||
echo 'Failed (size='.$thumbnail_width.'):<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>';
|
||||
}
|
||||
} else {
|
||||
$phpThumb->OutputThumbnail();
|
||||
}
|
||||
} else {
|
||||
// do something with debug/error messages
|
||||
echo 'Failed (size='.$thumbnail_width.'):<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>';
|
||||
}
|
||||
|
||||
// remember to unset the object each time through the loop
|
||||
unset($phpThumb);
|
||||
}
|
||||
|
||||
?>
|
95
site/racecalendar/phpthumb/demo/phpThumb.demo.random.php
Normal file
95
site/racecalendar/phpthumb/demo/phpThumb.demo.random.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// //
|
||||
// phpThumb.demo.random.php //
|
||||
// James Heinrich <info@silisoftware.com> //
|
||||
// //
|
||||
// Display a random image from a specified directory. //
|
||||
// Run with no parameters for usage instructions. //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
function SelectRandomImage($dirname='.', $portrait=true, $landscape=true, $square=true) {
|
||||
// return a random image filename from $dirname
|
||||
// the last 3 parameters determine what aspect ratio of images
|
||||
// may be returned
|
||||
$possibleimages = array();
|
||||
if ($dh = opendir($dirname)) {
|
||||
while ($file = readdir($dh)) {
|
||||
if (is_file($dirname.'/'.$file) && eregi('\.(jpg|jpeg|gif|png|tiff|bmp)$', $file)) {
|
||||
if ($gis = @GetImageSize($dirname.'/'.$file)) {
|
||||
if ($portrait && ($gis[0] < $gis[1])) {
|
||||
// portrait
|
||||
$possibleimages[] = $file;
|
||||
} elseif ($landscape && ($gis[0] > $gis[1])) {
|
||||
// landscape
|
||||
$possibleimages[] = $file;
|
||||
} elseif ($square) {
|
||||
// square
|
||||
$possibleimages[] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
if (empty($possibleimages)) {
|
||||
return false;
|
||||
}
|
||||
if (phpversion() < '4.2.0') {
|
||||
mt_srand(time());
|
||||
}
|
||||
$randkey = mt_rand(0, count($possibleimages) - 1);
|
||||
return realpath($dirname.'/'.$possibleimages[$randkey]);
|
||||
}
|
||||
|
||||
if (@$_REQUEST['dir']) {
|
||||
if (is_dir($_REQUEST['dir'])) {
|
||||
|
||||
if (!@$_REQUEST['o']) {
|
||||
$_REQUEST['o'] = 'PLS';
|
||||
}
|
||||
$_REQUEST['o'] = strtoupper($_REQUEST['o']);
|
||||
$portrait = (strpos(@$_REQUEST['o'], 'P') !== false);
|
||||
$landscape = (strpos(@$_REQUEST['o'], 'L') !== false);
|
||||
$square = (strpos(@$_REQUEST['o'], 'S') !== false);
|
||||
$randomSRC = SelectRandomImage($_REQUEST['dir'], $portrait, $landscape, $square);
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
$randomSRC = str_replace('\\', '/', eregi_replace('^'.realpath(@$_SERVER['DOCUMENT_ROOT']), '', realpath($randomSRC)));
|
||||
} else {
|
||||
$randomSRC = str_replace(realpath(@$_SERVER['DOCUMENT_ROOT']), '', realpath($randomSRC));
|
||||
}
|
||||
|
||||
$otherParams = array();
|
||||
foreach ($_GET as $key => $value) {
|
||||
if (($key == 'dir') || ($key == 'o')) {
|
||||
continue;
|
||||
}
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $vkey => $vvalue) {
|
||||
$otherParams[] = urlencode($key).'['.urlencode($vkey).']='.urlencode($vvalue);
|
||||
}
|
||||
} else {
|
||||
$otherParams[] = urlencode($key).'='.urlencode($value);
|
||||
}
|
||||
}
|
||||
header('Location: ../phpThumb.php?src='.urlencode($randomSRC).'&'.implode('&', $otherParams));
|
||||
exit;
|
||||
|
||||
} else {
|
||||
die($_REQUEST['dir'].' is not a directory');
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
echo '<html><body>Usage: <b>'.basename($_SERVER['PHP_SELF']).'?dir=<i><directory></i>&<i><phpThumb parameters></i></b>&o=<i>(P|L|S)</i><br><br>Examples:<ul>';
|
||||
echo '<li>'.basename($_SERVER['PHP_SELF']).'?./images/&o=L <i>(landscape images only)</i></li>';
|
||||
echo '<li>'.basename($_SERVER['PHP_SELF']).'?./images/&o=PS <i>(portrait or square images only)</i></li>';
|
||||
echo '</ul></body></html>';
|
||||
|
||||
}
|
||||
|
||||
?>
|
98
site/racecalendar/phpthumb/demo/phpThumb.demo.showpic.php
Normal file
98
site/racecalendar/phpthumb/demo/phpThumb.demo.showpic.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// phpThumb.demo.showpic.php //
|
||||
// James Heinrich <info@silisoftware.com> //
|
||||
// 23 Feb 2004 //
|
||||
// //
|
||||
// This code is useful for popup pictures (e.g. thumbnails //
|
||||
// you want to show larger, such as a larger version of a //
|
||||
// product photo for example) but you don't know the image //
|
||||
// dimensions before popping up. This script displays the //
|
||||
// image with no window border, and resizes the window to //
|
||||
// the size it needs to be (usually better to spawn it //
|
||||
// large (600x400 for example) and let it auto-resize it //
|
||||
// smaller), and if the image is larger than 90% of the //
|
||||
// current screen area the window respawns itself with //
|
||||
// scrollbars. //
|
||||
// //
|
||||
// Usage: //
|
||||
// window.open('showpic.php?src=big.jpg&title=Big+picture', //
|
||||
// 'popupwindowname', //
|
||||
// 'width=600,height=400,menubar=no,toolbar=no') //
|
||||
// //
|
||||
// See demo linked from http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo @$_GET['title']; ?></title>
|
||||
|
||||
<script language="Javascript">
|
||||
<!--
|
||||
// http://www.xs4all.nl/~ppk/js/winprop.html
|
||||
function CrossBrowserResizeInnerWindowTo(newWidth, newHeight) {
|
||||
if (self.innerWidth) {
|
||||
frameWidth = self.innerWidth;
|
||||
frameHeight = self.innerHeight;
|
||||
} else if (document.documentElement && document.documentElement.clientWidth) {
|
||||
frameWidth = document.documentElement.clientWidth;
|
||||
frameHeight = document.documentElement.clientHeight;
|
||||
} else if (document.body) {
|
||||
frameWidth = document.body.clientWidth;
|
||||
frameHeight = document.body.clientHeight;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (document.layers) {
|
||||
newWidth -= (parent.outerWidth - parent.innerWidth);
|
||||
newHeight -= (parent.outerHeight - parent.innerHeight);
|
||||
}
|
||||
// original code
|
||||
//parent.window.resizeTo(newWidth, newHeight);
|
||||
|
||||
// fixed code: James Heinrich, 20 Feb 2004
|
||||
parent.window.resizeBy(newWidth - frameWidth, newHeight - frameHeight);
|
||||
|
||||
return true;
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body style="margin: 0px;">
|
||||
<?php
|
||||
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$_GET['src'] = stripslashes($_GET['src']);
|
||||
}
|
||||
|
||||
if ($imgdata = @getimagesize($_GET['src'])) {
|
||||
|
||||
// this would be an excellent place to put some caching stuff to avoid re-scanning every picture every time
|
||||
|
||||
// check for maximum dimensions to allow no-scrollbar window
|
||||
echo '<script language="Javascript">'."\n";
|
||||
echo 'if (((screen.width * 1.1) > '.$imgdata[0].') || ((screen.height * 1.1) > '.$imgdata[1].')) {'."\n";
|
||||
// screen is large enough to fit whole picture on screen with 10% margin
|
||||
echo 'document.writeln(\'<img src="'.$_GET['src'].'" border="0">\');';
|
||||
echo 'CrossBrowserResizeInnerWindowTo('.$imgdata[0].', '.$imgdata[1].');'."\n";
|
||||
echo '} else {'."\n";
|
||||
// image is too large for screen: add scrollbars by putting the image inside an IFRAME
|
||||
echo 'document.writeln(\'<iframe width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" scrolling="on" src="'.$_GET['src'].'">Your browser does not support the IFRAME tag. Please use one that does (IE, Firefox, etc).<br><img src="'.$_GET['src'].'"></iframe>\');';
|
||||
echo '}'."\n";
|
||||
echo '</script>';
|
||||
|
||||
} else {
|
||||
|
||||
// cannot determine correct window size, or correct size too large: add scrollbars by putting the image inside an IFRAME
|
||||
echo '<iframe width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" scrolling="on" src="'.$_GET['src'].'"></iframe>';
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
41
site/racecalendar/phpthumb/demo/readme.demos.txt
Normal file
41
site/racecalendar/phpthumb/demo/readme.demos.txt
Normal file
@ -0,0 +1,41 @@
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// //
|
||||
// phpThumb() included and related demos //
|
||||
// ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
The phpThumb() distribution includes several demos, and it
|
||||
should be self-evident what they do when you run them:
|
||||
|
||||
* phpThumb.demo.demo.php - shows a wide variety of samples,
|
||||
basically all the different features and filters of phpThumb.
|
||||
Note: sample image files are not included in the distribution
|
||||
but can be downloaded from http://phpthumb.sourceforge.net/demo
|
||||
|
||||
* phpThumb.demo.check.php - configuration checker, will check
|
||||
your config file and server configuration and warn of any
|
||||
potential problems
|
||||
|
||||
* phpThumb.demo.object.php - example of how to call phpThumb
|
||||
as an object.
|
||||
|
||||
* phpThumb.demo.random.php - select & display a random thumbnail
|
||||
from a directory of images.
|
||||
|
||||
* phpThumb.demo.showpic.php - auto-resizes a popup window to
|
||||
match the dimensions of the image it is displaying
|
||||
|
||||
|
||||
|
||||
Other people have created useful demos and/or extensions to
|
||||
phpThumb(). Some of these I know of are:
|
||||
|
||||
* iManager - http://www.j-cons.com/news/
|
||||
* iBrowser - http://www.j-cons.com/news/
|
||||
* ThumbnailSelector - http://www.silisoftware.com/scripts/ThumbnailSelector
|
||||
|
||||
If you know of any others you think should be mentioned here
|
||||
please let me know: info@silisoftware.com
|
1040
site/racecalendar/phpthumb/docs/phpthumb.changelog.txt
Normal file
1040
site/racecalendar/phpthumb/docs/phpthumb.changelog.txt
Normal file
File diff suppressed because it is too large
Load Diff
203
site/racecalendar/phpthumb/docs/phpthumb.faq.txt
Normal file
203
site/racecalendar/phpthumb/docs/phpthumb.faq.txt
Normal file
@ -0,0 +1,203 @@
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// //
|
||||
// Frequently Asked Questions (FAQ) about phpThumb() //
|
||||
// ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Q: My question isn't answered here and I can't find any
|
||||
forums, how do I get support?
|
||||
A: Please email me directly at info@silisoftware.com with
|
||||
any questions, suggestions, donations, etc.
|
||||
|
||||
|
||||
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 <img src="phpThumb.php?src=pic.jpg&w=100"> 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: I'm getting is this error message:
|
||||
Failed: RenderToFile(<filename>) 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 "<filename> does not exist" when I know the
|
||||
file does exist
|
||||
A: Check 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 then you will have
|
||||
to configure 'allow_src_above_docroot' to true.
|
||||
|
||||
|
||||
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: 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
|
||||
|
||||
|
||||
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 may not exist in future versions of phpThumb().
|
||||
|
||||
|
||||
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']
|
||||
(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 <img> 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: 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).
|
340
site/racecalendar/phpthumb/docs/phpthumb.license.txt
Normal file
340
site/racecalendar/phpthumb/docs/phpthumb.license.txt
Normal file
@ -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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.
|
||||
|
||||
<signature of Ty Coon>, 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.
|
527
site/racecalendar/phpthumb/docs/phpthumb.readme.txt
Normal file
527
site/racecalendar/phpthumb/docs/phpthumb.readme.txt
Normal file
@ -0,0 +1,527 @@
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// //
|
||||
// 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. Donations also gratefully | //
|
||||
// | GPL FAQ: http://gnu.org/licenses/gpl-faq.html | //
|
||||
// | | //
|
||||
// | Donations are gratefully accepted from happy | //
|
||||
// | users :) See http://phpthumb.sourceforge.net | //
|
||||
// | | //
|
||||
// | If you like phpThumb(), please consider | //
|
||||
// | writing a review at HotScripts.com: | //
|
||||
// | http://www.hotscripts.com/Detailed/25654.html | //
|
||||
// | | //
|
||||
// | If you do use this code somewhere, send me | //
|
||||
// | an email and tell me how/where you used it. | //
|
||||
// +-----------------------------------------------+ //
|
||||
// ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
============
|
||||
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.
|
||||
|
||||
|
||||
======
|
||||
Usage:
|
||||
======
|
||||
|
||||
Call phpThumb() just like you would a normal image.
|
||||
Examples:
|
||||
<IMG SRC="phpThumb.php?src=/image.jpg&w=100">
|
||||
<IMG SRC="phpThumb.php?src=http://example.com/foo.jpg">
|
||||
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/<params>=<values>;<w>x<h>;<image>
|
||||
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
|
||||
|
||||
<image> 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 (";")
|
||||
|
||||
|
||||
==============
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
|
||||
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. I do not currently have a reliable
|
||||
formula for calculating such things, but I will attempt
|
||||
to craft one for future versions of phpThumb(). Until
|
||||
then, set "max_source_pixels" in phpThumb.config.php to a
|
||||
value that works well for you (or leave it alone if the
|
||||
defaults give you no problems).
|
||||
|
||||
The configuration options you should maybe modify are:
|
||||
* cache_directory - thumbnailing is slow and processor-
|
||||
intensive. Enabling caching will dramatically speed
|
||||
up future thumbnail serving
|
||||
* 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.
|
||||
* imagemagick_path - If the source image is larger than
|
||||
max_source_pixels allows, but ImageMagick is available
|
||||
phpThumb() will use it to generate the thumbnail.
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
Note: High-Security mode is recommended enabled if possible.
|
||||
Set $PHPTHUMB_CONFIG['high_security_enabled'] in
|
||||
phpThumb.config.php to enable it. Each call to phpThumb
|
||||
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 '<img src="'.phpThumbURL('src=pic.jpg&w=50').'">';
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
==============================================
|
||||
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.
|
||||
|
||||
|
||||
===============
|
||||
URL 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"). Set "zc=1" to enable.
|
||||
(overrides both "iar" and "far")
|
||||
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|<value>]
|
||||
where <value> is the amount +/- to adjust brightness
|
||||
(range -255 to 255)
|
||||
Availble in PHP5 with bundled GD only.
|
||||
- "cont" (Constrast) [ex: &fltr[]=cont|<value>]
|
||||
where <value> is the amount +/- to adjust contrast
|
||||
(range -255 to 255)
|
||||
Availble in PHP5 with bundled GD only.
|
||||
- "gam" (Gamma Correction) [ex: &fltr[]=gam|<value>]
|
||||
where <value> can be a number >0 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|<value>]
|
||||
where <value> 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|<value>]
|
||||
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|<value>]
|
||||
makes image greyscale, then sets all pixels brighter
|
||||
than <value> (range 0-255) to white, and all pixels
|
||||
darker than <value> to black
|
||||
- "rcd" (Reduce Color Depth) [ex: &fltr[]=rcd|<c>|<d>]
|
||||
where <c> is the number of colors (2-256) you want
|
||||
in the output image, and <d> is "1" for dithering
|
||||
(deault) or "0" for no dithering
|
||||
- "clr" (Colorize) [ex: &fltr[]=clr|<value>|<color>]
|
||||
where <value> is a number between 0 and 100 for the
|
||||
amount of colorization, and <color> is the hex color
|
||||
to colorize to.
|
||||
- "sep" (Sepia) [ex: &fltr[]=sep|<value>|<color>]
|
||||
where <value> is a number between 0 and 100 for the
|
||||
amount of colorization (default=50), and <color> 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|<a>|<r>|<t>]
|
||||
where <a> is the amount (default = 80), <r> is the
|
||||
radius (default = 0.5), <t> is the threshold
|
||||
(default = 3).
|
||||
- "blur" (Blur) [ex: &fltr[]=blur|<radius>]
|
||||
where (0 < <radius> < 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|<value>]
|
||||
where <value> 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|<channel>|<min>|<max>
|
||||
where <channel> can be one of 'r', 'g', 'b', 'a' (for
|
||||
Red, Green, Blue, Alpha respectively), or '*' for all
|
||||
channels based on average grayscale value (default).
|
||||
<min> and <max> are the clip points for the levels
|
||||
and are set to clip 0.1% of each end by default.
|
||||
(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.
|
||||
- "wb" (White Balance) [ex: &fltr[]=wb|<c>]
|
||||
where <c> 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 <c> is
|
||||
omitted the filter guesses based on brightest pixels
|
||||
in each of RGB
|
||||
- "hist" (Histogram)
|
||||
[ex: &fltr[]=hist|<b>|<c>|<w>|<h>|<a>|<o>|<m>]
|
||||
Where <b> is the color band(s) to display, from back
|
||||
to front (one or more of "rgba*" for Red Green Blue
|
||||
Alpha and Grayscale respectively);
|
||||
<c> is a semicolon-seperated list of hex colors to
|
||||
use for each graph band (defaults to FF0000, 00FF00,
|
||||
0000FF, 999999, FFFFFF respectively);
|
||||
<w> and <h> are the width and height of the overlaid
|
||||
histogram in pixels, or if <= 1 then percentage of
|
||||
source image width/height;
|
||||
<a> is the alignment (same as for "wmi" and "wmt");
|
||||
<o> is opacity from 0 (transparent) to 100 (opaque)
|
||||
(requires PHP v4.3.2, otherwise 100% opaque);
|
||||
<m> 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|<i>|<u>|<m>|<o>]
|
||||
where <i> is the image filename; <u> is "0" (default)
|
||||
for overlay the image on top of the thumbnail or "1"
|
||||
for overlay the thumbnail on top of the image; <m> 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);
|
||||
<o> is opacity (0 = transparent, 100 = opaque)
|
||||
(requires PHP v4.3.2, otherwise 100% opaque);
|
||||
(thanks raynerape<70>gmail*com, shabazz3<7A>msu*edu)
|
||||
- "wmi" (WaterMarkImage)
|
||||
[ex: &fltr[]=wmi|<f>|<a>|<o>|<m>] where
|
||||
<f> is the filename of the image to overlay;
|
||||
<a> 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);
|
||||
<o> is opacity from 0 (transparent) to 100 (opaque)
|
||||
(requires PHP v4.3.2, otherwise 100% opaque);
|
||||
<m> is the edge (and inter-tile) margin in percent
|
||||
- "wmt" (WaterMarkText)
|
||||
[ex: &fltr[]=wmt|<t>|<s>|<a>|<c>|<f>|<o>|<m>|<n>|<b>|<O>|<x>]
|
||||
where:
|
||||
<t> is the text to use as a watermark;
|
||||
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 ^
|
||||
<s> is the font size (1-5 for built-in font, or point
|
||||
size for TrueType fonts);
|
||||
<a> 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);
|
||||
<c> is the hex color of the text;
|
||||
<f> is the filename of the TTF file (optional, if
|
||||
omitted a built-in font will be used);
|
||||
<o> is opacity from 0 (transparent) to 100 (opaque)
|
||||
(requires PHP v4.3.2, otherwise 100% opaque);
|
||||
<m> is the edge (and inter-tile) margin in percent;
|
||||
<n> is the angle
|
||||
<b> is the hex color of the background;
|
||||
<O> is background opacity from 0 (transparent) to
|
||||
100 (opaque)
|
||||
(requires PHP v4.3.2, otherwise 100% opaque);
|
||||
<x> 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
|
||||
(thanks mail<69>mmjaeger*com, craig<69>pc-fanatics*com)
|
||||
- "flip" [ex: &fltr[]=flip|x or &fltr[]=flip|y]
|
||||
flip image on X or Y axis
|
||||
- "ric" [ex: &fltr[]=ric|<x>|<y>]
|
||||
rounds off the corners of the image (to transparent
|
||||
for PNG output), where <x> is the horizontal radius
|
||||
of the curve and <y> 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.
|
||||
- "bvl" (BeVeL) [ex: &fltr[]=bvl|<w>|<c1>|<c2>]
|
||||
where <w> is the bevel width, <c1> is the hex color
|
||||
for the top and left shading, <c2> is the hex color
|
||||
for the bottom and right shading
|
||||
- "bord" (BORDer) [ex: &fltr[]=bord|<w>|<rx>|<ry>|<c>
|
||||
where <w> is the width in pixels, <rx> and <ry> are
|
||||
horizontal and vertical radii for rounded corners,
|
||||
and <c> is the hex color of the border
|
||||
- "fram" (FRAMe) draws a frame, similar to "bord" but
|
||||
more configurable
|
||||
[ex: &fltr[]=fram|<w1>|<w2>|<c1>|<c2>|<c3>]
|
||||
where <w1> is the width of the main border, <w2> is
|
||||
the width of each side of the bevel part, <c1> is the
|
||||
hex color of the main border, <c2> is the highlight
|
||||
bevel color, <c3> is the shadow bevel color
|
||||
- "drop" (DROP shadow)
|
||||
[ex: &fltr[]=drop|<d>|<w>|<clr>|<a>]
|
||||
where <d> is distance from image to shadow, <w> is
|
||||
width of shadow fade (not yet implemented), <clr> is
|
||||
the hex color of the shadow, and <a> is the angle of
|
||||
the shadow (default=225)
|
||||
file = if set then thumbnail will be rendered to this
|
||||
filename, not output and not cached.
|
||||
(Deprecated. Disabled by default since v1.6.0.
|
||||
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.
|
||||
You should instantiate your own object instead)
|
||||
err = custom error image filename instead of showing
|
||||
error messages (for use on production sites)
|
||||
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.
|
||||
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.
|
||||
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
|
||||
|
||||
|
||||
|
||||
==============
|
||||
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
|
||||
unavailble, 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
|
||||
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;
|
||||
* 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;wb;hist;fram;drop;mask;elip;ric;bord;
|
5
site/racecalendar/phpthumb/fonts/readme.txt
Normal file
5
site/racecalendar/phpthumb/fonts/readme.txt
Normal file
@ -0,0 +1,5 @@
|
||||
This is the default location for TTF fonts.
|
||||
|
||||
You can safely delete or ignore this directory if you're not using
|
||||
TTF fonts for text watermarks. You can also specify an alternate
|
||||
directory in phpThumb.config.php
|
3
site/racecalendar/phpthumb/index.php
Normal file
3
site/racecalendar/phpthumb/index.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
header('Location: demo/phpThumb.demo.demo1.php');
|
||||
?>
|
BIN
site/racecalendar/phpthumb/lee.jpg
Normal file
BIN
site/racecalendar/phpthumb/lee.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 86 KiB |
241
site/racecalendar/phpthumb/phpThumb.config.php
Normal file
241
site/racecalendar/phpthumb/phpThumb.config.php
Normal file
@ -0,0 +1,241 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// //
|
||||
// See: phpthumb.readme.txt for usage instructions //
|
||||
// ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
ob_start();
|
||||
if (!file_exists(dirname(__FILE__).'/phpthumb.functions.php') || !include_once(dirname(__FILE__).'/phpthumb.functions.php')) {
|
||||
ob_end_flush();
|
||||
die('failed to include_once(phpthumb.functions.php) - realpath="'.realpath(dirname(__FILE__).'/phpthumb.functions.php').'"');
|
||||
}
|
||||
ob_end_clean();
|
||||
|
||||
// START USER CONFIGURATION SECTION:
|
||||
|
||||
// * DocumentRoot configuration
|
||||
// phpThumb() depends on $_SERVER['DOCUMENT_ROOT'] to resolve path/filenames. This value is usually correct,
|
||||
// but has been known to be broken on some servers. This value allows you to override the default value.
|
||||
// Do not modify from the auto-detect default value unless you are having problems.
|
||||
//$PHPTHUMB_CONFIG['document_root'] = '/home/httpd/httpdocs';
|
||||
//$PHPTHUMB_CONFIG['document_root'] = 'c:\\webroot\\example.com\\www';
|
||||
//$PHPTHUMB_CONFIG['document_root'] = $_SERVER['DOCUMENT_ROOT'];
|
||||
//$PHPTHUMB_CONFIG['document_root'] = realpath((@$_SERVER['DOCUMENT_ROOT'] && file_exists(@$_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'])) ? $_SERVER['DOCUMENT_ROOT'] : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace(DIRECTORY_SEPARATOR, '/', realpath('.'))));
|
||||
$PHPTHUMB_CONFIG['document_root'] = realpath((getenv('DOCUMENT_ROOT') && ereg('^'.preg_quote(realpath(getenv('DOCUMENT_ROOT'))), realpath(__FILE__))) ? getenv('DOCUMENT_ROOT') : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__))));
|
||||
|
||||
// * Cache directory configuration (choose only one of these - leave the other lines commented-out):
|
||||
// Note: this directory must be writable (usually chmod 777 is neccesary) for caching to work.
|
||||
// If the directory is not writable no error will be generated but caching will be disabled.
|
||||
$PHPTHUMB_CONFIG['cache_directory'] = dirname(__FILE__).'/cache/'; // set the cache directory relative to the phpThumb() installation
|
||||
//$PHPTHUMB_CONFIG['cache_directory'] = $PHPTHUMB_CONFIG['document_root'].'/phpthumb/cache/'; // set the cache directory to an absolute directory for all source images
|
||||
//$PHPTHUMB_CONFIG['cache_directory'] = './cache/'; // set the cache directory relative to the source image - must start with '.' (will not work to cache URL- or database-sourced images, please use an absolute directory name)
|
||||
//$PHPTHUMB_CONFIG['cache_directory'] = null; // disable thumbnail caching (not recommended)
|
||||
|
||||
$PHPTHUMB_CONFIG['cache_disable_warning'] = false; // If [cache_directory] is non-existant or not writable, and [cache_disable_warning] is false, an error image will be generated warning to either set the cache directory or disable the warning (to avoid people not knowing about the cache)
|
||||
|
||||
|
||||
// * Cache culling: phpThumb can automatically limit the contents of the cache directory
|
||||
// based on last-access date and/or number of files and/or total filesize.
|
||||
|
||||
//$PHPTHUMB_CONFIG['cache_maxage'] = null; // never delete cached thumbnails based on last-access time
|
||||
$PHPTHUMB_CONFIG['cache_maxage'] = 86400 * 30; // delete cached thumbnails that haven't been accessed in more than [30 days] (value is maximum time since last access in seconds to avoid deletion)
|
||||
|
||||
//$PHPTHUMB_CONFIG['cache_maxsize'] = null; // never delete cached thumbnails based on byte size of cache directory
|
||||
$PHPTHUMB_CONFIG['cache_maxsize'] = 10 * 1024 * 1024; // delete least-recently-accessed cached thumbnails when more than [10MB] of cached files are present (value is maximum bytesize of all cached files)
|
||||
|
||||
//$PHPTHUMB_CONFIG['cache_maxfiles'] = null; // never delete cached thumbnails based on number of cached files
|
||||
$PHPTHUMB_CONFIG['cache_maxfiles'] = 200; // delete least-recently-accessed cached thumbnails when more than [500] cached files are present (value is maximum number of cached files to keep)
|
||||
|
||||
|
||||
// * Source image cache configuration
|
||||
$PHPTHUMB_CONFIG['cache_source_enabled'] = false; // if true, source images obtained via HTTP are cached to $PHPTHUMB_CONFIG['cache_source_directory']
|
||||
$PHPTHUMB_CONFIG['cache_source_directory'] = dirname(__FILE__).'/cache/source/'; // set the cache directory for unprocessed source images
|
||||
|
||||
// * cache source modification date configuration
|
||||
$PHPTHUMB_CONFIG['cache_source_filemtime_ignore_local'] = false; // if true, local 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
|
||||
$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. WARNING: cached performance MUCH slower if this is set to false.
|
||||
|
||||
|
||||
// * Simplified cache filename configuration
|
||||
// Instead of creating unique cache filenames for all parameter combinations, create "simple" cache files (eg: "pic_thumb.jpg")
|
||||
// If cache_default_only_suffix is non-empty, GETstring parameters (except 'src') are ignored and only $PHPTHUMB_DEFAULTS
|
||||
// parameters (set at the bottom of phpThumb.config.php) are used for processing.
|
||||
// The '*' character MUST be used to represent the source image name
|
||||
$PHPTHUMB_CONFIG['cache_default_only_suffix'] = ''; // cached in normal phpThumb manner
|
||||
//$PHPTHUMB_CONFIG['cache_default_only_suffix'] = '*_thumb'; // cache 'pic.jpg' becomes 'pic_thumb.jpg' (or 'pic_thumb.png' if PNG output is selected, etc)
|
||||
//$PHPTHUMB_CONFIG['cache_default_only_suffix'] = 'small-*'; // cache 'pic.jpg' becomes 'small-pic.jpg' (or 'small-pic.png' if PNG output is selected, etc)
|
||||
|
||||
$PHPTHUMB_CONFIG['cache_prefix'] = 'phpThumb_cache_'.str_replace('www.', '', @$_SERVER['SERVER_NAME']);
|
||||
//$PHPTHUMB_CONFIG['cache_prefix'] = 'phpThumb_cache'; // allow phpThumb to share 1 set of cached files even if accessed under different servername/domains on same server
|
||||
|
||||
$PHPTHUMB_CONFIG['cache_force_passthru'] = true; // if true, cached image data will always be passed to browser; if false, HTTP redirect will be used instead
|
||||
|
||||
|
||||
|
||||
// * Temp directory configuration
|
||||
// phpThumb() may need to create temp files. Usually the system temp dir is writable and can be used.
|
||||
// Leave this value as NULL in most cases. If you get errors about "failed to open <filename> for writing"
|
||||
// you should change this to a full pathname to a directory you do have write access to.
|
||||
//$PHPTHUMB_CONFIG['temp_directory'] = '/tmp/';
|
||||
$PHPTHUMB_CONFIG['temp_directory'] = null;
|
||||
|
||||
|
||||
// maximum number of pixels in source image to attempt to process entire image.
|
||||
// If this is zero then no limit on source image dimensions.
|
||||
// If this is nonzero then this is the maximum number of pixels the source image
|
||||
// can have to be processed normally, otherwise the embedded EXIF thumbnail will
|
||||
// be used (if available) or an "image too large" notice will be displayed.
|
||||
// This is to be used for large source images (> 1600x1200) and low PHP memory
|
||||
// limits. If PHP runs out of memory the script will usually just die with no output.
|
||||
// To calculate this number, multiply the dimensions of the largest image
|
||||
// you can process with your memory limitation (e.g. 1600 * 1200 = 1920000)
|
||||
// As a general guideline, this number will be about 20% of your PHP memory
|
||||
// configuration, so 8M = 1,677,722; 16M = 3,355,443; 32M = 6,710,886; etc.
|
||||
if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=') && !defined('memory_get_usage') && !@ini_get('memory_limit')) {
|
||||
// memory_get_usage() will only be defined if your PHP is compiled with the --enable-memory-limit configuration option.
|
||||
$PHPTHUMB_CONFIG['max_source_pixels'] = 0; // no memory limit
|
||||
} else {
|
||||
// calculate default max_source_pixels as 20% of memory limit configuration
|
||||
$PHPTHUMB_CONFIG['max_source_pixels'] = round(max(intval(ini_get('memory_limit')), intval(get_cfg_var('memory_limit'))) * 1048576 * 0.20);
|
||||
//$PHPTHUMB_CONFIG['max_source_pixels'] = 0; // no memory limit
|
||||
//$PHPTHUMB_CONFIG['max_source_pixels'] = 1920000; // allow 1600x1200 images (2Mpx), no larger (about 10MB memory required)
|
||||
//$PHPTHUMB_CONFIG['max_source_pixels'] = 3355443; // 16MB memory limit
|
||||
//$PHPTHUMB_CONFIG['max_source_pixels'] = 3871488; // allow 2272x1704 images (4Mpx), no larger (about 16MB memory required)
|
||||
}
|
||||
|
||||
|
||||
// ImageMagick configuration
|
||||
// If source image is larger than available memory limits as defined above in
|
||||
// 'max_source_pixels' AND ImageMagick's "convert" program is available, phpThumb()
|
||||
// will call ImageMagick to perform the thumbnailing of the source image to bypass
|
||||
// the memory limitation. Leaving the value as NULL will cause phpThumb() to
|
||||
// attempt to detect ImageMagick's presence with `which`
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
// Windows: set absolute pathname
|
||||
$PHPTHUMB_CONFIG['imagemagick_path'] = 'C:/Program Files/ImageMagick-6.2.5-Q16/convert.exe';
|
||||
} else {
|
||||
// *nix: set absolute pathname to "convert", or leave as null if "convert" is in the path
|
||||
//$PHPTHUMB_CONFIG['imagemagick_path'] = '/usr/local/bin/convert';
|
||||
$PHPTHUMB_CONFIG['imagemagick_path'] = null;
|
||||
}
|
||||
|
||||
|
||||
// * Default output configuration:
|
||||
$PHPTHUMB_CONFIG['output_format'] = 'jpeg'; // default output format ('jpeg', 'png' or 'gif') - thumbnail will be output in this format (if available in your version of GD). This is always overridden by ?f=___ GETstring parameter
|
||||
$PHPTHUMB_CONFIG['output_maxwidth'] = 0; // default maximum thumbnail width. If this is zero then default width is the width of the source image. This is always overridden by ?w=___ GETstring parameter
|
||||
$PHPTHUMB_CONFIG['output_maxheight'] = 0; // default maximum thumbnail height. If this is zero then default height is the height of the source image. This is always overridden by ?h=___ GETstring parameter
|
||||
$PHPTHUMB_CONFIG['output_interlace'] = true; // if true: interlaced output for GIF/PNG, progressive output for JPEG; if false: non-interlaced for GIF/PNG, baseline for JPEG.
|
||||
|
||||
// * Error message configuration
|
||||
$PHPTHUMB_CONFIG['error_image_width'] = 400; // default width for error images
|
||||
$PHPTHUMB_CONFIG['error_image_height'] = 100; // default height for error images
|
||||
$PHPTHUMB_CONFIG['error_message_image_default'] = ''; // Set this to the name of a generic error image (e.g. '/images/error.png') that you want displayed in place of any error message that may occur. This setting is overridden by the 'err' parameter, which does the same thing.
|
||||
$PHPTHUMB_CONFIG['error_bgcolor'] = 'CCCCFF'; // background color of error message images
|
||||
$PHPTHUMB_CONFIG['error_textcolor'] = 'FF0000'; // color of text in error messages
|
||||
$PHPTHUMB_CONFIG['error_fontsize'] = 1; // size of text in error messages, from 1 (smallest) to 5 (largest)
|
||||
$PHPTHUMB_CONFIG['error_die_on_error'] = true; // die with error message on any fatal error (recommended with standalone phpThumb.php)
|
||||
$PHPTHUMB_CONFIG['error_silent_die_on_error'] = false; // simply die with no output of any kind on fatal errors (not recommended)
|
||||
$PHPTHUMB_CONFIG['error_die_on_source_failure'] = true; // die with error message if source image cannot be processed by phpThumb() (usually because source image is corrupt in some way). If false the source image will be passed through unprocessed, if true (default) an error message will be displayed.
|
||||
|
||||
// * Off-server Thumbnailing Configuration:
|
||||
$PHPTHUMB_CONFIG['nohotlink_enabled'] = true; // If false will allow thumbnailing from any source domain
|
||||
$PHPTHUMB_CONFIG['nohotlink_valid_domains'] = array(@$_SERVER['HTTP_HOST']); // This is the list of domains for which thumbnails are allowed to be created. The default value of the current domain should be fine in most cases, but if neccesary you can add more domains in here, in the format 'www.example.com'
|
||||
$PHPTHUMB_CONFIG['nohotlink_erase_image'] = true; // if true thumbnail is covered up with $PHPTHUMB_CONFIG['nohotlink_fill_color'] before text is applied, if false text is written over top of thumbnail
|
||||
$PHPTHUMB_CONFIG['nohotlink_text_message'] = 'Off-server thumbnailing is not allowed'; // text of error message
|
||||
|
||||
// * Off-server Linking Configuration:
|
||||
$PHPTHUMB_CONFIG['nooffsitelink_enabled'] = true; // If false will allow thumbnails to be linked to from any domain, if true only domains listed below in 'nooffsitelink_valid_domains' will be allowed.
|
||||
$PHPTHUMB_CONFIG['nooffsitelink_valid_domains'] = array(@$_SERVER['HTTP_HOST']); // This is the list of domains for which thumbnails are allowed to be created. The default value of the current domain should be fine in most cases, but if neccesary you can add more domains in here, in the format 'www.example.com'
|
||||
$PHPTHUMB_CONFIG['nooffsitelink_require_refer'] = false; // If false will allow standalone calls to phpThumb(). If true then only requests with a $_SERVER['HTTP_REFERER'] value in 'nooffsitelink_valid_domains' are allowed.
|
||||
$PHPTHUMB_CONFIG['nooffsitelink_erase_image'] = true; // if true thumbnail is covered up with $PHPTHUMB_CONFIG['nohotlink_fill_color'] before text is applied, if false text is written over top of thumbnail
|
||||
$PHPTHUMB_CONFIG['nooffsitelink_text_message'] = 'Image taken from '.@$_SERVER['HTTP_HOST']; // text of error message
|
||||
|
||||
|
||||
// * Border & Background default colors
|
||||
$PHPTHUMB_CONFIG['border_hexcolor'] = '000000'; // Default border color - usual HTML-style hex color notation (overidden with 'bc' parameter)
|
||||
$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__).'/fonts'; // Base directory for TTF font files
|
||||
//$PHPTHUMB_CONFIG['ttf_directory'] = 'c:/windows/fonts';
|
||||
|
||||
|
||||
// * MySQL configuration
|
||||
// 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
|
||||
// see http://www.billy-corgan.com/blog/archive/000143.php for a brief tutorial on this section
|
||||
|
||||
$PHPTHUMB_CONFIG['mysql_query'] = '';
|
||||
//$PHPTHUMB_CONFIG['mysql_query'] = 'SELECT `picture` FROM `products` WHERE (`id` = \''.mysql_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';
|
||||
$PHPTHUMB_CONFIG['mysql_username'] = '';
|
||||
$PHPTHUMB_CONFIG['mysql_password'] = '';
|
||||
$PHPTHUMB_CONFIG['mysql_database'] = '';
|
||||
|
||||
|
||||
// * Security configuration
|
||||
$PHPTHUMB_CONFIG['high_security_enabled'] = false; // if enabled, requires 'high_security_password' set to at least 5 characters, 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, must be at least 5 characters long
|
||||
$PHPTHUMB_CONFIG['disable_debug'] = false; // prevent phpThumb from displaying any information about your system. If true, phpThumbDebug and error messages will be disabled
|
||||
$PHPTHUMB_CONFIG['allow_src_above_docroot'] = false; // if true, allow src to be anywhere in filesystem; if false (default) only allow src within document_root
|
||||
$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['allow_parameter_file'] = false; // if true, allow use of 'file' parameter; if false (default) the 'file' parameter is disabled/ignored
|
||||
$PHPTHUMB_CONFIG['allow_parameter_goto'] = false; // if true, allow use of 'goto' parameter; if false (default) the 'goto' parameter is disabled/ignored
|
||||
|
||||
|
||||
// * HTTP UserAgent configuration
|
||||
//$PHPTHUMB_CONFIG['http_user_agent'] = ''; // PHP default: none
|
||||
//$PHPTHUMB_CONFIG['http_user_agent'] = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'; // Windows XP, Internet Explorer
|
||||
$PHPTHUMB_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'; // Windows XP, Firefox
|
||||
|
||||
|
||||
// * Compatability settings
|
||||
$PHPTHUMB_CONFIG['disable_pathinfo_parsing'] = false; // 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
|
||||
|
||||
|
||||
// * Speed optimizations configuration
|
||||
$PHPTHUMB_CONFIG['prefer_imagemagick'] = true; // If true, use ImageMagick to resize thumbnails if possible, since it is usually faster than GD functions; if false only use ImageMagick if PHP memory limit is too low.
|
||||
$PHPTHUMB_CONFIG['use_exif_thumbnail_for_speed'] = false; // If true, and EXIF thumbnail is available, and is larger or equal to output image dimensions, use EXIF thumbnail rather than actual source image for generating thumbnail. Benefit is only speed, avoiding resizing large image.
|
||||
|
||||
// END USER CONFIGURATION SECTION
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// START DEFAULT PARAMETERS SECTION
|
||||
// If any parameters are constant across ALL images, you can set them here
|
||||
|
||||
$PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE = true; // if true, any parameters in the URL will override the defaults set here; if false, any parameters set here cannot be overridden in the URL
|
||||
$PHPTHUMB_DEFAULTS_DISABLEGETPARAMS = false; // if true, GETstring parameters will be ignored (except for 'src') and only below default parameters will be used; if false, both default and GETstring parameters will be used (depending on $PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE). Will be auto-set true if !empty($PHPTHUMB_CONFIG['cache_default_only_suffix'])
|
||||
|
||||
//$PHPTHUMB_DEFAULTS['w'] = 100;
|
||||
//$PHPTHUMB_DEFAULTS['fltr'] = array('blur|10');
|
||||
//$PHPTHUMB_DEFAULTS['q'] = 90;
|
||||
|
||||
|
||||
// END DEFAULT PARAMETERS SECTION
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Function for generating hashed calls to phpThumb if 'high_security_enabled'
|
||||
// example:
|
||||
// require_once('phpThumb.config.php');
|
||||
// echo '<img src="'.phpThumbURL('src=pic.jpg&w=50').'">';
|
||||
|
||||
function phpThumbURL($ParameterString) {
|
||||
global $PHPTHUMB_CONFIG;
|
||||
return 'phpThumb.php?'.$ParameterString.'&hash='.md5($ParameterString.@$PHPTHUMB_CONFIG['high_security_password']);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
?>
|
585
site/racecalendar/phpthumb/phpThumb.php
Normal file
585
site/racecalendar/phpthumb/phpThumb.php
Normal file
@ -0,0 +1,585 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// //
|
||||
// See: phpthumb.changelog.txt for recent changes //
|
||||
// See: phpthumb.readme.txt for usage instructions //
|
||||
// ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
if (!@ini_get('safe_mode')) {
|
||||
set_time_limit(60); // shouldn't take nearly this long in most cases, but with many filter and/or a slow server...
|
||||
}
|
||||
ini_set('magic_quotes_runtime', '0');
|
||||
if (@ini_get('magic_quotes_runtime')) {
|
||||
die('"magic_quotes_runtime" is set in php.ini, cannot run phpThumb with this enabled');
|
||||
}
|
||||
$starttime = array_sum(explode(' ', microtime()));
|
||||
|
||||
// this script relies on the superglobal arrays, fake it here for old PHP versions
|
||||
if (phpversion() < '4.1.0') {
|
||||
$_SERVER = $HTTP_SERVER_VARS;
|
||||
$_GET = $HTTP_GET_VARS;
|
||||
}
|
||||
|
||||
// instantiate a new phpThumb() object
|
||||
ob_start();
|
||||
if (!include_once(dirname(__FILE__).'/phpthumb.class.php')) {
|
||||
ob_end_flush();
|
||||
die('failed to include_once("'.realpath(dirname(__FILE__).'/phpthumb.class.php').'")');
|
||||
}
|
||||
ob_end_clean();
|
||||
$phpThumb = new phpThumb();
|
||||
$phpThumb->DebugTimingMessage('phpThumb.php start', __FILE__, __LINE__, $starttime);
|
||||
|
||||
// phpThumbDebug[0] used to be here, but may reveal too much
|
||||
// info when high_security_mode should be enabled (not set yet)
|
||||
|
||||
if (file_exists(dirname(__FILE__).'/phpThumb.config.php')) {
|
||||
ob_start();
|
||||
if (include_once(dirname(__FILE__).'/phpThumb.config.php')) {
|
||||
// great
|
||||
} else {
|
||||
ob_end_flush();
|
||||
$phpThumb->ErrorImage('failed to include_once('.dirname(__FILE__).'/phpThumb.config.php) - realpath="'.realpath(dirname(__FILE__).'/phpThumb.config.php').'"');
|
||||
}
|
||||
ob_end_clean();
|
||||
} elseif (file_exists(dirname(__FILE__).'/phpThumb.config.php.default')) {
|
||||
$phpThumb->ErrorImage('Please rename "phpThumb.config.php.default" to "phpThumb.config.php"');
|
||||
} else {
|
||||
$phpThumb->ErrorImage('failed to include_once('.dirname(__FILE__).'/phpThumb.config.php) - realpath="'.realpath(dirname(__FILE__).'/phpThumb.config.php').'"');
|
||||
}
|
||||
|
||||
if (!@$PHPTHUMB_CONFIG['disable_pathinfo_parsing'] && empty($_GET) && !empty($_SERVER['PATH_INFO'])) {
|
||||
$_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', @$_SERVER['PHP_SELF']);
|
||||
|
||||
$args = explode(';', substr($_SERVER['PATH_INFO'], 1));
|
||||
if (!empty($args)) {
|
||||
$_GET['src'] = @$args[count($args) - 1];
|
||||
}
|
||||
if (eregi('^([0-9]*)x?([0-9]*)$', @$args[count($args) - 2], $matches)) {
|
||||
$_GET['w'] = $matches[1];
|
||||
$_GET['h'] = $matches[2];
|
||||
}
|
||||
for ($i = 0; $i < count($args) - 2; $i++) {
|
||||
@list($key, $value) = explode('=', @$args[$i]);
|
||||
if (substr($key, -2) == '[]') {
|
||||
$_GET[substr($key, 0, -2)][] = $value;
|
||||
} else {
|
||||
$_GET[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (@$PHPTHUMB_CONFIG['high_security_enabled']) {
|
||||
if (!@$_GET['hash']) {
|
||||
$phpThumb->ErrorImage('ERROR: missing hash');
|
||||
} elseif (strlen($PHPTHUMB_CONFIG['high_security_password']) < 5) {
|
||||
$phpThumb->ErrorImage('ERROR: strlen($PHPTHUMB_CONFIG[high_security_password]) < 5');
|
||||
} elseif ($_GET['hash'] != md5(str_replace('&hash='.$_GET['hash'], '', $_SERVER['QUERY_STRING']).$PHPTHUMB_CONFIG['high_security_password'])) {
|
||||
$phpThumb->ErrorImage('ERROR: invalid hash');
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Debug output, to try and help me diagnose problems
|
||||
$phpThumb->DebugTimingMessage('phpThumbDebug[0]', __FILE__, __LINE__);
|
||||
if (@$_GET['phpThumbDebug'] == '0') {
|
||||
$phpThumb->phpThumbDebug();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// returned the fixed string if the evil "magic_quotes_gpc" setting is on
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$RequestVarsToStripSlashes = array('src', 'wmf', 'file', 'err', 'goto', 'down');
|
||||
foreach ($RequestVarsToStripSlashes as $dummy => $key) {
|
||||
if (isset($_GET[$key])) {
|
||||
$_GET[$key] = stripslashes($_GET[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!@$_SERVER['PATH_INFO'] && !@$_SERVER['QUERY_STRING']) {
|
||||
|
||||
echo 'phpThumb() v'.$phpThumb->phpthumb_version.'<br><a href="http://phpthumb.sourceforge.net">http://phpthumb.sourceforge.net</a><br><br>ERROR: no parameters specified';
|
||||
unset($phpThumb);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
if (@$_GET['src'] && isset($_GET['md5s']) && empty($_GET['md5s'])) {
|
||||
if (eregi('^(f|ht)tps?://', $_GET['src'])) {
|
||||
if ($rawImageData = phpthumb_functions::SafeURLread($_GET['src'], $error)) {
|
||||
$md5s = md5($rawImageData);
|
||||
}
|
||||
} else {
|
||||
$SourceFilename = $phpThumb->ResolveFilenameToAbsolute($_GET['src']);
|
||||
if (is_readable($SourceFilename)) {
|
||||
$md5s = phpthumb_functions::md5_file_safe($SourceFilename);
|
||||
} else {
|
||||
$phpThumb->ErrorImage('ERROR: "'.$SourceFilename.'" cannot be read');
|
||||
}
|
||||
}
|
||||
if (@$_SERVER['HTTP_REFERER']) {
|
||||
$phpThumb->ErrorImage('&md5s='.$md5s);
|
||||
} else {
|
||||
die('&md5s='.$md5s);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($PHPTHUMB_CONFIG)) {
|
||||
foreach ($PHPTHUMB_CONFIG as $key => $value) {
|
||||
$keyname = 'config_'.$key;
|
||||
$phpThumb->setParameter($keyname, $value);
|
||||
if (!eregi('password', $key)) {
|
||||
$phpThumb->DebugMessage('setParameter('.$keyname.', '.$phpThumb->phpThumbDebugVarDump($value).')', __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$phpThumb->DebugMessage('$PHPTHUMB_CONFIG is empty', __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Debug output, to try and help me diagnose problems
|
||||
$phpThumb->DebugTimingMessage('phpThumbDebug[1]', __FILE__, __LINE__);
|
||||
if (@$_GET['phpThumbDebug'] == '1') {
|
||||
$phpThumb->phpThumbDebug();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
$parsed_url_referer = parse_url(@$_SERVER['HTTP_REFERER']);
|
||||
if ($phpThumb->config_nooffsitelink_require_refer && !in_array(@$parsed_url_referer['host'], $phpThumb->config_nohotlink_valid_domains)) {
|
||||
$phpThumb->ErrorImage('config_nooffsitelink_require_refer enabled and '.(@$parsed_url_referer['host'] ? '"'.$parsed_url_referer['host'].'" is not an allowed referer' : 'no HTTP_REFERER exists'));
|
||||
}
|
||||
$parsed_url_src = parse_url(@$_GET['src']);
|
||||
if ($phpThumb->config_nohotlink_enabled && $phpThumb->config_nohotlink_erase_image && eregi('^(f|ht)tps?://', @$_GET['src']) && !in_array(@$parsed_url_src['host'], $phpThumb->config_nohotlink_valid_domains)) {
|
||||
$phpThumb->ErrorImage($phpThumb->config_nohotlink_text_message);
|
||||
}
|
||||
|
||||
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)) {
|
||||
|
||||
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_close($cid);
|
||||
$phpThumb->ErrorImage('cannot select MySQL database: "'.mysql_error($cid).'"');
|
||||
}
|
||||
} else {
|
||||
$phpThumb->ErrorImage('cannot connect to MySQL server');
|
||||
}
|
||||
unset($_GET['id']);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Debug output, to try and help me diagnose problems
|
||||
$phpThumb->DebugTimingMessage('phpThumbDebug[2]', __FILE__, __LINE__);
|
||||
if (@$_GET['phpThumbDebug'] == '2') {
|
||||
$phpThumb->phpThumbDebug();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
if (@$PHPTHUMB_CONFIG['cache_default_only_suffix'] && (strpos($PHPTHUMB_CONFIG['cache_default_only_suffix'], '*') !== false)) {
|
||||
$PHPTHUMB_DEFAULTS_DISABLEGETPARAMS = true;
|
||||
}
|
||||
$allowedGETparameters = array('src', 'new', 'w', 'h', 'wp', 'hp', 'wl', 'hl', 'ws', 'hs', 'f', 'q', 'sx', 'sy', 'sw', 'sh', 'zc', 'bc', 'bg', 'bgt', 'fltr', 'file', 'goto', 'err', 'xto', 'ra', 'ar', 'aoe', 'far', 'iar', 'maxb', 'down', 'phpThumbDebug', 'hash', 'md5s');
|
||||
foreach ($_GET as $key => $value) {
|
||||
if (@$PHPTHUMB_DEFAULTS_DISABLEGETPARAMS && ($key != 'src')) {
|
||||
// disabled, do not set parameter
|
||||
$phpThumb->DebugMessage('ignoring $_GET['.$key.'] because of $PHPTHUMB_DEFAULTS_DISABLEGETPARAMS', __FILE__, __LINE__);
|
||||
} elseif (in_array($key, $allowedGETparameters)) {
|
||||
$phpThumb->DebugMessage('setParameter('.$key.', '.$phpThumb->phpThumbDebugVarDump($value).')', __FILE__, __LINE__);
|
||||
$phpThumb->setParameter($key, $value);
|
||||
} else {
|
||||
$phpThumb->ErrorImage('Forbidden parameter: '.$key);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($PHPTHUMB_DEFAULTS) && is_array($PHPTHUMB_DEFAULTS)) {
|
||||
$phpThumb->DebugMessage('setting $PHPTHUMB_DEFAULTS['.implode(';', array_keys($PHPTHUMB_DEFAULTS)).']', __FILE__, __LINE__);
|
||||
foreach ($PHPTHUMB_DEFAULTS as $key => $value) {
|
||||
if ($PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE || !isset($_GET[$key])) {
|
||||
$phpThumb->DebugMessage('setParameter('.$key.', '.$phpThumb->phpThumbDebugVarDump($value).')', __FILE__, __LINE__);
|
||||
$phpThumb->setParameter($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Debug output, to try and help me diagnose problems
|
||||
$phpThumb->DebugTimingMessage('phpThumbDebug[3]', __FILE__, __LINE__);
|
||||
if (@$_GET['phpThumbDebug'] == '3') {
|
||||
$phpThumb->phpThumbDebug();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
//if (!@$_GET['phpThumbDebug'] && !$phpThumb->sourceFilename && !function_exists('ImageJPEG') && !function_exists('ImagePNG') && !function_exists('ImageGIF')) {
|
||||
if (!@$_GET['phpThumbDebug'] && !is_file($phpThumb->sourceFilename) && !phpthumb_functions::gd_version()) {
|
||||
if (!headers_sent()) {
|
||||
// base64-encoded error image in GIF format
|
||||
$ERROR_NOGD = 'R0lGODlhIAAgALMAAAAAABQUFCQkJDY2NkZGRldXV2ZmZnJycoaGhpSUlKWlpbe3t8XFxdXV1eTk5P7+/iwAAAAAIAAgAAAE/vDJSau9WILtTAACUinDNijZtAHfCojS4W5H+qxD8xibIDE9h0OwWaRWDIljJSkUJYsN4bihMB8th3IToAKs1VtYM75cyV8sZ8vygtOE5yMKmGbO4jRdICQCjHdlZzwzNW4qZSQmKDaNjhUMBX4BBAlmMywFSRWEmAI6b5gAlhNxokGhooAIK5o/pi9vEw4Lfj4OLTAUpj6IabMtCwlSFw0DCKBoFqwAB04AjI54PyZ+yY3TD0ss2YcVmN/gvpcu4TOyFivWqYJlbAHPpOntvxNAACcmGHjZzAZqzSzcq5fNjxFmAFw9iFRunD1epU6tsIPmFCAJnWYE0FURk7wJDA0MTKpEzoWAAskiAAA7';
|
||||
header('Content-Type: image/gif');
|
||||
echo base64_decode($ERROR_NOGD);
|
||||
} else {
|
||||
echo '*** ERROR: No PHP-GD support available ***';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// check to see if file can be output from source with no processing or caching
|
||||
$CanPassThroughDirectly = true;
|
||||
if ($phpThumb->rawImageData) {
|
||||
// data from SQL, should be fine
|
||||
} elseif (eregi('^(f|ht)tp\://', $phpThumb->src)) {
|
||||
$phpThumb->DebugMessage('$CanPassThroughDirectly=false because eregi("^(f|ht)tp\://", '.$phpThumb->src.')', __FILE__, __LINE__);
|
||||
$CanPassThroughDirectly = false;
|
||||
} elseif (!@is_file($phpThumb->sourceFilename)) {
|
||||
$phpThumb->DebugMessage('$CanPassThroughDirectly=false because !@is_file('.$phpThumb->sourceFilename.')', __FILE__, __LINE__);
|
||||
$CanPassThroughDirectly = false;
|
||||
} elseif (!@is_readable($phpThumb->sourceFilename)) {
|
||||
$phpThumb->DebugMessage('$CanPassThroughDirectly=false because !@is_readable('.$phpThumb->sourceFilename.')', __FILE__, __LINE__);
|
||||
$CanPassThroughDirectly = false;
|
||||
}
|
||||
foreach ($_GET as $key => $value) {
|
||||
switch ($key) {
|
||||
case 'src':
|
||||
// allowed
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
case 'h':
|
||||
// might be OK if exactly matches original
|
||||
break;
|
||||
|
||||
case 'phpThumbDebug':
|
||||
// handled in direct-passthru code
|
||||
break;
|
||||
|
||||
default:
|
||||
// all other parameters will cause some processing,
|
||||
// therefore cannot pass through original image unmodified
|
||||
$CanPassThroughDirectly = false;
|
||||
$UnAllowedGET[] = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($UnAllowedGET)) {
|
||||
$phpThumb->DebugMessage('$CanPassThroughDirectly=false because $_GET['.implode(';', array_unique($UnAllowedGET)).'] are set', __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Debug output, to try and help me diagnose problems
|
||||
$phpThumb->DebugTimingMessage('phpThumbDebug[4]', __FILE__, __LINE__);
|
||||
if (@$_GET['phpThumbDebug'] == '4') {
|
||||
$phpThumb->phpThumbDebug();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
function SendSaveAsFileHeaderIfNeeded() {
|
||||
if (headers_sent()) {
|
||||
return false;
|
||||
}
|
||||
global $phpThumb;
|
||||
if (@$_GET['down']) {
|
||||
$downloadfilename = ereg_replace('[/\\:\*\?"<>|]', '_', $_GET['down']);
|
||||
if (phpthumb_functions::version_compare_replacement(phpversion(), '4.1.0', '>=')) {
|
||||
$downloadfilename = trim($downloadfilename, '.');
|
||||
}
|
||||
if (@$downloadfilename) {
|
||||
$phpThumb->DebugMessage('SendSaveAsFileHeaderIfNeeded() sending header: Content-Disposition: attachment; filename="'.$downloadfilename.'"', __FILE__, __LINE__);
|
||||
header('Content-Disposition: attachment; filename="'.$downloadfilename.'"');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$phpThumb->DebugMessage('SendSaveAsFileHeaderIfNeeded() sending header: Content-Disposition: inline', __FILE__, __LINE__);
|
||||
header('Content-Disposition: inline');
|
||||
return true;
|
||||
}
|
||||
|
||||
$phpThumb->DebugMessage('$CanPassThroughDirectly="'.intval($CanPassThroughDirectly).'" && $phpThumb->src="'.$phpThumb->src.'"', __FILE__, __LINE__);
|
||||
while ($CanPassThroughDirectly && $phpThumb->src) {
|
||||
// no parameters set, passthru
|
||||
$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 (!@$_REQUEST['w'] && !@$_REQUEST['wp'] && !@$_REQUEST['wl'] && !@$_REQUEST['ws'] && !@$_REQUEST['h'] && !@$_REQUEST['hp'] && !@$_REQUEST['hl'] && !@$_REQUEST['hs']) {
|
||||
// no resizing needed
|
||||
$phpThumb->DebugMessage('Passing "'.$SourceFilename.'" through directly, no resizing required ("'.$phpThumb->getimagesizeinfo[0].'"x"'.$phpThumb->getimagesizeinfo[1].'")', __FILE__, __LINE__);
|
||||
} elseif (($phpThumb->getimagesizeinfo[0] <= @$_REQUEST['w']) && ($phpThumb->getimagesizeinfo[1] <= @$_REQUEST['h']) && ((@$_REQUEST['w'] == $phpThumb->getimagesizeinfo[0]) || (@$_REQUEST['h'] == $phpThumb->getimagesizeinfo[1]))) {
|
||||
// image fits into 'w'x'h' box, and at least one dimension matches exactly, therefore no resizing needed
|
||||
$phpThumb->DebugMessage('Passing "'.$SourceFilename.'" through directly, no resizing required ("'.$phpThumb->getimagesizeinfo[0].'"x"'.$phpThumb->getimagesizeinfo[1].'" fits inside "'.@$_REQUEST['w'].'"x"'.@$_REQUEST['h'].'")', __FILE__, __LINE__);
|
||||
} else {
|
||||
$phpThumb->DebugMessage('Not passing "'.$SourceFilename.'" through directly because resizing required (from "'.$phpThumb->getimagesizeinfo[0].'"x"'.$phpThumb->getimagesizeinfo[1].'" to "'.@$_REQUEST['w'].'"x"'.@$_REQUEST['h'].'")', __FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
switch ($phpThumb->getimagesizeinfo[2]) {
|
||||
case 1: // GIF
|
||||
case 2: // JPG
|
||||
case 3: // PNG
|
||||
// great, let it through
|
||||
break;
|
||||
default:
|
||||
// browser probably can't handle format, remangle it to JPEG/PNG/GIF
|
||||
$phpThumb->DebugMessage('Not passing "'.$SourceFilename.'" through directly because $phpThumb->getimagesizeinfo[2] = "'.$phpThumb->getimagesizeinfo[2].'"', __FILE__, __LINE__);
|
||||
break 2;
|
||||
}
|
||||
|
||||
$ImageCreateFunctions = array(1=>'ImageCreateFromGIF', 2=>'ImageCreateFromJPEG', 3=>'ImageCreateFromPNG');
|
||||
$theImageCreateFunction = @$ImageCreateFunctions[$phpThumb->getimagesizeinfo[2]];
|
||||
if ($phpThumb->config_disable_onlycreateable_passthru || (function_exists($theImageCreateFunction) && ($dummyImage = @$theImageCreateFunction($SourceFilename)))) {
|
||||
|
||||
// great
|
||||
if (@is_resource($dummyImage)) {
|
||||
unset($dummyImage);
|
||||
}
|
||||
|
||||
if (headers_sent()) {
|
||||
$phpThumb->ErrorImage('Headers already sent ('.basename(__FILE__).' line '.__LINE__.')');
|
||||
exit;
|
||||
}
|
||||
if (@$_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;
|
||||
}
|
||||
|
||||
SendSaveAsFileHeaderIfNeeded();
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s', @filemtime($SourceFilename)).' GMT');
|
||||
if ($contentType = phpthumb_functions::ImageTypeToMIMEtype(@$phpThumb->getimagesizeinfo[2])) {
|
||||
header('Content-Type: '.$contentType);
|
||||
}
|
||||
@readfile($SourceFilename);
|
||||
exit;
|
||||
|
||||
} else {
|
||||
$phpThumb->DebugMessage('Not passing "'.$SourceFilename.'" through directly because ($phpThumb->config_disable_onlycreateable_passthru = "'.$phpThumb->config_disable_onlycreateable_passthru.'") and '.$theImageCreateFunction.'() failed', __FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
$phpThumb->DebugMessage('Not passing "'.$SourceFilename.'" through directly because GetImageSize() failed', __FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Debug output, to try and help me diagnose problems
|
||||
$phpThumb->DebugTimingMessage('phpThumbDebug[5]', __FILE__, __LINE__);
|
||||
if (@$_GET['phpThumbDebug'] == '5') {
|
||||
$phpThumb->phpThumbDebug();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
function RedirectToCachedFile() {
|
||||
global $phpThumb, $PHPTHUMB_CONFIG;
|
||||
|
||||
$nice_cachefile = str_replace(DIRECTORY_SEPARATOR, '/', $phpThumb->cache_filename);
|
||||
$nice_docroot = str_replace(DIRECTORY_SEPARATOR, '/', rtrim($PHPTHUMB_CONFIG['document_root'], '/\\'));
|
||||
|
||||
$parsed_url = @parse_url(@$_SERVER['HTTP_REFERER']);
|
||||
|
||||
$nModified = filemtime($phpThumb->cache_filename);
|
||||
|
||||
if ($phpThumb->config_nooffsitelink_enabled && @$_SERVER['HTTP_REFERER'] && !in_array(@$parsed_url['host'], $phpThumb->config_nooffsitelink_valid_domains)) {
|
||||
|
||||
$phpThumb->DebugMessage('Would have used cached (image/'.$phpThumb->thumbnailFormat.') file "'.$phpThumb->cache_filename.'" (Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT), but skipping because $_SERVER[HTTP_REFERER] ('.@$_SERVER['HTTP_REFERER'].') is not in $phpThumb->config_nooffsitelink_valid_domains ('.implode(';', $phpThumb->config_nooffsitelink_valid_domains).')', __FILE__, __LINE__);
|
||||
|
||||
} elseif ($phpThumb->phpThumbDebug) {
|
||||
|
||||
$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)) {
|
||||
$phpThumb->DebugMessage('* Would have sent headers (2): Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]), __FILE__, __LINE__);
|
||||
}
|
||||
if (ereg('^'.preg_quote($nice_docroot).'(.*)$', $nice_cachefile, $matches)) {
|
||||
$phpThumb->DebugMessage('* Would have sent headers (3): Location: '.dirname($matches[1]).'/'.urlencode(basename($matches[1])), __FILE__, __LINE__);
|
||||
} else {
|
||||
$phpThumb->DebugMessage('* Would have sent data: readfile('.$phpThumb->cache_filename.')', __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (headers_sent()) {
|
||||
$phpThumb->ErrorImage('Headers already sent ('.basename(__FILE__).' line '.__LINE__.')');
|
||||
exit;
|
||||
}
|
||||
SendSaveAsFileHeaderIfNeeded();
|
||||
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT');
|
||||
if (@$_SERVER['HTTP_IF_MODIFIED_SINCE'] && ($nModified == strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) && @$_SERVER['SERVER_PROTOCOL']) {
|
||||
header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified');
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) {
|
||||
header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]));
|
||||
} elseif (eregi('\.ico$', $phpThumb->cache_filename)) {
|
||||
header('Content-Type: image/x-icon');
|
||||
}
|
||||
if (!@$PHPTHUMB_CONFIG['cache_force_passthru'] && ereg('^'.preg_quote($nice_docroot).'(.*)$', $nice_cachefile, $matches)) {
|
||||
header('Location: '.dirname($matches[1]).'/'.urlencode(basename($matches[1])));
|
||||
} else {
|
||||
@readfile($phpThumb->cache_filename);
|
||||
}
|
||||
exit;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// check to see if file already exists in cache, and output it with no processing if it does
|
||||
$phpThumb->SetCacheFilename();
|
||||
if (@is_file($phpThumb->cache_filename)) {
|
||||
RedirectToCachedFile();
|
||||
} else {
|
||||
$phpThumb->DebugMessage('Cached file "'.$phpThumb->cache_filename.'" does not exist, processing as normal', __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Debug output, to try and help me diagnose problems
|
||||
$phpThumb->DebugTimingMessage('phpThumbDebug[6]', __FILE__, __LINE__);
|
||||
if (@$_GET['phpThumbDebug'] == '6') {
|
||||
$phpThumb->phpThumbDebug();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
if ($phpThumb->rawImageData) {
|
||||
|
||||
// great
|
||||
|
||||
} elseif (@$_GET['new']) {
|
||||
|
||||
// generate a blank image resource of the specified size/background color/opacity
|
||||
if (($phpThumb->w <= 0) || ($phpThumb->h <= 0)) {
|
||||
$phpThumb->ErrorImage('"w" and "h" parameters required for "new"');
|
||||
}
|
||||
@list($bghexcolor, $opacity) = explode('|', $_GET['new']);
|
||||
if (!phpthumb_functions::IsHexColor($bghexcolor)) {
|
||||
$phpThumb->ErrorImage('BGcolor parameter for "new" is not valid');
|
||||
}
|
||||
$opacity = (strlen($opacity) ? $opacity : 100);
|
||||
if ($phpThumb->gdimg_source = phpthumb_functions::ImageCreateFunction($phpThumb->w, $phpThumb->h)) {
|
||||
$alpha = (100 - min(100, max(0, $opacity))) * 1.27;
|
||||
if ($alpha) {
|
||||
$phpThumb->setParameter('is_alpha', true);
|
||||
ImageAlphaBlending($phpThumb->gdimg_source, false);
|
||||
phpthumb_functions::gd_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);
|
||||
} else {
|
||||
$phpThumb->ErrorImage('failed to create "new" image ('.$phpThumb->w.'x'.$phpThumb->h.')');
|
||||
}
|
||||
|
||||
} elseif (!$phpThumb->src) {
|
||||
|
||||
$phpThumb->ErrorImage('Usage: '.$_SERVER['PHP_SELF'].'?src=/path/and/filename.jpg'."\n".'read Usage comments for details');
|
||||
|
||||
} elseif (eregi('^(f|ht)tp\://', $phpThumb->src)) {
|
||||
|
||||
if ($phpThumb->config_http_user_agent) {
|
||||
ini_set('user_agent', $phpThumb->config_http_user_agent);
|
||||
}
|
||||
$basename = preg_quote(basename($phpThumb->src));
|
||||
$encoded = rawurlencode(basename($phpThumb->src));
|
||||
$HTTPurl = ereg_replace('(.*)'.$basename.'$', '\\1'.$encoded, $phpThumb->src);
|
||||
if ($rawImageData = phpthumb_functions::SafeURLread($HTTPurl, $error)) {
|
||||
$phpThumb->setSourceData($rawImageData, urlencode($phpThumb->src));
|
||||
} else {
|
||||
$phpThumb->ErrorImage($error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Debug output, to try and help me diagnose problems
|
||||
$phpThumb->DebugTimingMessage('phpThumbDebug[7]', __FILE__, __LINE__);
|
||||
if (@$_GET['phpThumbDebug'] == '7') {
|
||||
$phpThumb->phpThumbDebug();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
$phpThumb->GenerateThumbnail();
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Debug output, to try and help me diagnose problems
|
||||
$phpThumb->DebugTimingMessage('phpThumbDebug[8]', __FILE__, __LINE__);
|
||||
if (@$_GET['phpThumbDebug'] == '8') {
|
||||
$phpThumb->phpThumbDebug();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
if ($phpThumb->config_allow_parameter_file && $phpThumb->file) {
|
||||
|
||||
$phpThumb->RenderToFile($phpThumb->ResolveFilenameToAbsolute($phpThumb->file));
|
||||
if ($phpThumb->config_allow_parameter_goto && $phpThumb->goto && eregi('^(f|ht)tps?://', $phpThumb->goto)) {
|
||||
// redirect to another URL after image has been rendered to file
|
||||
header('Location: '.$phpThumb->goto);
|
||||
exit;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ((file_exists($phpThumb->cache_filename) && is_writable($phpThumb->cache_filename)) || is_writable(dirname($phpThumb->cache_filename))) {
|
||||
|
||||
$phpThumb->CleanUpCacheDirectory();
|
||||
if ($phpThumb->RenderToFile($phpThumb->cache_filename) && is_readable($phpThumb->cache_filename)) {
|
||||
chmod($phpThumb->cache_filename, 0644);
|
||||
RedirectToCachedFile();
|
||||
} else {
|
||||
$phpThumb->DebugMessage('Failed: RenderToFile('.$phpThumb->cache_filename.')', __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$phpThumb->DebugMessage('Cannot write to $phpThumb->cache_filename ('.$phpThumb->cache_filename.') because that directory ('.dirname($phpThumb->cache_filename).') is not writable', __FILE__, __LINE__);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Debug output, to try and help me diagnose problems
|
||||
$phpThumb->DebugTimingMessage('phpThumbDebug[9]', __FILE__, __LINE__);
|
||||
if (@$_GET['phpThumbDebug'] == '9') {
|
||||
$phpThumb->phpThumbDebug();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
if (!$phpThumb->OutputThumbnail()) {
|
||||
$phpThumb->ErrorImage('Error in OutputThumbnail():'."\n".$phpThumb->debugmessages[(count($phpThumb->debugmessages) - 1)]);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Debug output, to try and help me diagnose problems
|
||||
$phpThumb->DebugTimingMessage('phpThumbDebug[10]', __FILE__, __LINE__);
|
||||
if (@$_GET['phpThumbDebug'] == '10') {
|
||||
$phpThumb->phpThumbDebug();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
?>
|
874
site/racecalendar/phpthumb/phpthumb.bmp.php
Normal file
874
site/racecalendar/phpthumb/phpthumb.bmp.php
Normal file
@ -0,0 +1,874 @@
|
||||
<?php
|
||||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <info@getid3.org> //
|
||||
// available at http://getid3.sourceforge.net //
|
||||
// or http://www.getid3.org //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// See readme.txt for more details //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// module.graphic.bmp.php //
|
||||
// module for analyzing BMP Image files //
|
||||
// dependencies: NONE //
|
||||
// ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Modified for use in phpThumb() - James Heinrich 2004.07.27 //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
class phpthumb_bmp {
|
||||
|
||||
function phpthumb_bmp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function phpthumb_bmp2gd(&$BMPdata, $truecolor=true) {
|
||||
$ThisFileInfo = array();
|
||||
if ($this->getid3_bmp($BMPdata, $ThisFileInfo, true, true)) {
|
||||
$gd = $this->PlotPixelsGD($ThisFileInfo['bmp'], $truecolor);
|
||||
return $gd;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function phpthumb_bmpfile2gd($filename, $truecolor=true) {
|
||||
if ($fp = @fopen($filename, 'rb')) {
|
||||
$BMPdata = fread($fp, filesize($filename));
|
||||
fclose($fp);
|
||||
return $this->phpthumb_bmp2gd($BMPdata, $truecolor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function GD2BMPstring(&$gd_image) {
|
||||
$imageX = ImageSX($gd_image);
|
||||
$imageY = ImageSY($gd_image);
|
||||
|
||||
$BMP = '';
|
||||
for ($y = ($imageY - 1); $y >= 0; $y--) {
|
||||
$thisline = '';
|
||||
for ($x = 0; $x < $imageX; $x++) {
|
||||
$argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
|
||||
$thisline .= chr($argb['blue']).chr($argb['green']).chr($argb['red']);
|
||||
}
|
||||
while (strlen($thisline) % 4) {
|
||||
$thisline .= "\x00";
|
||||
}
|
||||
$BMP .= $thisline;
|
||||
}
|
||||
|
||||
$bmpSize = strlen($BMP) + 14 + 40;
|
||||
// BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp
|
||||
$BITMAPFILEHEADER = 'BM'; // WORD bfType;
|
||||
$BITMAPFILEHEADER .= phpthumb_functions::LittleEndian2String($bmpSize, 4); // DWORD bfSize;
|
||||
$BITMAPFILEHEADER .= phpthumb_functions::LittleEndian2String( 0, 2); // WORD bfReserved1;
|
||||
$BITMAPFILEHEADER .= phpthumb_functions::LittleEndian2String( 0, 2); // WORD bfReserved2;
|
||||
$BITMAPFILEHEADER .= phpthumb_functions::LittleEndian2String( 54, 4); // DWORD bfOffBits;
|
||||
|
||||
// BITMAPINFOHEADER - [40 bytes] http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1rw2.asp
|
||||
$BITMAPINFOHEADER = phpthumb_functions::LittleEndian2String( 40, 4); // DWORD biSize;
|
||||
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( $imageX, 4); // LONG biWidth;
|
||||
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( $imageY, 4); // LONG biHeight;
|
||||
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 1, 2); // WORD biPlanes;
|
||||
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 24, 2); // WORD biBitCount;
|
||||
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 0, 4); // DWORD biCompression;
|
||||
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 0, 4); // DWORD biSizeImage;
|
||||
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 2835, 4); // LONG biXPelsPerMeter;
|
||||
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 2835, 4); // LONG biYPelsPerMeter;
|
||||
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 0, 4); // DWORD biClrUsed;
|
||||
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 0, 4); // DWORD biClrImportant;
|
||||
|
||||
return $BITMAPFILEHEADER.$BITMAPINFOHEADER.$BMP;
|
||||
}
|
||||
|
||||
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'];
|
||||
|
||||
// BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp
|
||||
// all versions
|
||||
// WORD bfType;
|
||||
// DWORD bfSize;
|
||||
// WORD bfReserved1;
|
||||
// WORD bfReserved2;
|
||||
// DWORD bfOffBits;
|
||||
|
||||
$offset = 0;
|
||||
$overalloffset = 0;
|
||||
$BMPheader = substr($BMPdata, $overalloffset, 14 + 40);
|
||||
$overalloffset += (14 + 40);
|
||||
|
||||
$thisfile_bmp_header_raw['identifier'] = substr($BMPheader, $offset, 2);
|
||||
$offset += 2;
|
||||
|
||||
if ($thisfile_bmp_header_raw['identifier'] != 'BM') {
|
||||
$ThisFileInfo['error'][] = 'Expecting "BM" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$thisfile_bmp_header_raw['identifier'].'"';
|
||||
unset($ThisFileInfo['fileformat']);
|
||||
unset($ThisFileInfo['bmp']);
|
||||
return false;
|
||||
}
|
||||
|
||||
$thisfile_bmp_header_raw['filesize'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['reserved1'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$thisfile_bmp_header_raw['reserved2'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$thisfile_bmp_header_raw['data_offset'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['header_size'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
|
||||
// check if the hardcoded-to-1 "planes" is at offset 22 or 26
|
||||
$planes22 = $this->LittleEndian2Int(substr($BMPheader, 22, 2));
|
||||
$planes26 = $this->LittleEndian2Int(substr($BMPheader, 26, 2));
|
||||
if (($planes22 == 1) && ($planes26 != 1)) {
|
||||
$thisfile_bmp['type_os'] = 'OS/2';
|
||||
$thisfile_bmp['type_version'] = 1;
|
||||
} elseif (($planes26 == 1) && ($planes22 != 1)) {
|
||||
$thisfile_bmp['type_os'] = 'Windows';
|
||||
$thisfile_bmp['type_version'] = 1;
|
||||
} elseif ($thisfile_bmp_header_raw['header_size'] == 12) {
|
||||
$thisfile_bmp['type_os'] = 'OS/2';
|
||||
$thisfile_bmp['type_version'] = 1;
|
||||
} elseif ($thisfile_bmp_header_raw['header_size'] == 40) {
|
||||
$thisfile_bmp['type_os'] = 'Windows';
|
||||
$thisfile_bmp['type_version'] = 1;
|
||||
} elseif ($thisfile_bmp_header_raw['header_size'] == 84) {
|
||||
$thisfile_bmp['type_os'] = 'Windows';
|
||||
$thisfile_bmp['type_version'] = 4;
|
||||
} elseif ($thisfile_bmp_header_raw['header_size'] == 100) {
|
||||
$thisfile_bmp['type_os'] = 'Windows';
|
||||
$thisfile_bmp['type_version'] = 5;
|
||||
} else {
|
||||
$ThisFileInfo['error'][] = 'Unknown BMP subtype (or not a BMP file)';
|
||||
unset($ThisFileInfo['fileformat']);
|
||||
unset($ThisFileInfo['bmp']);
|
||||
return false;
|
||||
}
|
||||
|
||||
$ThisFileInfo['fileformat'] = 'bmp';
|
||||
$ThisFileInfo['video']['dataformat'] = 'bmp';
|
||||
$ThisFileInfo['video']['lossless'] = true;
|
||||
$ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
|
||||
|
||||
if ($thisfile_bmp['type_os'] == 'OS/2') {
|
||||
|
||||
// OS/2-format BMP
|
||||
// http://netghost.narod.ru/gff/graphics/summary/os2bmp.htm
|
||||
|
||||
// DWORD Size; /* Size of this structure in bytes */
|
||||
// DWORD Width; /* Bitmap width in pixels */
|
||||
// DWORD Height; /* Bitmap height in pixel */
|
||||
// WORD NumPlanes; /* Number of bit planes (color depth) */
|
||||
// WORD BitsPerPixel; /* Number of bits per pixel per plane */
|
||||
|
||||
$thisfile_bmp_header_raw['width'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$thisfile_bmp_header_raw['height'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$thisfile_bmp_header_raw['planes'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$thisfile_bmp_header_raw['bits_per_pixel'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
|
||||
$ThisFileInfo['video']['resolution_x'] = $thisfile_bmp_header_raw['width'];
|
||||
$ThisFileInfo['video']['resolution_y'] = $thisfile_bmp_header_raw['height'];
|
||||
$ThisFileInfo['video']['codec'] = 'BI_RGB '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
|
||||
$ThisFileInfo['video']['bits_per_sample'] = $thisfile_bmp_header_raw['bits_per_pixel'];
|
||||
|
||||
if ($thisfile_bmp['type_version'] >= 2) {
|
||||
// DWORD Compression; /* Bitmap compression scheme */
|
||||
// DWORD ImageDataSize; /* Size of bitmap data in bytes */
|
||||
// DWORD XResolution; /* X resolution of display device */
|
||||
// DWORD YResolution; /* Y resolution of display device */
|
||||
// DWORD ColorsUsed; /* Number of color table indices used */
|
||||
// DWORD ColorsImportant; /* Number of important color indices */
|
||||
// WORD Units; /* Type of units used to measure resolution */
|
||||
// WORD Reserved; /* Pad structure to 4-byte boundary */
|
||||
// WORD Recording; /* Recording algorithm */
|
||||
// WORD Rendering; /* Halftoning algorithm used */
|
||||
// DWORD Size1; /* Reserved for halftoning algorithm use */
|
||||
// DWORD Size2; /* Reserved for halftoning algorithm use */
|
||||
// DWORD ColorEncoding; /* Color model used in bitmap */
|
||||
// DWORD Identifier; /* Reserved for application use */
|
||||
|
||||
$thisfile_bmp_header_raw['compression'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$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));
|
||||
$offset += 4;
|
||||
$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;
|
||||
$thisfile_bmp_header_raw['colors_important'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['resolution_units'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$thisfile_bmp_header_raw['reserved1'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$thisfile_bmp_header_raw['recording'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$thisfile_bmp_header_raw['rendering'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$thisfile_bmp_header_raw['size1'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['size2'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['color_encoding'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['identifier'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
$thisfile_bmp_header['compression'] = $this->BMPcompressionOS2Lookup($thisfile_bmp_header_raw['compression']);
|
||||
|
||||
$ThisFileInfo['video']['codec'] = $thisfile_bmp_header['compression'].' '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
|
||||
}
|
||||
|
||||
} elseif ($thisfile_bmp['type_os'] == 'Windows') {
|
||||
|
||||
// Windows-format BMP
|
||||
|
||||
// BITMAPINFOHEADER - [40 bytes] http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1rw2.asp
|
||||
// all versions
|
||||
// DWORD biSize;
|
||||
// LONG biWidth;
|
||||
// LONG biHeight;
|
||||
// WORD biPlanes;
|
||||
// WORD biBitCount;
|
||||
// DWORD biCompression;
|
||||
// DWORD biSizeImage;
|
||||
// LONG biXPelsPerMeter;
|
||||
// LONG biYPelsPerMeter;
|
||||
// DWORD biClrUsed;
|
||||
// DWORD biClrImportant;
|
||||
|
||||
$thisfile_bmp_header_raw['width'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4), true);
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['height'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4), true);
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['planes'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$thisfile_bmp_header_raw['bits_per_pixel'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
|
||||
$offset += 2;
|
||||
$thisfile_bmp_header_raw['compression'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$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);
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['resolution_v'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4), true);
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['colors_used'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['colors_important'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
$thisfile_bmp_header['compression'] = $this->BMPcompressionWindowsLookup($thisfile_bmp_header_raw['compression']);
|
||||
$ThisFileInfo['video']['resolution_x'] = $thisfile_bmp_header_raw['width'];
|
||||
$ThisFileInfo['video']['resolution_y'] = $thisfile_bmp_header_raw['height'];
|
||||
$ThisFileInfo['video']['codec'] = $thisfile_bmp_header['compression'].' '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
|
||||
$ThisFileInfo['video']['bits_per_sample'] = $thisfile_bmp_header_raw['bits_per_pixel'];
|
||||
|
||||
if (($thisfile_bmp['type_version'] >= 4) || ($thisfile_bmp_header_raw['compression'] == 3)) {
|
||||
// should only be v4+, but BMPs with type_version==1 and BI_BITFIELDS compression have been seen
|
||||
$BMPheader .= substr($BMPdata, $overalloffset, 44);
|
||||
$overalloffset += 44;
|
||||
|
||||
// BITMAPV4HEADER - [44 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_2k1e.asp
|
||||
// Win95+, WinNT4.0+
|
||||
// DWORD bV4RedMask;
|
||||
// DWORD bV4GreenMask;
|
||||
// DWORD bV4BlueMask;
|
||||
// DWORD bV4AlphaMask;
|
||||
// DWORD bV4CSType;
|
||||
// CIEXYZTRIPLE bV4Endpoints;
|
||||
// DWORD bV4GammaRed;
|
||||
// DWORD bV4GammaGreen;
|
||||
// DWORD bV4GammaBlue;
|
||||
$thisfile_bmp_header_raw['red_mask'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['green_mask'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['blue_mask'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['alpha_mask'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['cs_type'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['ciexyz_red'] = substr($BMPheader, $offset, 4);
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['ciexyz_green'] = substr($BMPheader, $offset, 4);
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['ciexyz_blue'] = substr($BMPheader, $offset, 4);
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['gamma_red'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['gamma_green'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['gamma_blue'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
|
||||
$thisfile_bmp_header['ciexyz_red'] = $this->FixedPoint2_30(strrev($thisfile_bmp_header_raw['ciexyz_red']));
|
||||
$thisfile_bmp_header['ciexyz_green'] = $this->FixedPoint2_30(strrev($thisfile_bmp_header_raw['ciexyz_green']));
|
||||
$thisfile_bmp_header['ciexyz_blue'] = $this->FixedPoint2_30(strrev($thisfile_bmp_header_raw['ciexyz_blue']));
|
||||
}
|
||||
|
||||
if ($thisfile_bmp['type_version'] >= 5) {
|
||||
$BMPheader .= substr($BMPdata, $overalloffset, 16);
|
||||
$overalloffset += 16;
|
||||
|
||||
// BITMAPV5HEADER - [16 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_7c36.asp
|
||||
// Win98+, Win2000+
|
||||
// DWORD bV5Intent;
|
||||
// DWORD bV5ProfileData;
|
||||
// DWORD bV5ProfileSize;
|
||||
// DWORD bV5Reserved;
|
||||
$thisfile_bmp_header_raw['intent'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['profile_data_offset'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['profile_data_size'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
$thisfile_bmp_header_raw['reserved3'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
|
||||
$offset += 4;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$ThisFileInfo['error'][] = 'Unknown BMP format in header.';
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if ($ExtractPalette || $ExtractData) {
|
||||
$PaletteEntries = 0;
|
||||
if ($thisfile_bmp_header_raw['bits_per_pixel'] < 16) {
|
||||
$PaletteEntries = pow(2, $thisfile_bmp_header_raw['bits_per_pixel']);
|
||||
} elseif (isset($thisfile_bmp_header_raw['colors_used']) && ($thisfile_bmp_header_raw['colors_used'] > 0) && ($thisfile_bmp_header_raw['colors_used'] <= 256)) {
|
||||
$PaletteEntries = $thisfile_bmp_header_raw['colors_used'];
|
||||
}
|
||||
if ($PaletteEntries > 0) {
|
||||
$BMPpalette = substr($BMPdata, $overalloffset, 4 * $PaletteEntries);
|
||||
$overalloffset += 4 * $PaletteEntries;
|
||||
|
||||
$paletteoffset = 0;
|
||||
for ($i = 0; $i < $PaletteEntries; $i++) {
|
||||
// RGBQUAD - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_5f8y.asp
|
||||
// BYTE rgbBlue;
|
||||
// BYTE rgbGreen;
|
||||
// BYTE rgbRed;
|
||||
// BYTE rgbReserved;
|
||||
$blue = $this->LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
|
||||
$green = $this->LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
|
||||
$red = $this->LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
|
||||
if (($thisfile_bmp['type_os'] == 'OS/2') && ($thisfile_bmp['type_version'] == 1)) {
|
||||
// no padding byte
|
||||
} else {
|
||||
$paletteoffset++; // padding byte
|
||||
}
|
||||
$thisfile_bmp['palette'][$i] = (($red << 16) | ($green << 8) | ($blue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($ExtractData) {
|
||||
$RowByteLength = ceil(($thisfile_bmp_header_raw['width'] * ($thisfile_bmp_header_raw['bits_per_pixel'] / 8)) / 4) * 4; // round up to nearest DWORD boundry
|
||||
|
||||
$BMPpixelData = substr($BMPdata, $thisfile_bmp_header_raw['data_offset'], $thisfile_bmp_header_raw['height'] * $RowByteLength);
|
||||
$overalloffset = $thisfile_bmp_header_raw['data_offset'] + ($thisfile_bmp_header_raw['height'] * $RowByteLength);
|
||||
|
||||
$pixeldataoffset = 0;
|
||||
switch (@$thisfile_bmp_header_raw['compression']) {
|
||||
|
||||
case 0: // BI_RGB
|
||||
switch ($thisfile_bmp_header_raw['bits_per_pixel']) {
|
||||
case 1:
|
||||
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
|
||||
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col = $col) {
|
||||
$paletteindexbyte = ord($BMPpixelData{$pixeldataoffset++});
|
||||
for ($i = 7; $i >= 0; $i--) {
|
||||
$paletteindex = ($paletteindexbyte & (0x01 << $i)) >> $i;
|
||||
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
|
||||
$col++;
|
||||
}
|
||||
}
|
||||
while (($pixeldataoffset % 4) != 0) {
|
||||
// lines are padded to nearest DWORD
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
|
||||
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col = $col) {
|
||||
$paletteindexbyte = ord($BMPpixelData{$pixeldataoffset++});
|
||||
for ($i = 1; $i >= 0; $i--) {
|
||||
$paletteindex = ($paletteindexbyte & (0x0F << (4 * $i))) >> (4 * $i);
|
||||
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
|
||||
$col++;
|
||||
}
|
||||
}
|
||||
while (($pixeldataoffset % 4) != 0) {
|
||||
// lines are padded to nearest DWORD
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
|
||||
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
|
||||
$paletteindex = ord($BMPpixelData{$pixeldataoffset++});
|
||||
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
|
||||
}
|
||||
while (($pixeldataoffset % 4) != 0) {
|
||||
// lines are padded to nearest DWORD
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 24:
|
||||
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
|
||||
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
|
||||
$thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData{$pixeldataoffset+2}) << 16) | (ord($BMPpixelData{$pixeldataoffset+1}) << 8) | ord($BMPpixelData{$pixeldataoffset});
|
||||
$pixeldataoffset += 3;
|
||||
}
|
||||
while (($pixeldataoffset % 4) != 0) {
|
||||
// lines are padded to nearest DWORD
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 32:
|
||||
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
|
||||
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
|
||||
$thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData{$pixeldataoffset+3}) << 24) | (ord($BMPpixelData{$pixeldataoffset+2}) << 16) | (ord($BMPpixelData{$pixeldataoffset+1}) << 8) | ord($BMPpixelData{$pixeldataoffset});
|
||||
$pixeldataoffset += 4;
|
||||
}
|
||||
while (($pixeldataoffset % 4) != 0) {
|
||||
// lines are padded to nearest DWORD
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 16:
|
||||
// ?
|
||||
break;
|
||||
|
||||
default:
|
||||
$ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 1: // BI_RLE8 - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_6x0u.asp
|
||||
switch ($thisfile_bmp_header_raw['bits_per_pixel']) {
|
||||
case 8:
|
||||
$pixelcounter = 0;
|
||||
while ($pixeldataoffset < strlen($BMPpixelData)) {
|
||||
$firstbyte = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$secondbyte = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
if ($firstbyte == 0) {
|
||||
|
||||
// escaped/absolute mode - the first byte of the pair can be set to zero to
|
||||
// indicate an escape character that denotes the end of a line, the end of
|
||||
// a bitmap, or a delta, depending on the value of the second byte.
|
||||
switch ($secondbyte) {
|
||||
case 0:
|
||||
// end of line
|
||||
// no need for special processing, just ignore
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// end of bitmap
|
||||
$pixeldataoffset = strlen($BMPpixelData); // force to exit loop just in case
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// delta - The 2 bytes following the escape contain unsigned values
|
||||
// indicating the horizontal and vertical offsets of the next pixel
|
||||
// from the current position.
|
||||
$colincrement = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$rowincrement = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$col = ($pixelcounter % $thisfile_bmp_header_raw['width']) + $colincrement;
|
||||
$row = ($thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width'])) - $rowincrement;
|
||||
$pixelcounter = ($row * $thisfile_bmp_header_raw['width']) + $col;
|
||||
break;
|
||||
|
||||
default:
|
||||
// In absolute mode, the first byte is zero and the second byte is a
|
||||
// value in the range 03H through FFH. The second byte represents the
|
||||
// number of bytes that follow, each of which contains the color index
|
||||
// of a single pixel. Each run must be aligned on a word boundary.
|
||||
for ($i = 0; $i < $secondbyte; $i++) {
|
||||
$paletteindex = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$col = $pixelcounter % $thisfile_bmp_header_raw['width'];
|
||||
$row = $thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width']);
|
||||
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
|
||||
$pixelcounter++;
|
||||
}
|
||||
while (($pixeldataoffset % 2) != 0) {
|
||||
// Each run must be aligned on a word boundary.
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// encoded mode - the first byte specifies the number of consecutive pixels
|
||||
// to be drawn using the color index contained in the second byte.
|
||||
for ($i = 0; $i < $firstbyte; $i++) {
|
||||
$col = $pixelcounter % $thisfile_bmp_header_raw['width'];
|
||||
$row = $thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width']);
|
||||
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$secondbyte];
|
||||
$pixelcounter++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 2: // BI_RLE4 - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_6x0u.asp
|
||||
switch ($thisfile_bmp_header_raw['bits_per_pixel']) {
|
||||
case 4:
|
||||
$pixelcounter = 0;
|
||||
while ($pixeldataoffset < strlen($BMPpixelData)) {
|
||||
$firstbyte = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$secondbyte = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
if ($firstbyte == 0) {
|
||||
|
||||
// escaped/absolute mode - the first byte of the pair can be set to zero to
|
||||
// indicate an escape character that denotes the end of a line, the end of
|
||||
// a bitmap, or a delta, depending on the value of the second byte.
|
||||
switch ($secondbyte) {
|
||||
case 0:
|
||||
// end of line
|
||||
// no need for special processing, just ignore
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// end of bitmap
|
||||
$pixeldataoffset = strlen($BMPpixelData); // force to exit loop just in case
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// delta - The 2 bytes following the escape contain unsigned values
|
||||
// indicating the horizontal and vertical offsets of the next pixel
|
||||
// from the current position.
|
||||
$colincrement = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$rowincrement = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$col = ($pixelcounter % $thisfile_bmp_header_raw['width']) + $colincrement;
|
||||
$row = ($thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width'])) - $rowincrement;
|
||||
$pixelcounter = ($row * $thisfile_bmp_header_raw['width']) + $col;
|
||||
break;
|
||||
|
||||
default:
|
||||
// In absolute mode, the first byte is zero. The second byte contains the number
|
||||
// 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);
|
||||
for ($i = 0; $i < ceil($secondbyte / 2); $i++) {
|
||||
$paletteindexbyte = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
|
||||
$paletteindexes[] = ($paletteindexbyte & 0xF0) >> 4;
|
||||
$paletteindexes[] = ($paletteindexbyte & 0x0F);
|
||||
}
|
||||
while (($pixeldataoffset % 2) != 0) {
|
||||
// Each run must be aligned on a word boundary.
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
|
||||
foreach ($paletteindexes as $dummy => $paletteindex) {
|
||||
$col = $pixelcounter % $thisfile_bmp_header_raw['width'];
|
||||
$row = $thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width']);
|
||||
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
|
||||
$pixelcounter++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// encoded mode - the first byte of the pair contains the number of pixels to be
|
||||
// drawn using the color indexes in the second byte. The second byte contains two
|
||||
// color indexes, one in its high-order 4 bits and one in its low-order 4 bits.
|
||||
// The first of the pixels is drawn using the color specified by the high-order
|
||||
// 4 bits, the second is drawn using the color in the low-order 4 bits, the third
|
||||
// is drawn using the color in the high-order 4 bits, and so on, until all the
|
||||
// pixels specified by the first byte have been drawn.
|
||||
$paletteindexes[0] = ($secondbyte & 0xF0) >> 4;
|
||||
$paletteindexes[1] = ($secondbyte & 0x0F);
|
||||
for ($i = 0; $i < $firstbyte; $i++) {
|
||||
$col = $pixelcounter % $thisfile_bmp_header_raw['width'];
|
||||
$row = $thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width']);
|
||||
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindexes[($i % 2)]];
|
||||
$pixelcounter++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 3: // BI_BITFIELDS
|
||||
switch ($thisfile_bmp_header_raw['bits_per_pixel']) {
|
||||
case 16:
|
||||
case 32:
|
||||
$redshift = 0;
|
||||
$greenshift = 0;
|
||||
$blueshift = 0;
|
||||
if (!$thisfile_bmp_header_raw['red_mask'] || !$thisfile_bmp_header_raw['green_mask'] || !$thisfile_bmp_header_raw['blue_mask']) {
|
||||
$ThisFileInfo['error'][] = 'missing $thisfile_bmp_header_raw[(red|green|blue)_mask]';
|
||||
return false;
|
||||
}
|
||||
while ((($thisfile_bmp_header_raw['red_mask'] >> $redshift) & 0x01) == 0) {
|
||||
$redshift++;
|
||||
}
|
||||
while ((($thisfile_bmp_header_raw['green_mask'] >> $greenshift) & 0x01) == 0) {
|
||||
$greenshift++;
|
||||
}
|
||||
while ((($thisfile_bmp_header_raw['blue_mask'] >> $blueshift) & 0x01) == 0) {
|
||||
$blueshift++;
|
||||
}
|
||||
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
|
||||
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
|
||||
$pixelvalue = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset, $thisfile_bmp_header_raw['bits_per_pixel'] / 8));
|
||||
$pixeldataoffset += $thisfile_bmp_header_raw['bits_per_pixel'] / 8;
|
||||
|
||||
$red = intval(round(((($pixelvalue & $thisfile_bmp_header_raw['red_mask']) >> $redshift) / ($thisfile_bmp_header_raw['red_mask'] >> $redshift)) * 255));
|
||||
$green = intval(round(((($pixelvalue & $thisfile_bmp_header_raw['green_mask']) >> $greenshift) / ($thisfile_bmp_header_raw['green_mask'] >> $greenshift)) * 255));
|
||||
$blue = intval(round(((($pixelvalue & $thisfile_bmp_header_raw['blue_mask']) >> $blueshift) / ($thisfile_bmp_header_raw['blue_mask'] >> $blueshift)) * 255));
|
||||
$thisfile_bmp['data'][$row][$col] = (($red << 16) | ($green << 8) | ($blue));
|
||||
}
|
||||
while (($pixeldataoffset % 4) != 0) {
|
||||
// lines are padded to nearest DWORD
|
||||
$pixeldataoffset++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default: // unhandled compression type
|
||||
$ThisFileInfo['error'][] = 'Unknown/unhandled compression type value ('.$thisfile_bmp_header_raw['compression'].') - cannot decompress pixel data';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function IntColor2RGB($color) {
|
||||
$red = ($color & 0x00FF0000) >> 16;
|
||||
$green = ($color & 0x0000FF00) >> 8;
|
||||
$blue = ($color & 0x000000FF);
|
||||
return array($red, $green, $blue);
|
||||
}
|
||||
|
||||
function PlotPixelsGD(&$BMPdata, $truecolor=true) {
|
||||
$imagewidth = $BMPdata['header']['raw']['width'];
|
||||
$imageheight = $BMPdata['header']['raw']['height'];
|
||||
|
||||
if ($truecolor) {
|
||||
|
||||
$gd = @ImageCreateTrueColor($imagewidth, $imageheight);
|
||||
|
||||
} else {
|
||||
|
||||
$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);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!is_resource($gd)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($BMPdata['data'] as $row => $colarray) {
|
||||
@set_time_limit(30);
|
||||
foreach ($colarray as $col => $color) {
|
||||
list($red, $green, $blue) = $this->IntColor2RGB($color);
|
||||
if ($truecolor) {
|
||||
$pixelcolor = ImageColorAllocate($gd, $red, $green, $blue);
|
||||
} else {
|
||||
$pixelcolor = ImageColorClosest($gd, $red, $green, $blue);
|
||||
}
|
||||
ImageSetPixel($gd, $col, $row, $pixelcolor);
|
||||
}
|
||||
}
|
||||
return $gd;
|
||||
}
|
||||
|
||||
function PlotBMP(&$BMPinfo) {
|
||||
$starttime = time();
|
||||
if (!isset($BMPinfo['bmp']['data']) || !is_array($BMPinfo['bmp']['data'])) {
|
||||
echo 'ERROR: no pixel data<BR>';
|
||||
return false;
|
||||
}
|
||||
set_time_limit(intval(round($BMPinfo['resolution_x'] * $BMPinfo['resolution_y'] / 10000)));
|
||||
$im = $this->PlotPixelsGD($BMPinfo['bmp']);
|
||||
if (headers_sent()) {
|
||||
echo 'plotted '.($BMPinfo['resolution_x'] * $BMPinfo['resolution_y']).' pixels in '.(time() - $starttime).' seconds<BR>';
|
||||
ImageDestroy($im);
|
||||
exit;
|
||||
} else {
|
||||
header('Content-Type: image/png');
|
||||
ImagePNG($im);
|
||||
ImageDestroy($im);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function BMPcompressionWindowsLookup($compressionid) {
|
||||
static $BMPcompressionWindowsLookup = array(
|
||||
0 => 'BI_RGB',
|
||||
1 => 'BI_RLE8',
|
||||
2 => 'BI_RLE4',
|
||||
3 => 'BI_BITFIELDS',
|
||||
4 => 'BI_JPEG',
|
||||
5 => 'BI_PNG'
|
||||
);
|
||||
return (isset($BMPcompressionWindowsLookup[$compressionid]) ? $BMPcompressionWindowsLookup[$compressionid] : 'invalid');
|
||||
}
|
||||
|
||||
function BMPcompressionOS2Lookup($compressionid) {
|
||||
static $BMPcompressionOS2Lookup = array(
|
||||
0 => 'BI_RGB',
|
||||
1 => 'BI_RLE8',
|
||||
2 => 'BI_RLE4',
|
||||
3 => 'Huffman 1D',
|
||||
4 => 'BI_RLE24',
|
||||
);
|
||||
return (isset($BMPcompressionOS2Lookup[$compressionid]) ? $BMPcompressionOS2Lookup[$compressionid] : 'invalid');
|
||||
}
|
||||
|
||||
|
||||
// from getid3.lib.php
|
||||
|
||||
function trunc($floatnumber) {
|
||||
// truncates a floating-point number at the decimal point
|
||||
// returns int (if possible, otherwise float)
|
||||
if ($floatnumber >= 1) {
|
||||
$truncatednumber = floor($floatnumber);
|
||||
} elseif ($floatnumber <= -1) {
|
||||
$truncatednumber = ceil($floatnumber);
|
||||
} else {
|
||||
$truncatednumber = 0;
|
||||
}
|
||||
if ($truncatednumber <= 1073741824) { // 2^30
|
||||
$truncatednumber = (int) $truncatednumber;
|
||||
}
|
||||
return $truncatednumber;
|
||||
}
|
||||
|
||||
function LittleEndian2Int($byteword) {
|
||||
$intvalue = 0;
|
||||
$byteword = strrev($byteword);
|
||||
$bytewordlen = strlen($byteword);
|
||||
for ($i = 0; $i < $bytewordlen; $i++) {
|
||||
$intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
|
||||
}
|
||||
return $intvalue;
|
||||
}
|
||||
|
||||
function BigEndian2Int($byteword) {
|
||||
return $this->LittleEndian2Int(strrev($byteword));
|
||||
}
|
||||
|
||||
function BigEndian2Bin($byteword) {
|
||||
$binvalue = '';
|
||||
$bytewordlen = strlen($byteword);
|
||||
for ($i = 0; $i < $bytewordlen; $i++) {
|
||||
$binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
|
||||
}
|
||||
return $binvalue;
|
||||
}
|
||||
|
||||
function FixedPoint2_30($rawdata) {
|
||||
$binarystring = $this->BigEndian2Bin($rawdata);
|
||||
return $this->Bin2Dec(substr($binarystring, 0, 2)) + (float) ($this->Bin2Dec(substr($binarystring, 2, 30)) / 1073741824);
|
||||
}
|
||||
|
||||
function Bin2Dec($binstring, $signed=false) {
|
||||
$signmult = 1;
|
||||
if ($signed) {
|
||||
if ($binstring{0} == '1') {
|
||||
$signmult = -1;
|
||||
}
|
||||
$binstring = substr($binstring, 1);
|
||||
}
|
||||
$decvalue = 0;
|
||||
for ($i = 0; $i < strlen($binstring); $i++) {
|
||||
$decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
|
||||
}
|
||||
return $this->CastAsInt($decvalue * $signmult);
|
||||
}
|
||||
|
||||
function CastAsInt($floatnum) {
|
||||
// convert to float if not already
|
||||
$floatnum = (float) $floatnum;
|
||||
|
||||
// convert a float to type int, only if possible
|
||||
if ($this->trunc($floatnum) == $floatnum) {
|
||||
// it's not floating point
|
||||
if ($floatnum <= 1073741824) { // 2^30
|
||||
// it's within int range
|
||||
$floatnum = (int) $floatnum;
|
||||
}
|
||||
}
|
||||
return $floatnum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
3170
site/racecalendar/phpthumb/phpthumb.class.php
Normal file
3170
site/racecalendar/phpthumb/phpthumb.class.php
Normal file
File diff suppressed because it is too large
Load Diff
1235
site/racecalendar/phpthumb/phpthumb.filters.php
Normal file
1235
site/racecalendar/phpthumb/phpthumb.filters.php
Normal file
File diff suppressed because it is too large
Load Diff
707
site/racecalendar/phpthumb/phpthumb.functions.php
Normal file
707
site/racecalendar/phpthumb/phpthumb.functions.php
Normal file
@ -0,0 +1,707 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// //
|
||||
// phpthumb.functions.php - general support functions //
|
||||
// ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
class phpthumb_functions {
|
||||
|
||||
function user_function_exists($functionname) {
|
||||
if (function_exists('get_defined_functions')) {
|
||||
static $get_defined_functions = array();
|
||||
if (empty($get_defined_functions)) {
|
||||
$get_defined_functions = get_defined_functions();
|
||||
}
|
||||
return in_array(strtolower($functionname), $get_defined_functions['user']);
|
||||
}
|
||||
return function_exists($functionname);
|
||||
}
|
||||
|
||||
|
||||
function builtin_function_exists($functionname) {
|
||||
if (function_exists('get_defined_functions')) {
|
||||
static $get_defined_functions = array();
|
||||
if (empty($get_defined_functions)) {
|
||||
$get_defined_functions = get_defined_functions();
|
||||
}
|
||||
return in_array(strtolower($functionname), $get_defined_functions['internal']);
|
||||
}
|
||||
return function_exists($functionname);
|
||||
}
|
||||
|
||||
|
||||
function version_compare_replacement_sub($version1, $version2, $operator='') {
|
||||
// If you specify the third optional operator argument, you can test for a particular relationship.
|
||||
// The possible operators are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne respectively.
|
||||
// Using this argument, the function will return 1 if the relationship is the one specified by the operator, 0 otherwise.
|
||||
|
||||
// If a part contains special version strings these are handled in the following order: dev < (alpha = a) < (beta = b) < RC < pl
|
||||
static $versiontype_lookup = array();
|
||||
if (empty($versiontype_lookup)) {
|
||||
$versiontype_lookup['dev'] = 10001;
|
||||
$versiontype_lookup['a'] = 10002;
|
||||
$versiontype_lookup['alpha'] = 10002;
|
||||
$versiontype_lookup['b'] = 10003;
|
||||
$versiontype_lookup['beta'] = 10003;
|
||||
$versiontype_lookup['RC'] = 10004;
|
||||
$versiontype_lookup['pl'] = 10005;
|
||||
}
|
||||
if (isset($versiontype_lookup[$version1])) {
|
||||
$version1 = $versiontype_lookup[$version1];
|
||||
}
|
||||
if (isset($versiontype_lookup[$version2])) {
|
||||
$version2 = $versiontype_lookup[$version2];
|
||||
}
|
||||
|
||||
switch ($operator) {
|
||||
case '<':
|
||||
case 'lt':
|
||||
return intval($version1 < $version2);
|
||||
break;
|
||||
case '<=':
|
||||
case 'le':
|
||||
return intval($version1 <= $version2);
|
||||
break;
|
||||
case '>':
|
||||
case 'gt':
|
||||
return intval($version1 > $version2);
|
||||
break;
|
||||
case '>=':
|
||||
case 'ge':
|
||||
return intval($version1 >= $version2);
|
||||
break;
|
||||
case '==':
|
||||
case '=':
|
||||
case 'eq':
|
||||
return intval($version1 == $version2);
|
||||
break;
|
||||
case '!=':
|
||||
case '<>':
|
||||
case 'ne':
|
||||
return intval($version1 != $version2);
|
||||
break;
|
||||
}
|
||||
if ($version1 == $version2) {
|
||||
return 0;
|
||||
} elseif ($version1 < $version2) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function version_compare_replacement($version1, $version2, $operator='') {
|
||||
if (function_exists('version_compare')) {
|
||||
// built into PHP v4.1.0+
|
||||
return version_compare($version1, $version2, $operator);
|
||||
}
|
||||
|
||||
// The function first replaces _, - and + with a dot . in the version strings
|
||||
$version1 = strtr($version1, '_-+', '...');
|
||||
$version2 = strtr($version2, '_-+', '...');
|
||||
|
||||
// and also inserts dots . before and after any non number so that for example '4.3.2RC1' becomes '4.3.2.RC.1'.
|
||||
// Then it splits the results like if you were using explode('.',$ver). Then it compares the parts starting from left to right.
|
||||
$version1 = eregi_replace('([0-9]+)([A-Z]+)([0-9]+)', '\\1.\\2.\\3', $version1);
|
||||
$version2 = eregi_replace('([0-9]+)([A-Z]+)([0-9]+)', '\\1.\\2.\\3', $version2);
|
||||
|
||||
$parts1 = explode('.', $version1);
|
||||
$parts2 = explode('.', $version1);
|
||||
$parts_count = max(count($parts1), count($parts2));
|
||||
for ($i = 0; $i < $parts_count; $i++) {
|
||||
$comparison = phpthumb_functions::version_compare_replacement_sub($version1, $version2, $operator);
|
||||
if ($comparison != 0) {
|
||||
return $comparison;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function phpinfo_array() {
|
||||
static $phpinfo_array = array();
|
||||
if (empty($phpinfo_array)) {
|
||||
ob_start();
|
||||
phpinfo();
|
||||
$phpinfo = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$phpinfo_array = explode("\n", $phpinfo);
|
||||
}
|
||||
return $phpinfo_array;
|
||||
}
|
||||
|
||||
|
||||
function exif_info() {
|
||||
static $exif_info = array();
|
||||
if (empty($exif_info)) {
|
||||
// based on code by johnschaefer at gmx dot de
|
||||
// from PHP help on gd_info()
|
||||
$exif_info = array(
|
||||
'EXIF Support' => '',
|
||||
'EXIF Version' => '',
|
||||
'Supported EXIF Version' => '',
|
||||
'Supported filetypes' => ''
|
||||
);
|
||||
$phpinfo_array = phpthumb_functions::phpinfo_array();
|
||||
foreach ($phpinfo_array as $dummy => $line) {
|
||||
$line = trim(strip_tags($line));
|
||||
foreach ($exif_info as $key => $value) {
|
||||
if (strpos($line, $key) === 0) {
|
||||
$newvalue = trim(str_replace($key, '', $line));
|
||||
$exif_info[$key] = $newvalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $exif_info;
|
||||
}
|
||||
|
||||
|
||||
function ImageTypeToMIMEtype($imagetype) {
|
||||
if (function_exists('image_type_to_mime_type') && ($imagetype >= 1) && ($imagetype <= 16)) {
|
||||
// PHP v4.3.0+
|
||||
return image_type_to_mime_type($imagetype);
|
||||
}
|
||||
static $image_type_to_mime_type = array(
|
||||
1 => 'image/gif', // IMAGETYPE_GIF
|
||||
2 => 'image/jpeg', // IMAGETYPE_JPEG
|
||||
3 => 'image/png', // IMAGETYPE_PNG
|
||||
4 => 'application/x-shockwave-flash', // IMAGETYPE_SWF
|
||||
5 => 'image/psd', // IMAGETYPE_PSD
|
||||
6 => 'image/bmp', // IMAGETYPE_BMP
|
||||
7 => 'image/tiff', // IMAGETYPE_TIFF_II (intel byte order)
|
||||
8 => 'image/tiff', // IMAGETYPE_TIFF_MM (motorola byte order)
|
||||
9 => 'application/octet-stream', // IMAGETYPE_JPC
|
||||
10 => 'image/jp2', // IMAGETYPE_JP2
|
||||
11 => 'application/octet-stream', // IMAGETYPE_JPX
|
||||
12 => 'application/octet-stream', // IMAGETYPE_JB2
|
||||
13 => 'application/x-shockwave-flash', // IMAGETYPE_SWC
|
||||
14 => 'image/iff', // IMAGETYPE_IFF
|
||||
15 => 'image/vnd.wap.wbmp', // IMAGETYPE_WBMP
|
||||
16 => 'image/xbm', // IMAGETYPE_XBM
|
||||
|
||||
'gif' => 'image/gif', // IMAGETYPE_GIF
|
||||
'jpg' => 'image/jpeg', // IMAGETYPE_JPEG
|
||||
'jpeg' => 'image/jpeg', // IMAGETYPE_JPEG
|
||||
'png' => 'image/png', // IMAGETYPE_PNG
|
||||
'bmp' => 'image/bmp', // IMAGETYPE_BMP
|
||||
'ico' => 'image/x-icon',
|
||||
);
|
||||
|
||||
return (isset($image_type_to_mime_type[$imagetype]) ? $image_type_to_mime_type[$imagetype] : false);
|
||||
}
|
||||
|
||||
|
||||
function HexCharDisplay($string) {
|
||||
$len = strlen($string);
|
||||
$output = '';
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$output .= ' 0x'.str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
function IsHexColor($HexColorString) {
|
||||
return eregi('^[0-9A-F]{6}$', $HexColorString);
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
} else {
|
||||
return ImageColorAllocate($gdimg_hexcolorallocate, $R, $G, $B);
|
||||
}
|
||||
}
|
||||
|
||||
function ImageHexColorAllocate(&$gdimg_hexcolorallocate, $HexColorString, $dieOnInvalid=false, $alpha=false) {
|
||||
if (!is_resource($gdimg_hexcolorallocate)) {
|
||||
die('$gdimg_hexcolorallocate is not a GD resource in ImageHexColorAllocate()');
|
||||
}
|
||||
if (phpthumb_functions::IsHexColor($HexColorString)) {
|
||||
$R = hexdec(substr($HexColorString, 0, 2));
|
||||
$G = hexdec(substr($HexColorString, 2, 2));
|
||||
$B = hexdec(substr($HexColorString, 4, 2));
|
||||
return phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_hexcolorallocate, $R, $G, $B, $alpha);
|
||||
}
|
||||
if ($dieOnInvalid) {
|
||||
die('Invalid hex color string: "'.$HexColorString.'"');
|
||||
}
|
||||
return ImageColorAllocate($gdimg_hexcolorallocate, 0x00, 0x00, 0x00);
|
||||
}
|
||||
|
||||
|
||||
function HexColorXOR($hexcolor) {
|
||||
return strtoupper(str_pad(dechex(~hexdec($hexcolor) & 0xFFFFFF), 6, '0', STR_PAD_LEFT));
|
||||
}
|
||||
|
||||
|
||||
function GetPixelColor(&$img, $x, $y) {
|
||||
if (!is_resource($img)) {
|
||||
return false;
|
||||
}
|
||||
return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
|
||||
}
|
||||
|
||||
|
||||
function GrayscaleValue($r, $g, $b) {
|
||||
return round(($r * 0.30) + ($g * 0.59) + ($b * 0.11));
|
||||
}
|
||||
|
||||
|
||||
function GrayscalePixel($OriginalPixel) {
|
||||
$gray = phpthumb_functions::GrayscaleValue($OriginalPixel['red'], $OriginalPixel['green'], $OriginalPixel['blue']);
|
||||
return array('red'=>$gray, 'green'=>$gray, 'blue'=>$gray);
|
||||
}
|
||||
|
||||
|
||||
function GrayscalePixelRGB($rgb) {
|
||||
$r = ($rgb >> 16) & 0xFF;
|
||||
$g = ($rgb >> 8) & 0xFF;
|
||||
$b = $rgb & 0xFF;
|
||||
return ($r * 0.299) + ($g * 0.587) + ($b * 0.114);
|
||||
}
|
||||
|
||||
|
||||
function ImageCopyResampleBicubic($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {
|
||||
// ron at korving dot demon dot nl
|
||||
// http://www.php.net/imagecopyresampled
|
||||
|
||||
$scaleX = ($src_w - 1) / $dst_w;
|
||||
$scaleY = ($src_h - 1) / $dst_h;
|
||||
|
||||
$scaleX2 = $scaleX / 2.0;
|
||||
$scaleY2 = $scaleY / 2.0;
|
||||
|
||||
$isTrueColor = ImageIsTrueColor($src_img);
|
||||
|
||||
for ($y = $src_y; $y < $src_y + $dst_h; $y++) {
|
||||
$sY = $y * $scaleY;
|
||||
$siY = (int) $sY;
|
||||
$siY2 = (int) $sY + $scaleY2;
|
||||
|
||||
for ($x = $src_x; $x < $src_x + $dst_w; $x++) {
|
||||
$sX = $x * $scaleX;
|
||||
$siX = (int) $sX;
|
||||
$siX2 = (int) $sX + $scaleX2;
|
||||
|
||||
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);
|
||||
|
||||
$r = (( $c1 + $c2 + $c3 + $c4 ) >> 2) & 0xFF0000;
|
||||
$g = ((($c1 & 0x00FF00) + ($c2 & 0x00FF00) + ($c3 & 0x00FF00) + ($c4 & 0x00FF00)) >> 2) & 0x00FF00;
|
||||
$b = ((($c1 & 0x0000FF) + ($c2 & 0x0000FF) + ($c3 & 0x0000FF) + ($c4 & 0x0000FF)) >> 2);
|
||||
|
||||
} 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));
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function ImageCreateFunction($x_size, $y_size) {
|
||||
$ImageCreateFunction = 'ImageCreate';
|
||||
if (phpthumb_functions::gd_version() >= 2.0) {
|
||||
$ImageCreateFunction = 'ImageCreateTrueColor';
|
||||
}
|
||||
if (!function_exists($ImageCreateFunction)) {
|
||||
return phpthumb::ErrorImage($ImageCreateFunction.'() does not exist - no GD support?');
|
||||
}
|
||||
if (($x_size <= 0) || ($y_size <= 0)) {
|
||||
return phpthumb::ErrorImage('Invalid image dimensions: '.$ImageCreateFunction.'('.$x_size.', '.$y_size.')');
|
||||
}
|
||||
return $ImageCreateFunction($x_size, $y_size);
|
||||
}
|
||||
|
||||
|
||||
function ImageCopyRespectAlpha(&$dst_im, &$src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct=100) {
|
||||
for ($x = $src_x; $x < $src_w; $x++) {
|
||||
for ($y = $src_y; $y < $src_h; $y++) {
|
||||
$RealPixel = phpthumb_functions::GetPixelColor($dst_im, $dst_x + $x, $dst_y + $y);
|
||||
$OverlayPixel = phpthumb_functions::GetPixelColor($src_im, $x, $y);
|
||||
$alphapct = $OverlayPixel['alpha'] / 127;
|
||||
$opacipct = $pct / 100;
|
||||
$overlaypct = (1 - $alphapct) * $opacipct;
|
||||
|
||||
$newcolor = phpthumb_functions::ImageColorAllocateAlphaSafe(
|
||||
$dst_im,
|
||||
round($RealPixel['red'] * (1 - $overlaypct)) + ($OverlayPixel['red'] * $overlaypct),
|
||||
round($RealPixel['green'] * (1 - $overlaypct)) + ($OverlayPixel['green'] * $overlaypct),
|
||||
round($RealPixel['blue'] * (1 - $overlaypct)) + ($OverlayPixel['blue'] * $overlaypct),
|
||||
//$RealPixel['alpha']);
|
||||
0);
|
||||
|
||||
ImageSetPixel($dst_im, $dst_x + $x, $dst_y + $y, $newcolor);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function ProportionalResize($old_width, $old_height, $new_width=false, $new_height=false) {
|
||||
$old_aspect_ratio = $old_width / $old_height;
|
||||
if (($new_width === false) && ($new_height === false)) {
|
||||
return false;
|
||||
} elseif ($new_width === false) {
|
||||
$new_width = $new_height * $old_aspect_ratio;
|
||||
} elseif ($new_height === false) {
|
||||
$new_height = $new_width / $old_aspect_ratio;
|
||||
}
|
||||
$new_aspect_ratio = $new_width / $new_height;
|
||||
if ($new_aspect_ratio == $old_aspect_ratio) {
|
||||
// great, done
|
||||
} elseif ($new_aspect_ratio < $old_aspect_ratio) {
|
||||
// limited by width
|
||||
$new_height = $new_width / $old_aspect_ratio;
|
||||
} elseif ($new_aspect_ratio > $old_aspect_ratio) {
|
||||
// limited by height
|
||||
$new_width = $new_height * $old_aspect_ratio;
|
||||
}
|
||||
return array(round($new_width), round($new_height));
|
||||
}
|
||||
|
||||
|
||||
function SafeExec($command) {
|
||||
static $AllowedExecFunctions = array();
|
||||
if (empty($AllowedExecFunctions)) {
|
||||
$AllowedExecFunctions = array('shell_exec'=>true, 'passthru'=>true, 'system'=>true, 'exec'=>true);
|
||||
if (@ini_get('safe_mode')) {
|
||||
$AllowedExecFunctions['shell_exec'] = false;
|
||||
}
|
||||
$disable_functions = explode(',', @ini_get('disable_functions'));
|
||||
foreach ($AllowedExecFunctions as $key => $value) {
|
||||
if (in_array($key, $disable_functions)) {
|
||||
$AllowedExecFunctions[$key] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($AllowedExecFunctions as $execfunction => $is_allowed) {
|
||||
if (!$is_allowed) {
|
||||
continue;
|
||||
}
|
||||
if ($execfunction == 'passthru') {
|
||||
ob_start();
|
||||
$execfunction($command);
|
||||
$returnvalue = ob_get_contents();
|
||||
ob_end_clean();
|
||||
} else {
|
||||
$returnvalue = @$execfunction($command);
|
||||
}
|
||||
return $returnvalue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function ApacheLookupURIarray($filename) {
|
||||
// apache_lookup_uri() only works when PHP is installed as an Apache module.
|
||||
if (php_sapi_name() == 'apache') {
|
||||
$keys = array('status', 'the_request', 'status_line', 'method', 'content_type', 'handler', 'uri', 'filename', 'path_info', 'args', 'boundary', 'no_cache', 'no_local_copy', 'allowed', 'send_bodyct', 'bytes_sent', 'byterange', 'clength', 'unparsed_uri', 'mtime', 'request_time');
|
||||
if ($apacheLookupURIobject = @apache_lookup_uri($filename)) {
|
||||
$apacheLookupURIarray = array();
|
||||
foreach ($keys as $dummy => $key) {
|
||||
$apacheLookupURIarray[$key] = @$apacheLookupURIobject->$key;
|
||||
}
|
||||
return $apacheLookupURIarray;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function gd_is_bundled() {
|
||||
static $isbundled = null;
|
||||
if (is_null($isbundled)) {
|
||||
$gd_info = gd_info();
|
||||
$isbundled = (strpos($gd_info['GD Version'], 'bundled') !== false);
|
||||
}
|
||||
return $isbundled;
|
||||
}
|
||||
|
||||
|
||||
function gd_version($fullstring=false) {
|
||||
static $cache_gd_version = array();
|
||||
if (empty($cache_gd_version)) {
|
||||
$gd_info = gd_info();
|
||||
if (eregi('bundled \((.+)\)$', $gd_info['GD Version'], $matches)) {
|
||||
$cache_gd_version[1] = $gd_info['GD Version']; // e.g. "bundled (2.0.15 compatible)"
|
||||
$cache_gd_version[0] = (float) $matches[1]; // e.g. "2.0" (not "bundled (2.0.15 compatible)")
|
||||
} else {
|
||||
$cache_gd_version[1] = $gd_info['GD Version']; // e.g. "1.6.2 or higher"
|
||||
$cache_gd_version[0] = (float) substr($gd_info['GD Version'], 0, 3); // e.g. "1.6" (not "1.6.2 or higher")
|
||||
}
|
||||
}
|
||||
return $cache_gd_version[intval($fullstring)];
|
||||
}
|
||||
|
||||
|
||||
function gd_ImageSaveAlpha(&$img, $flag) {
|
||||
// requires PHP >= 4.3.2
|
||||
// requires GD >= 2.0.1
|
||||
if (function_exists('ImageSaveAlpha')) {
|
||||
return ImageSaveAlpha($img, $flag);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function filesize_remote($remotefile, $timeout=10) {
|
||||
$size = false;
|
||||
$url = parse_url($remotefile);
|
||||
if ($fp = @fsockopen($url['host'], ($url['port'] ? $url['port'] : 80), $errno, $errstr, $timeout)) {
|
||||
fwrite($fp, 'HEAD '.@$url['path'].@$url['query'].' HTTP/1.0'."\r\n".'Host: '.@$url['host']."\r\n\r\n");
|
||||
if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.0', '>=')) {
|
||||
stream_set_timeout($fp, $timeout);
|
||||
}
|
||||
while (!feof($fp)) {
|
||||
$headerline = fgets($fp, 4096);
|
||||
if (eregi('^Content-Length: (.*)', $headerline, $matches)) {
|
||||
$size = intval($matches[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose ($fp);
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
|
||||
|
||||
function filedate_remote($remotefile, $timeout=10) {
|
||||
$date = false;
|
||||
$url = parse_url($remotefile);
|
||||
if ($fp = @fsockopen($url['host'], ($url['port'] ? $url['port'] : 80), $errno, $errstr, $timeout)) {
|
||||
fwrite($fp, 'HEAD '.@$url['path'].@$url['query'].' HTTP/1.0'."\r\n".'Host: '.@$url['host']."\r\n\r\n");
|
||||
if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.0', '>=')) {
|
||||
stream_set_timeout($fp, $timeout);
|
||||
}
|
||||
while (!feof($fp)) {
|
||||
$headerline = fgets($fp, 4096);
|
||||
if (eregi('^Last-Modified: (.*)', $headerline, $matches)) {
|
||||
$date = strtotime($matches[1]) - date('Z');
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose ($fp);
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
|
||||
function md5_file_safe($filename) {
|
||||
// md5_file() doesn't exist in PHP < 4.2.0
|
||||
if (function_exists('md5_file')) {
|
||||
return md5_file($filename);
|
||||
}
|
||||
if ($fp = @fopen($filename, 'rb')) {
|
||||
$filedata = fread($fp, filesize($filename));
|
||||
fclose($fp);
|
||||
return md5($filedata);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function nonempty_min() {
|
||||
$arg_list = func_get_args();
|
||||
$acceptable = array();
|
||||
foreach ($arg_list as $dummy => $arg) {
|
||||
if ($arg) {
|
||||
$acceptable[] = $arg;
|
||||
}
|
||||
}
|
||||
return min($acceptable);
|
||||
}
|
||||
|
||||
|
||||
function LittleEndian2String($number, $minbytes=1) {
|
||||
$intstring = '';
|
||||
while ($number > 0) {
|
||||
$intstring = $intstring.chr($number & 255);
|
||||
$number >>= 8;
|
||||
}
|
||||
return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
|
||||
}
|
||||
|
||||
function OneOfThese() {
|
||||
// return the first useful (non-empty/non-zero/non-false) value from those passed
|
||||
$arg_list = func_get_args();
|
||||
foreach ($arg_list as $key => $value) {
|
||||
if ($value) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function SafeURLread($url, &$error) {
|
||||
if (function_exists('curl_version')) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
|
||||
$rawData = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if (strlen($rawData) > 0) {
|
||||
return $rawData;
|
||||
}
|
||||
$error .= 'CURL available but returned no data; ';
|
||||
} else {
|
||||
$error .= 'CURL unavailable; ';
|
||||
}
|
||||
if (@ini_get('allow_url_fopen')) {
|
||||
$rawData = '';
|
||||
ob_start();
|
||||
if ($fp = fopen($url, 'rb')) {
|
||||
do {
|
||||
$buffer = fread($fp, 8192);
|
||||
$rawData .= $buffer;
|
||||
} while (strlen($buffer) > 0);
|
||||
fclose($fp);
|
||||
} else {
|
||||
$error = trim(strip_tags(ob_get_contents()));
|
||||
}
|
||||
ob_end_clean();
|
||||
if (!$error) {
|
||||
return $rawData;
|
||||
}
|
||||
$error .= '; "allow_url_fopen" enabled but returned no data; ';
|
||||
} else {
|
||||
$error .= '"allow_url_fopen" disabled; ';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('gd_info')) {
|
||||
// built into PHP v4.3.0+ (with bundled GD2 library)
|
||||
function gd_info() {
|
||||
static $gd_info = array();
|
||||
if (empty($gd_info)) {
|
||||
// based on code by johnschaefer at gmx dot de
|
||||
// from PHP help on gd_info()
|
||||
$gd_info = array(
|
||||
'GD Version' => '',
|
||||
'FreeType Support' => false,
|
||||
'FreeType Linkage' => '',
|
||||
'T1Lib Support' => false,
|
||||
'GIF Read Support' => false,
|
||||
'GIF Create Support' => false,
|
||||
'JPG Support' => false,
|
||||
'PNG Support' => false,
|
||||
'WBMP Support' => false,
|
||||
'XBM Support' => false
|
||||
);
|
||||
$phpinfo_array = phpthumb_functions::phpinfo_array();
|
||||
foreach ($phpinfo_array as $dummy => $line) {
|
||||
$line = trim(strip_tags($line));
|
||||
foreach ($gd_info as $key => $value) {
|
||||
//if (strpos($line, $key) !== false) {
|
||||
if (strpos($line, $key) === 0) {
|
||||
$newvalue = trim(str_replace($key, '', $line));
|
||||
$gd_info[$key] = $newvalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($gd_info['GD Version'])) {
|
||||
// probable cause: "phpinfo() disabled for security reasons"
|
||||
if (function_exists('ImageTypes')) {
|
||||
$imagetypes = ImageTypes();
|
||||
if ($imagetypes & IMG_PNG) {
|
||||
$gd_info['PNG Support'] = true;
|
||||
}
|
||||
if ($imagetypes & IMG_GIF) {
|
||||
$gd_info['GIF Create Support'] = true;
|
||||
}
|
||||
if ($imagetypes & IMG_JPG) {
|
||||
$gd_info['JPG Support'] = true;
|
||||
}
|
||||
if ($imagetypes & IMG_WBMP) {
|
||||
$gd_info['WBMP Support'] = true;
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
}
|
||||
unlink($tempfilename);
|
||||
}
|
||||
}
|
||||
if (function_exists('ImageCreateTrueColor') && @ImageCreateTrueColor(1, 1)) {
|
||||
$gd_info['GD Version'] = '2.0.1 or higher (assumed)';
|
||||
} elseif (function_exists('ImageCreate') && @ImageCreate(1, 1)) {
|
||||
$gd_info['GD Version'] = '1.6.0 or higher (assumed)';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $gd_info;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('is_executable')) {
|
||||
// in PHP v3+, but v5.0+ for Windows
|
||||
function is_executable($filename) {
|
||||
// poor substitute, but better than nothing
|
||||
return file_exists($filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('file_get_contents')) {
|
||||
// included in PHP v4.3.0+
|
||||
function file_get_contents($filename) {
|
||||
if (eregi('^(f|ht)tp\://', $filename)) {
|
||||
return SafeURLread($filename);
|
||||
}
|
||||
if ($fp = @fopen($filename, 'rb')) {
|
||||
$buffer = fread($fp, filesize($filename));
|
||||
fclose($fp);
|
||||
return $buffer;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('file_put_contents')) {
|
||||
// included in PHP v5.0.0+
|
||||
function file_put_contents($filename, $filedata) {
|
||||
if ($fp = @fopen($filename, 'wb')) {
|
||||
fwrite($fp, $filedata);
|
||||
fclose($fp);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
1168
site/racecalendar/phpthumb/phpthumb.gif.php
Normal file
1168
site/racecalendar/phpthumb/phpthumb.gif.php
Normal file
File diff suppressed because it is too large
Load Diff
119
site/racecalendar/phpthumb/phpthumb.ico.php
Normal file
119
site/racecalendar/phpthumb/phpthumb.ico.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// phpThumb() by James Heinrich <info@silisoftware.com> //
|
||||
// available at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// //
|
||||
// phpthumb.ico.php - .ICO output format functions //
|
||||
// ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
class phpthumb_ico {
|
||||
|
||||
function phpthumb_ico() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function GD2ICOstring(&$gd_image_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);
|
||||
|
||||
$icXOR[$key] = '';
|
||||
for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
|
||||
for ($x = 0; $x < $ImageWidths[$key]; $x++) {
|
||||
$argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
|
||||
$a = round(255 * ((127 - $argb['alpha']) / 127));
|
||||
$r = $argb['red'];
|
||||
$g = $argb['green'];
|
||||
$b = $argb['blue'];
|
||||
|
||||
if ($bpp[$key] == 32) {
|
||||
$icXOR[$key] .= chr($b).chr($g).chr($r).chr($a);
|
||||
} elseif ($bpp[$key] == 24) {
|
||||
$icXOR[$key] .= chr($b).chr($g).chr($r);
|
||||
}
|
||||
|
||||
if ($a < 128) {
|
||||
@$icANDmask[$key][$y] .= '1';
|
||||
} else {
|
||||
@$icANDmask[$key][$y] .= '0';
|
||||
}
|
||||
}
|
||||
// mask bits are 32-bit aligned per scanline
|
||||
while (strlen($icANDmask[$key][$y]) % 32) {
|
||||
$icANDmask[$key][$y] .= '0';
|
||||
}
|
||||
}
|
||||
$icAND[$key] = '';
|
||||
foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
|
||||
for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
|
||||
$icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($gd_image_array as $key => $gd_image) {
|
||||
$biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
|
||||
|
||||
// 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] .= "\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;
|
||||
}
|
||||
|
||||
|
||||
$icondata = "\x00\x00"; // idReserved; // Reserved (must be 0)
|
||||
$icondata .= "\x01\x00"; // idType; // Resource Type (1 for icons)
|
||||
$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2); // idCount; // How many images?
|
||||
|
||||
$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)
|
||||
|
||||
$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 .= 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?
|
||||
$dwImageOffset += strlen($BitmapInfoHeader[$key]);
|
||||
$dwImageOffset += strlen($icXOR[$key]);
|
||||
$dwImageOffset += strlen($icAND[$key]);
|
||||
}
|
||||
|
||||
foreach ($gd_image_array as $key => $gd_image) {
|
||||
$icondata .= $BitmapInfoHeader[$key];
|
||||
$icondata .= $icXOR[$key];
|
||||
$icondata .= $icAND[$key];
|
||||
}
|
||||
|
||||
return $icondata;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
162
site/racecalendar/phpthumb/phpthumb.unsharp.php
Normal file
162
site/racecalendar/phpthumb/phpthumb.unsharp.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////
|
||||
//// ////
|
||||
//// p h p U n s h a r p M a s k ////
|
||||
//// ////
|
||||
//// Unsharp mask algorithm by Torstein H<>nsi 2003. ////
|
||||
//// thoensi_at_netcom_dot_no ////
|
||||
//// Please leave this notice. ////
|
||||
//// ////
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// From: http://vikjavev.no/hovudsida/umtestside.php //
|
||||
// //
|
||||
// Reformatted by James Heinrich <info@silisoftware.com> //
|
||||
// for use in phpThumb() on 3 February 2003. //
|
||||
// //
|
||||
// phpThumb() is found at http://phpthumb.sourceforge.net ///
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
WARNING! Due to a known bug in PHP 4.3.2 this script is not working well in this version.
|
||||
The sharpened images get too dark. The bug is fixed in version 4.3.3.
|
||||
|
||||
Unsharp masking is a traditional darkroom technique that has proven very suitable for
|
||||
digital imaging. The principle of unsharp masking is to create a blurred copy of the image
|
||||
and compare it to the underlying original. The difference in colour values
|
||||
between the two images is greatest for the pixels near sharp edges. When this
|
||||
difference is subtracted from the original image, the edges will be
|
||||
accentuated.
|
||||
|
||||
The Amount parameter simply says how much of the effect you want. 100 is 'normal'.
|
||||
Radius is the radius of the blurring circle of the mask. 'Threshold' is the least
|
||||
difference in colour values that is allowed between the original and the mask. In practice
|
||||
this means that low-contrast areas of the picture are left unrendered whereas edges
|
||||
are treated normally. This is good for pictures of e.g. skin or blue skies.
|
||||
|
||||
Any suggenstions for improvement of the algorithm, expecially regarding the speed
|
||||
and the roundoff errors in the Gaussian blur process, are welcome.
|
||||
*/
|
||||
|
||||
class phpUnsharpMask {
|
||||
|
||||
function applyUnsharpMask(&$img, $amount, $radius, $threshold) {
|
||||
|
||||
// $img is an image that is already created within php using
|
||||
// imgcreatetruecolor. No url! $img must be a truecolor image.
|
||||
|
||||
// Attempt to calibrate the parameters to Photoshop:
|
||||
$amount = min($amount, 500);
|
||||
$amount = $amount * 0.016;
|
||||
if ($amount == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$radius = min($radius, 50);
|
||||
$radius = $radius * 2;
|
||||
|
||||
$threshold = min($threshold, 255);
|
||||
|
||||
$radius = abs(round($radius)); // Only integers make sense.
|
||||
if ($radius == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$w = ImageSX($img);
|
||||
$h = ImageSY($img);
|
||||
$imgCanvas = ImageCreateTrueColor($w, $h);
|
||||
$imgCanvas2 = ImageCreateTrueColor($w, $h);
|
||||
ImageCopy($imgCanvas, $img, 0, 0, 0, 0, $w, $h);
|
||||
ImageCopy($imgCanvas2, $img, 0, 0, 0, 0, $w, $h);
|
||||
|
||||
|
||||
$builtinFilterSucceeded = false;
|
||||
if ($radius == 1) {
|
||||
if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
|
||||
if (ImageFilter($imgCanvas, IMG_FILTER_GAUSSIAN_BLUR) && ImageFilter($imgCanvas2, IMG_FILTER_GAUSSIAN_BLUR)) {
|
||||
$builtinFilterSucceeded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$builtinFilterSucceeded) {
|
||||
$imgBlur = ImageCreateTrueColor($w, $h);
|
||||
$imgBlur2 = ImageCreateTrueColor($w, $h);
|
||||
|
||||
///////////////////////////
|
||||
//
|
||||
// Gaussian blur matrix:
|
||||
// 1 2 1
|
||||
// 2 4 2
|
||||
// 1 2 1
|
||||
//
|
||||
///////////////////////////
|
||||
|
||||
// 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, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left
|
||||
ImageCopyMerge($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right
|
||||
ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left
|
||||
ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right
|
||||
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left
|
||||
ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right
|
||||
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up
|
||||
ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down
|
||||
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center
|
||||
ImageCopy ($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h);
|
||||
|
||||
// During the loop above the blurred copy darkens, possibly due to a roundoff
|
||||
// error. Therefore the sharp picture has to go through the same loop to
|
||||
// produce a similar image for comparison. This is not a good thing, as processing
|
||||
// time increases heavily.
|
||||
ImageCopy ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h);
|
||||
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
|
||||
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
|
||||
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
|
||||
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
|
||||
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
|
||||
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 20 );
|
||||
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 16.666667);
|
||||
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
|
||||
ImageCopy ($imgCanvas2, $imgBlur2, 0, 0, 0, 0, $w, $h);
|
||||
}
|
||||
ImageDestroy($imgBlur);
|
||||
ImageDestroy($imgBlur2);
|
||||
}
|
||||
|
||||
// Calculate the difference between the blurred pixels and the original
|
||||
// and set the pixels
|
||||
for ($x = 0; $x < $w; $x++) { // each row
|
||||
for ($y = 0; $y < $h; $y++) { // each pixel
|
||||
|
||||
$rgbOrig = ImageColorAt($imgCanvas2, $x, $y);
|
||||
$rOrig = (($rgbOrig >> 16) & 0xFF);
|
||||
$gOrig = (($rgbOrig >> 8) & 0xFF);
|
||||
$bOrig = ($rgbOrig & 0xFF);
|
||||
|
||||
$rgbBlur = ImageColorAt($imgCanvas, $x, $y);
|
||||
$rBlur = (($rgbBlur >> 16) & 0xFF);
|
||||
$gBlur = (($rgbBlur >> 8) & 0xFF);
|
||||
$bBlur = ($rgbBlur & 0xFF);
|
||||
|
||||
// When the masked pixels differ less from the original
|
||||
// than the threshold specifies, they are set to their original value.
|
||||
$rNew = (abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig;
|
||||
$gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig;
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImageDestroy($imgCanvas);
|
||||
ImageDestroy($imgCanvas2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user