| 1 |
<?php |
|---|
| 2 |
$GDversion['string'] = 'unknown'; |
|---|
| 3 |
$GDversion['numeric'] = 0; |
|---|
| 4 |
if (!@include_once('phpthumb.functions.php')) { |
|---|
| 5 |
die('failed to open "phpthumb.functions.php"'); |
|---|
| 6 |
} |
|---|
| 7 |
if (include_once('phpthumb.class.php')) { |
|---|
| 8 |
$phpThumb = new phpThumb(); |
|---|
| 9 |
$phpthumb_version = $phpThumb->phpthumb_version; |
|---|
| 10 |
unset($phpThumb); |
|---|
| 11 |
$GDversion['string'] = phpthumb_functions::gd_version(true); |
|---|
| 12 |
$GDversion['numeric'] = phpthumb_functions::gd_version(false); |
|---|
| 13 |
} else { |
|---|
| 14 |
die('failed to open "phpthumb.class.php"'); |
|---|
| 15 |
} |
|---|
| 16 |
?> |
|---|
| 17 |
|
|---|
| 18 |
<html> |
|---|
| 19 |
<head> |
|---|
| 20 |
<title>Demo of phpThumb() - thumbnails created by PHP</title> |
|---|
| 21 |
<link rel="stylesheet" type="text/css" href="/style.css" title="style sheet"> |
|---|
| 22 |
</head> |
|---|
| 23 |
<body bgcolor="#C5C5C5"> |
|---|
| 24 |
|
|---|
| 25 |
This is a demo of <a href="http://phpthumb.sourceforge.net"><b>phpThumb()</b></a> (current version: v<?php echo @$phpthumb_version; ?>)<br> |
|---|
| 26 |
A dynamic demo where you can set <strike>all</strike> some of the parmeters and see their effect is <a href="phpThumb.demo.demo2.php">here</a>.<br> |
|---|
| 27 |
<br> |
|---|
| 28 |
<!-- |
|---|
| 29 |
<b>Note:</b> none of the images on this page are cached, so they may take a few seconds to load, but they represent the actual script in action.<br> |
|---|
| 30 |
<br> |
|---|
| 31 |
--> |
|---|
| 32 |
<b>Note:</b> this server is working on GD "<?php |
|---|
| 33 |
echo $GDversion['string'].'"'; |
|---|
| 34 |
if ($GDversion['numeric'] >= 2) { |
|---|
| 35 |
echo ', so images should be of optimal quality.'; |
|---|
| 36 |
} else { |
|---|
| 37 |
echo ', so images (especially watermarks) do not look as good as they would on GD v2. <blockquote><b>A static demo of what this page should look like can be seen <a href="static.html">here</a>.</b></blockquote>'; |
|---|
| 38 |
} |
|---|
| 39 |
?><br> |
|---|
| 40 |
<br> |
|---|
| 41 |
<table border="5" cellspacing="0" cellpadding="3" width="500"> |
|---|
| 42 |
<tr> |
|---|
| 43 |
<td colspan="4"> |
|---|
| 44 |
<b>Illustration of potential difference between GD1.x and GD2.x</b><br> |
|---|
| 45 |
In most cases the thumbnails produced by phpThumb() on GD v1.x are perfectly |
|---|
| 46 |
acceptable, but in some cases it may look ugly. Diagonal lines and reducing a |
|---|
| 47 |
very large source image increase chance for bad results (the house/sky picture |
|---|
| 48 |
has both problems). Here are three static examples: |
|---|
| 49 |
</td> |
|---|
| 50 |
</tr> |
|---|
| 51 |
<tr> |
|---|
| 52 |
<td><b>GD v2.0.15</b></td> |
|---|
| 53 |
<td><img src="PHP-GD2-kayak.jpg" width="200" height="133" border="0" alt="kayak.jpg generated with phpThumb() on GD v2.0.15"></td> |
|---|
| 54 |
<td><img src="PHP-GD2-bottle.jpg" width="100" height="152" border="0" alt="bottle.jpg generated with phpThumb() on GD v2.0.15"></td> |
|---|
| 55 |
<td><img src="PHP-GD2-sky.jpg" width="200" height="150" border="0" alt="sky.jpg generated with phpThumb() on GD v2.0.15"></td> |
|---|
| 56 |
</tr> |
|---|
| 57 |
<tr> |
|---|
| 58 |
<td><b>GD v1.6.2</b></td> |
|---|
| 59 |
<td><img src="PHP-GD1-kayak.jpg" width="200" height="133" border="0" alt="kayak.jpg generated with phpThumb() on GD v1.6.2"></td> |
|---|
| 60 |
<td><img src="PHP-GD1-bottle.jpg" width="100" height="152" border="0" alt="bottle.jpg generated with phpThumb() on GD v1.6.2"></td> |
|---|
| 61 |
<td><img src="PHP-GD1-sky.jpg" width="200" height="150" border="0" alt="sky.jpg generated with phpThumb() on GD v1.6.2"></td> |
|---|
| 62 |
</tr> |
|---|
| 63 |
</table> |
|---|
| 64 |
|
|---|
| 65 |
<hr size="1"> |
|---|
| 66 |
<a href="#showpic">phpThumb.demo.showpic.php demo here</a><br> |
|---|
| 67 |
<hr size="1"> |
|---|
| 68 |
<table border="5" align="center" width="500" cellpadding="5"><tr><td> |
|---|
| 69 |
<b>The following images have the textured background behind them to illustrate transparency effects. |
|---|
| 70 |
Note that some browsers, notably Internet Explorer, are incapable of displaying alpha-channel PNGs. |
|---|
| 71 |
See my page on the <a href="http://www.silisoftware.com/png_alpha_transparency/" target="_blank">PNG transparency problem</a>. |
|---|
| 72 |
Other modern browsers such as <a href="http://www.mozilla.org">Mozilla/Firefox</a> display alpha-transparent PNGs with no problems.</b> |
|---|
| 73 |
</td></tr></table><br> |
|---|
| 74 |
|
|---|
| 75 |
<!-- |
|---|
| 76 |
<xmp><img src="disk.jpg"></xmp> |
|---|
| 77 |
Original image (not thumbnailed) - original dimensions = 500x500px<br> |
|---|
| 78 |
<img border="0" src="disk.jpg"><br> |
|---|
| 79 |
<br> |
|---|
| 80 |
<hr size="1"> |
|---|
| 81 |
--> |
|---|
| 82 |
|
|---|
| 83 |
<?php |
|---|
| 84 |
|
|---|
| 85 |
$img_square = 'disk.jpg'; |
|---|
| 86 |
$img_landscape = 'loco.jpg'; |
|---|
| 87 |
$img_portrait = 'pineapple.jpg'; |
|---|
| 88 |
$img_unrotated = 'monkey.jpg'; |
|---|
| 89 |
$img_watermark = 'watermark.png'; |
|---|
| 90 |
$img_levels = 'bunnies.jpg'; |
|---|
| 91 |
|
|---|
| 92 |
$png_alpha = 'Note: PNG 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'; |
|---|
| 93 |
$only_gd2 = '<br>(only works with GD v2.0+, this server is running GD "<i>'.$GDversion['string'].'</i>" so it <b>will '.(($GDversion['numeric'] >= 2) ? '' : 'not').'</b> work'; |
|---|
| 94 |
$only_php42 = '<br>(only works with PHP v4.2.0+, this server is running PHP v'.phpversion().' so it <b>will '.(version_compare(phpversion(), '4.2.0', '>=') ? '' : 'not').'</b> work)'; |
|---|
| 95 |
|
|---|
| 96 |
echo 'The source images, without manipulation:<ul>'; |
|---|
| 97 |
echo '<li><a href="'.$img_square.'">'.$img_square.'</a></li>'; |
|---|
| 98 |
echo '<li><a href="'.$img_landscape.'">'.$img_landscape.'</a></li>'; |
|---|
| 99 |
echo '<li><a href="'.$img_portrait.'">'.$img_portrait.'</a></li>'; |
|---|
| 100 |
echo '</ul><hr>'; |
|---|
| 101 |
|
|---|
| 102 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_square.'&w=200'), 'description' => 'width=200px'); |
|---|
| 103 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_square.'&w=200&q=10'), 'description' => 'width=200px, JPEGquality=10%'); |
|---|
| 104 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_square.'&w=200&f=png'), 'description' => 'width=200px, format=PNG'); |
|---|
| 105 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_square.'&w=800&aoe=1'), 'description' => 'width=800px, AllowOutputEnlargement enabled'); |
|---|
| 106 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_square.'&w=250&sx=125&sy=140&sw=130&sh=65&aoe=1'), 'description' => 'section from (125x140 - 255x190) cropped and enlarged by 200%, AllowOutputEnlargement enabled'); |
|---|
| 107 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_square.'&w=200&fltr[]=wmi|'.$img_watermark.'|BL'), 'description' => 'width=200px, watermark (bottom-left, 75% opacity)'); |
|---|
| 108 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_square.'&w=200&fltr[]=wmi|'.$img_watermark.'|*|25'), 'description' => 'width=200px, watermark (tiled, 25% opacity)'); |
|---|
| 109 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_watermark.'&bg=00FFFF&f=png', 'phpThumb.php?src='.$img_watermark.'&bg=00FFFF&f=jpeg'), 'description' => 'source image (GIF) transpancy with transparent output (PNG) vs. specified background color (JPEG)'); |
|---|
| 110 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=usm|80|0.5|3'), 'description' => 'normal vs. unsharp masking at default settings'.$only_gd2); |
|---|
| 111 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=blur|1', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=blur|5'), 'description' => 'normal vs. blur at default (1) and heavy (5)'.$only_gd2); |
|---|
| 112 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_portrait.'&w=100&h=100&far=1&fltr[]=bord|3|0|0|FF0000&bg=0000FF&f=png'), 'description' => '3px red border, fixed-size thumbnail despite aspect ratio, blue background, PNG output'); |
|---|
| 113 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_portrait.'&w=150&ar=L', 'phpThumb.php?src='.$img_landscape.'&w=150&ar=L'), 'description' => 'auto-rotate counter-clockwise to landscape from portrait & lanscape'.$only_php42); |
|---|
| 114 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_unrotated.'&w=150&h=150', 'phpThumb.php?src='.$img_unrotated.'&w=150&h=150&ar=x'), 'description' => 'original image vs. auto-rotated based on EXIF data'.$only_php42); |
|---|
| 115 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&ra=30&bg=0000FF', 'phpThumb.php?src='.$img_landscape.'&w=200&ra=30&f=png'), 'description' => 'Rotated 30° (counter-clockwise), width=200px, blue background vs. transparent background'.$only_php42); |
|---|
| 116 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&h=300&far=1&bg=CCCCCC', 'phpThumb.php?src='.$img_landscape.'&w=200&h=300&iar=1'), 'description' => 'Normal resize behavior (left) vs. Forced non-proportional resize (right)'); |
|---|
| 117 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=150&h=150&zc=1', 'phpThumb.php?src='.$img_portrait.'&w=150&h=150&zc=1'), 'description' => 'Zoom-Crop'); |
|---|
| 118 |
$Examples[] = array('getstrings' => array('phpThumb.php?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)'); |
|---|
| 119 |
$Examples[] = array('getstrings' => array('phpThumb.php?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); |
|---|
| 120 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=ds|75', 'phpThumb.php?src='.$img_landscape.'&w=200', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=ds|-100'), 'description' => 'desaturated 75% vs. normal vs. boosted saturation 100%'.$only_gd2); |
|---|
| 121 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=clr|25|00FF00'), 'description' => 'colorized 25% to green (#00FF00)'.$only_gd2); |
|---|
| 122 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=gray', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=sep'), 'description' => 'grayscale vs. sepia'.$only_gd2); |
|---|
| 123 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=gam|0.6', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=gam|1.6'), 'description' => 'Gamma corrected to 0.8 vs. 1.6'); |
|---|
| 124 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=mask|mask06.png&f=png', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=mask|mask04.png&f=png', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=mask|mask05.png&f=jpeg&bg=9900CC&q=100'), 'description' => 'Assorted alpha masks (seen below) applied<br>'.$png_alpha.'<br>JPEG/GIF output is flattened to "bg" background color'.$only_gd2.'<br><img src="mask06.png"> <img src="mask04.png"> <img src="mask05.png">'); |
|---|
| 125 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=drop|5|10|000000|225&f=png', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=mask|mask06.png&fltr[]=drop|5|10|000000|225&f=png', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=drop|5|10|000000|225&fltr[]=elip&f=png', 'phpThumb.php?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.'); |
|---|
| 126 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=elip&f=png', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=elip&f=jpeg&bg=00FFFF'), 'description' => 'Elipse<br>'.$png_alpha.'<br>JPEG/GIF output is flattened to "bg" background color'.$only_gd2); |
|---|
| 127 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=flip|x', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=flip|y', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=flip|xy'), 'description' => 'flipped on X, Y and X+Y axes'); |
|---|
| 128 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=bvl|10|FFFFFF|000000', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=bvl|10|000000|FFFFFF'), 'description' => '10px bevel edge filter'); |
|---|
| 129 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=fram|3|2|CCCCCC|FFFFFF|000000', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=fram|3|2|CC9966|333333|CCCCCC'), 'description' => '3+2px frame filter'); |
|---|
| 130 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=neg'), 'description' => 'Negative filter (inverted color)'); |
|---|
| 131 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=th|105', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=mask|mask04.png&fltr[]=th|105&f=png'), 'description' => 'Threshold filter; showing preserved alpha channel'); |
|---|
| 132 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_levels.'&w=200', 'phpThumb.php?src='.$img_levels.'&w=200&fltr[]=lvl'), 'description' => 'original vs. Levels filter (default settings)'); |
|---|
| 133 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=300&fltr[]=hist|rgb', 'phpThumb.php?src='.$img_levels.'&w=200&fltr[]=hist|*'), 'description' => 'histograms of RGB vs grayscale'); |
|---|
| 134 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_portrait.'&w=200&fltr[]=over|frame1.png|0', 'phpThumb.php?src='.$img_portrait.'&w=200&fltr[]=over|frame2.png|1'), 'description' => 'Overlay vs. Underlay<br><br>Original over/under images:<br><table border="0"><tr><td style="padding: 20px; background-image: url(lrock011.jpg);"><img src="frame1.png"> <img src="frame2.png"></td></tr></table>'); |
|---|
| 135 |
$Examples[] = array('getstrings' => array('phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=wmt|phpThumb|18|B|FF0000|loki.ttf|100|5|20&f=png', 'phpThumb.php?src='.$img_landscape.'&w=200&fltr[]=wmt|copyright+2004|3|BR|00FFFF||50&f=png'), 'description' => 'Text overlay, TTF and built-in fonts'); |
|---|
| 136 |
$Examples[] = array('getstrings' => array('phpThumb.php?new=FF0000&w=100&h=50&fltr[]=bvl|10&fltr[]=wmt|hello|14|C|00FFFF|arial.ttf&f=png', 'phpThumb.php?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'); |
|---|
| 137 |
|
|---|
| 138 |
$Examples[] = array('getstrings' => array('phpThumb.php?src=winnt.bmp&w=200'), 'description' => 'BMP source, width=200px'); |
|---|
| 139 |
$Examples[] = array('getstrings' => array('phpThumb.php?src=1024-none.tiff&w=200'), 'description' => 'TIFF source, width=200px'); |
|---|
| 140 |
$Examples[] = array('getstrings' => array('phpThumb.php?src=globe.wmf&w=200'), 'description' => 'WMF source, width=200px'); |
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
foreach ($Examples as $key => $ExamplesArray) { |
|---|
| 144 |
echo '<a href="#" name="'.$key.'" title="click to get URL link for example #'.$key.'" onClick="prompt(\'Here is the to example #'.$key.'\', \'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'#'.$key.'\'); return false;">#</a>'; |
|---|
| 145 |
echo '<table border="0"><tr><td style="padding: 20px; background-image: url(lrock011.jpg);">'; |
|---|
| 146 |
foreach ($ExamplesArray['getstrings'] as $GETstring) { |
|---|
| 147 |
echo '<a href="'.$GETstring.'&down='.urlencode($GETstring).'.jpg">'; |
|---|
| 148 |
echo '<img border="0" src="'.$GETstring.'">'; |
|---|
| 149 |
echo '</a> '; |
|---|
| 150 |
} |
|---|
| 151 |
echo '</td></tr></table>'; |
|---|
| 152 |
echo '<xmp><img src="'.implode('">'."\n".'<img src="', $ExamplesArray['getstrings']).'"></xmp>'; |
|---|
| 153 |
echo $ExamplesArray['description'].'<br>'; |
|---|
| 154 |
echo '<br><br><hr size="1">'; |
|---|
| 155 |
} |
|---|
| 156 |
?> |
|---|
| 157 |
|
|---|
| 158 |
<a name="showpic"></a> |
|---|
| 159 |
<b>Demo of <i>phpThumb.demo.showpic.php</i></b><br> |
|---|
| 160 |
<br> |
|---|
| 161 |
Small picture (500x333), window opened at wrong size (640x480):<br> |
|---|
| 162 |
<a href="javascript:void(0);" onClick="window.open('phpThumb.demo.showpic.php?src=kayak.jpg&title=This+is+a+small+picture', 'showpic1', 'width=640,height=480,resizable=no,status=no,menubar=no,toolbar=no,scrollbars=no');"> |
|---|
| 163 |
<img src="phpThumb.php?src=kayak.jpg&w=100" border="2"></a><br> |
|---|
| 164 |
<br> |
|---|
| 165 |
Big picture (2272x1704), window opened at wrong size (640x480):<br> |
|---|
| 166 |
<a href="javascript:void(0);" onClick="window.open('phpThumb.demo.showpic.php?src=big.jpg&title=This+is+a+big+picture', 'showpic2', 'width=640,height=480,resizable=yes,status=no,menubar=no,toolbar=no,scrollbars=no');"> |
|---|
| 167 |
<img src="phpThumb.php?src=big.jpg&w=100" border="2"></a><br> |
|---|
| 168 |
<br> |
|---|
| 169 |
|
|---|
| 170 |
</body> |
|---|
| 171 |
</html> |
|---|