Hi,
I am working on a simple gallery and want to add thumbnails on the fly. My service provider hasn't installed the GD library yet so I have written a very simple function that uses NetPBM.
function thumbnail($file){
$jpegtopnm = realpath("whlib/netpbm/jpegtopnm");
$pnmscale = realpath("whlib/netpbm/pnmscale");
$pnmtojpeg = realpath("whlib/netpbm/pnmtojpeg");
$size = "100";
passthru("$jpegtopnm $file | $pnmscale -height $size| $pnmtojpeg");
}
the function works fine and displays the image when called as the only item in the script eg.
<?PHP
function thumbnail($file){
$jpegtopnm = realpath("whlib/netpbm/jpegtopnm");
$pnmscale = realpath("whlib/netpbm/pnmscale");
$pnmtojpeg = realpath("whlib/netpbm/pnmtojpeg");
$size = "100";
passthru("$jpegtopnm $file | $pnmscale -height $size| $pnmtojpeg");
}
thumbnail("somepic.jpg");
?>
However if I add other items to the script I get the raw output of the image file rather than the thumbnail picture. eg.
<?PHP
function thumbnail($file){
$jpegtopnm = realpath("whlib/netpbm/jpegtopnm");
$pnmscale = realpath("whlib/netpbm/pnmscale");
$pnmtojpeg = realpath("whlib/netpbm/pnmtojpeg");
$size = "100";
passthru("$jpegtopnm $file | $pnmscale -height $size| $pnmtojpeg");
}
echo "<a href=somplace.php>";
thumbnail("somepic.jpg");
echo "</a>";
?>
Why is this happening and how do I fix it?
Thanks,
Malcolm 🙁