Page 1 of 1
set the height and width of binary image
Posted: Mon Dec 27, 2010 5:57 am
by manojsemwal1
Hi ,
i need a help to set the width and height of binary image. code are like....
<?php
$username = "infosoft_web";
$password = "admin";
$host = "localhost";
$database = "infosoft_webschool";
@mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
@mysql_select_db($database) or die("Can not select the database: ".mysql_error());
$query = mysql_query("SELECT * FROM Photo WHERE ID='2'");
$row = mysql_fetch_array($query);
$content = $row['Photo'];
//$size="60000";
header('Content-type: image/jpg');
header("Content-length: $size");
echo $content; /// here image are in full length so how to configure the width and height
Thanks
?>
Re: set the height and width of binary image
Posted: Mon Dec 27, 2010 6:02 am
by Darhazer
If I understand you correctly, you need to know the $size used for the Content-Length parameter?
if so, $size=strlen($content);
if no, why would you need to know the width and height if you are just outputting the image?
By the way I've wrote a script that can parse JPEG headers to determine width and height, I'm going to publish it in the first days of 2011
Re: set the height and width of binary image
Posted: Mon Dec 27, 2010 6:08 am
by manojsemwal1
thanks for ur quick reply..................
actually the image size (width,height) is too much large. so i want to customize this as per user requirment..................like fix the image width and height....
Thanks
Re: set the height and width of binary image
Posted: Mon Dec 27, 2010 6:17 am
by Darhazer
manojsemwal1 wrote:thanks for ur quick reply..................
actually the image size (width,height) is too much large. so i want to customize this as per user requirment..................like fix the image width and height....
Thanks
Maybe you want to resize the image?
Better do this before saving it to database.
Look at the GD functions, you can use imagecreatefromstring, imagecopyresampled and imagegd to output resized image
Re: set the height and width of binary image
Posted: Tue Jan 04, 2011 6:25 am
by manojsemwal1
Ya i had tried the written links but not got success.
$query = mysql_query("SELECT * FROM Photo WHERE ID='2'");
$row = mysql_fetch_array($query);
$content = $row['Photo'];
header('Content-type: image/jpeg');
//print $content;
imagejpeg($content);
When i use print $content the image is showing but when i use imagejpeg($content); image is not showing...................
may be this due to binary or simple image calling.............?
Pl tell
Thanks
How to set the binary image in data form
Posted: Wed Jan 05, 2011 6:52 am
by manojsemwal1
How to set the Binary data Image in data form like
I have store image to blob in sql server and want to display in the form of employee information page so how can i do it..........
help
Thanks
Re: set the height and width of binary image
Posted: Wed Jan 05, 2011 7:00 am
by Darhazer
read the manual
imagejpeg works with resource handle, not with binary data
Code: Select all
$image = imagecreatefromstring($content);
// add imagecopyresampled() to resize the image
imagejpeg($content);