サムネイルを生成するために見つけたスクリプトを使用していますが、3行目と4行目の最初のエラーが発生しています。関数の1つが非推奨になっていると思います(1年前です)が、実際にはありませんアイディア。GDサポートが有効になっています。リンクされた質問を読んでいてisset
、うまくいかないことがあることに気づきましたが、「画像」と「幅」の両方にこれを書く方法がわかりません。次の数行で設定されているようです。 。すべての助けに感謝します。
注意:未定義のインデックス:3行目のC:\ xampp \ htdocs \ thumbnail\thumbnail.phpの画像
注意:未定義のインデックス:4行目のC:\ xampp \ htdocs \ thumbnail\thumbnail.phpの幅
<?php
$imageSrc = (string)$_GET['image'];
$width = $_GET['width'];
if (is_numeric($width) && isset($imageSrc)){
header('Content-type: image/jpeg');
makeThumb($imageSrc, $width);
}
function makeThumb($src,$newWidth) {
// read the source image given
$srcImage = imagecreatefromjpeg($src);
$width = imagesx($srcImage);
$height = imagesy($srcImage);
// find the height of the thumb based on the width given
$newHeight = floor($height*($newWidth/$width));
// create a new blank image
$newImage = imagecreatetruecolor($newWidth,$newHeight);
// copy source image to a new size
imagecopyresized($newImage,$srcImage,0,0,0,0,$newWidth,$newHeight,$width,$height);
// create the thumbnail
imagejpeg($newImage);
}
?>
ページを読み込むたびにその場でスクリプトを生成するのは効率的ではないことに気づきましたが、何かを機能させようとしているだけです。
ローレンスによって提案された3番目の変更を行いましたが、まだエラーが発生しています。
注意:未定義の変数:13行目のC:\ xampp \ htdocs \ thumbnail\thumbnail.phpの幅