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
?>
set the height and width of binary image
Moderator: General Moderators
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
Re: set the height and width of binary image
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
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
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
Re: set the height and width of binary image
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
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
Maybe you want to resize the image?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
Better do this before saving it to database.
Look at the GD functions, you can use imagecreatefromstring, imagecopyresampled and imagegd to output resized image
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
Re: set the height and width of binary image
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
$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
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
How to set the binary image in data form
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
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
read the manual
imagejpeg works with resource handle, not with binary data
imagejpeg works with resource handle, not with binary data
Code: Select all
$image = imagecreatefromstring($content);
// add imagecopyresampled() to resize the image
imagejpeg($content);