Resizing an image (dynamic)
| From: | Lauri Vain | Date: | Sun, 03 Dec 2000 08:03:04 +0000 |
| Subject: | Resizing an image (dynamic) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-28411@lists.php.net to get a copy of this message | ||
Hello,
I have to resize an image to reduce the loading time (there will be thumbnails,
which have to be resized, and there will be full sized images).
Now, the images that will be inserted into the DB have the dimensions height=300
and width=400. The dimensions for the thumbnail have to be 4 times smaller.
/************ code to show images **************/
<?if (!isset($id) || empty($id)) {
echo "Looking for images ?";
} else {
$mysqlhost = "localhost";
$mysqluser = "**********";
$mysqlpassword = "*******************";
mysql_connect($mysqlhost, $mysqluser, $mysqlpassword) or die
($mysql_db_connect_error);
$pilt_q = mysql_db_query(DBname,"SELECT pilt,tyyp FROM pildid WHERE
idep='$id'");
$pilt_k = mysql_fetch_array($pilt_q);
Header("Content-Type: image/pjpeg");
print($pilt_k["pilt"]);
}?>
/************ end code to show images **************/
/************ code to insert images **************/
if (!empty($pilt) && strlen($pilt)>6) {
$size = GetImageSize ("$pilt");
$fd = fopen($pilt, "r");
echo "pildi suurus $size[0], $size[1], id=$id";
$piltdata = addslashes(fread($fd, filesize($pilt)));
fclose($fd);
mysql_db_query(DBname,"INSERT INTO pildid (tyyp, pilt) VALUES
('$pilt_type','$piltdata')", $db);
$piltid = mysql_insert_id($db);
}
/************ end code to insert images **************/
Any ideas how I could resize the images to 100*75 pixels (from 400*300 pixels)?
Would I do it with "ImageCopyResized"?
Yours,
Lauri Väin