サムネイルを作成してどこかに保存せずにウェブサイトにプリントするこのコードはあります。サムネイルを保存せずに作成
<img src ="imageThumbnail.php" alt="some description"/>
これは私がこれを行ったときにうまく動作し、出力が表示されました。
imageThumbnail.php
header("Content-type: image/png");
$im = imagecreatefrompng("image.png");
list($width, $height) = getimagesize($im);
$newimage = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($newimage, $im, 0, 0, 0, 0, "100", "100", $width, $height);
imagepng($newimage);
imagedestroy($newimage);
imagedestroy($im);
このコードは、今私が望んでここにcreating thumbnails without saving them
から撮影されたこのimageThumbnail
のphpファイルにいくつかのデータを送信し、データベースにクエリを作成し、正しいを取得するということでしたgetとして渡された特定のデータのパス。出力は期待通りではなく、イメージは表示されません。
Html code
<img src ="imageThumbnail.php?product_code=PD1001" alt="some description"/>
imageThumbnail.php
This is the modified code
header("Content-type: image/jpeg");
$productCode=$_GET['product_code'];
require 'connect.inc.php';
$statement=$mysqli->prepare("select `product_img_name` from `products` where `product_code`=?");
$statement->bind_param("s",$productCode);
$statement->execute();
$result=$statement->get_result();
while($row=$result->fetch_object())
$pathName=$row->product_img_name;
$im=imagecreatefromjpeg("cart/images/".$pathName);
$width=imagesx($im);
$height=imagesy($im);
$newimage=imagecreatetruecolor(116,116);
imagecopyresampled($newimage, $im, 0, 0, 0, 0,'116', '116', $width, $height);
imagejpeg($newimage);
imagedestroy($newimage);
imagedestroy($im);
問題とどのように私はこれを達成んとは何ですか?
私たちは本当にあなたの質問に答えるためにそのコードのすべてを必要ですか? – m02ph3u5
ええ、これはすべて重要で、私の質問に関連していると思います。 @ m02ph3u5 – Mitali
@ m02ph3u5非常に少ないコードで私の質問を更新しました – Mitali