<?php
$Src = "6.jpg";
$newWidth = 120;
$newHeight = 120;
Header('Content-type: image/jpeg');
$Thumb = ImageCreateTrueColor($newWidth, $newHeight);
$Source = ImageCreateFromJpeg($Src);
List($Width, $Height) = GetImageSize($Src);
ImageCopyResized($Thumb, $Source, 0, 0, 0, 0, $newWidth, $newHeight, $Width, $Height);
ImageJpeg($Thumb);
?>
<?php
$Src = "6.jpg";
$newWidth = 120;
$newHeight = 120;
Header('Content-type: image/jpeg');
$Thumb = ImageCreateTrueColor($newWidth, $newHeight);
$Source = ImageCreateFromJpeg($Src);
List($Width, $Height) = GetImageSize($Src);
ImageCopyResized($Thumb, $Source, 0, 0, 0, 0, $newWidth, $newHeight, $Width, $Height);
ImageJpeg($Thumb, "folan/bahman.jpg");
?>
<?php
$Src = "6.jpg";
$newWidth = 120;
$newHeight = 120;
Header('Content-type: image/jpeg');
$Thumb = ImageCreateTrueColor($newWidth, $newHeight);
$Source = ImageCreateFromJpeg($Src);
List($Width, $Height) = GetImageSize($Src);
ImageCopyResized($Thumb, $Source, 0, 0, 0, 0, $newWidth, $newHeight, $Width, $Height);
ImageJpeg($Thumb, "folan/bahman.jpg");
$sql="insert into tb (pic)values('folan/bahman.jpg')";
?>
[code/]
ببینید کد اینسرت درسته بعدش اولش یک فایل 6.jpg معرفی کردی بعد یک فایل felanbaman.jpg جریان چی ؟
<?php
// The file
$filename = 'test.jpg';
// Set a maximum height and width
$width = 200;
$height = 200;
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
imagejpeg($image_p, null, 100);
?>