Greeting to all
am trying to create thumbnail from image stored in mysql database..
this is the coding am using to create the thumbnail...
this works like charm.. but the problem is that the image quality is not as in the original image.. -
<?php
-
-
// Place the code to connect your Database here
-
// DATABASE CONNECTION
-
include('config.php');
-
-
$id = $_GET['id'];
-
-
// Check if ID exists
-
if(!is_numeric($id)) die("No image with the ID: " .$id);
-
-
// Get data from database
-
$dbQuery = "SELECT image, file_name ";
-
$dbQuery .= "FROM imagesdata ";
-
$dbQuery .= "WHERE id = $id ";
-
$dbQuery .= "LIMIT 1";
-
-
$result = mysql_query($dbQuery);
-
-
// read imagetype + -data from database
-
if(mysql_num_rows($result) == 1) {
-
$file_Type = mysql_result($result, 0, "file_name");
-
$fileContent = mysql_result($result, 0, "image");
-
-
//$fileType = str_replace(".","",strtolower(substr( $file_Type,strrpos( $file_Type,"."))));
-
-
//$filename = $file_Type;
-
-
header("Content-type: $fileType");
-
-
// get originalsize of image
-
$im = imagecreatefromstring($fileContent);
-
$width = imagesx($im);
-
$height = imagesy($im);
-
-
// Set thumbnail-width to 100 pixel
-
$imgw = 150;
-
-
// calculate thumbnail-height from given width to maintain aspect ratio
-
$imgh = $height / $width * $imgw;
-
-
// create new image using thumbnail-size
-
$thumb=imagecreatetruecolor($imgw,$imgh);
-
$filename = addslashes (file_get_contents($fileContent));
-
$image_name= stripslashes($fileContent);
-
// copy original image to thumbnail
-
imagecopyresampled($thumb,$im,0,0,0,0,$imgw,$imgh,ImageSX($im),ImageSY($im));
-
-
// show thumbnail on screen
-
$out = imagejpeg($thumb);
-
print($out);
-
-
// clean memory
-
imagedestroy ($im);
-
imagedestroy ($thumb);
-
}
-
?>
-
i tried to change $out = imagejpeg($thumb); to $out = imagejpeg($thumb, $fileType, 100); but it doesnt print the image...
pls help me getrit of this problem or suggest me some other coding for the above..
Thanks in Advance...
Regards,
Guna
2 8674
The second parameter is for filename not filetype. If you are outputting the jpeg directly you don't need to declare a filename and should leave it NULL.
Here is an example -
$out = imagejpeg($thumb, NULL, 100);
-
Thanks JKing.. Thanks lot.. it works as a charm..
Sign in to post your reply or Sign up for a free account.
Similar topics
by: hemashiki |
last post by:
hi
i need help..how can i store image in mysql database
and i want to retrive that image
can anyone suggest plz
|
by: sashi |
last post by:
BLOB - Retieve image stored in database
Dim CN As New ADODB.Connection
Dim RS As ADODB.Recordset
Dim DataFile As Integer, Fl As Long, Chunks As Integer
Dim Fragment As Integer, Chunk() As...
|
by: wingleader |
last post by:
Hi!
I'm looking for ways of uploading image file to mysql database. I know, that it should be possible, but don't know how to do it.... could someone help me?
|
by: SarangMaskikar |
last post by:
hi
how to save tif image in mysql database in vb.net
plz guide me
Sarang.
|
by: berry |
last post by:
Hi all,
I am scratching my head on how to store image that user upload to the MySQL database in vb6?
Please HELP me!!
Thank you very much..
|
by: rajiv07 |
last post by:
Hi to all,
We can store image in mysql using MEDIUMBLOG data type.I want to know how to insert or select and store an image data type using perl.
Is any idea Please
Thanks.
Regards
...
|
by: jarremw |
last post by:
hello all, i am making a database to hold some scanned pdf's so i was wondering how would i go about saving them in the mysql database? would i put the file in the database or just link to it? so if...
|
by: WellCom34 |
last post by:
hey guys need a little help.
i tried to save image into my database, it saves without error
but when i tried to check if it saves in mysql, the data about my picture id save, but the image i save...
|
by: yusufjammy |
last post by:
How to insert image in mysql database via php and how to retrieve in php ?
|
by: Gunasegar |
last post by:
I need to retrieve an image from mysql database, where it is already stored as longblob format pls help me
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |