サムネイルを生成するために見つかったスクリプトを使用していますが、3行目と4行目の最初にエラーが発生しています。機能の1つが廃止予定です(それは一歳ですが)、私は本当に分かりません。 GDサポートが有効になっています。私はリンクされた質問を読んでいると私は約isset
について取得していない何かが実現しているが、私は両方の 'イメージ'と '幅'のためにこれを書く方法はわからない、それはまた、ライン。すべての助けに感謝します。サムネイル生成スクリプトの最初の行で未定義のインデックス
Notice: Undefined index: image in C:\xampp\htdocs\thumbnail\thumbnail.php on line 3
Notice: Undefined index: width in C:\xampp\htdocs\thumbnail\thumbnail.php on line 4
<?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);
}
?>
私はすべてのページのロードのためのオンザフライで生成するスクリプトを実現し、効率的ではありませんが、私はちょうど働く何かを取得しようとしています。
私はローレンスによって提案された第三変更を行ったし、私はまだエラーを取得しています:
Notice: Undefined variable: width in C:\xampp\htdocs\thumbnail\thumbnail.php on line 13
これは、クエリパラメータなしでスクリプトを呼び出すことを意味します。 'http://example.com/script.php?image = X&width = Y'の代わりに' http:// example.com/script.php'を入力してください。 –