imagepng(); outputs the data to the standard output buffer, when used in a a simple php file, the browser will only read the imagepng(); output and determine by the header that it is an image. When you have use it in a text however, it will have read the header as it being a text, and thus read the image as a textfile and not an image
Solve this by creating a PHP-script for accessing your files, such as this
- Code: Select all
<?php
if(isset($_GET['img'])) {
$img = $_GET['img'];
image($img);
}
else return;
function image($filename) {
$path=/home/foo/bar/php //path to the script, without trailing slash , I usually get it from a 'config.php'
$file = $filename;
if(!is_readable($file)) return;
$type = getimagesize($file);
if($type[2]!=3) return;
else {
$src_img = imagecreatefrompng("$path/$file");
imagepng($src_img);
imagedestroy($src_img);
return;
}
?>
now all you have to do is call the image script (image.php or whatever)
and add ?img=[path to file]
And no, there is no noticable difference between using php to create the thumbnail and showing pre-made thumbnails, unless you're on a slow server
EDIT: hmm...copy-paste is not well if you want nice indenting -_-


