Lid |
|
Op internet heb ik een stukje code gevonden om images te wijzigen in thumbnails
<?php
$nWidth = imagesx($oSourceImage); // get original source image width
$nHeight = imagesy($oSourceImage); // and height
// create small thumbnail
$nDestinationWidth = 80;
$nDestinationHeight = 60;
//$oDestinationImage = imagecreatetruecolor($nDestinationWidth, $nDestinationHeight);
$oDestinationImage = imagecreate($nDestinationWidth, $nDestinationHeight);
/*$oResult = imagecopyresampled(
$oDestinationImage, $oSourceImage,
0, 0, 0, 0,
$nDestinationWidth, $nDestinationHeight,
$nWidth, $nHeight); // resize the image
*/
imagecopyresized(
$oDestinationImage, $oSourceImage,
0, 0, 0, 0,
$nDestinationWidth, $nDestinationHeight,
$nWidth, $nHeight); // resize the image
ob_start(); // Start capturing stdout.
imageJPEG($oDestinationImage); // As though output to browser.
$sBinaryThumbnail = ob_get_contents(); // the raw jpeg image data.
ob_end_clean(); // Dump the result so it does not screw other output.
?>
<?php $nWidth = imagesx($oSourceImage); // get original source image width $nHeight = imagesy($oSourceImage); // and height // create small thumbnail $nDestinationWidth = 80; $nDestinationHeight = 60; //$oDestinationImage = imagecreatetruecolor($nDestinationWidth, $nDestinationHeight); $oDestinationImage = imagecreate($nDestinationWidth, $nDestinationHeight); /*$oResult = imagecopyresampled( $oDestinationImage, $oSourceImage, 0, 0, 0, 0, $nDestinationWidth, $nDestinationHeight, $nWidth, $nHeight); // resize the image */ imagecopyresized( $oDestinationImage, $oSourceImage, 0, 0, 0, 0, $nDestinationWidth, $nDestinationHeight, $nWidth, $nHeight); // resize the image imageJPEG($oDestinationImage); // As though output to browser. ob_end_clean(); // Dump the result so it does not screw other output. ?>
Ik krijg bij het draaien van deze code de volgende foutmelding.
Warning: imagesx(): supplied argument is not a valid Image resource in .....
Warning: imagesy(): supplied argument is not a valid Image resource in ......
Warning: imagecopyresized(): supplied argument is not a valid Image resource in ......
Hoe los ik dit op?
|