Resizing a picture

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
Watch

freeflow

Established Member
Impact
13
Hi everyone,

Can you help me with this code? I would like to resize a picture from a MySQL
database using PHP and the variable in a link to select the picture (..php?s=...)
What’s the best way to do this?
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
at first get your image data

PHP:
	$query = "SELECT * from  binary_data where id='$id' ";		

	$sql_result = mysql_query($query,$config[connection]) or sql_error("Connection Error");
	while( $row = mysql_fetch_array( $sql_result) ) {

				$data = $row[bin_data];
	}

then optimize it to your rules

PHP:
$width = 100;
$height = 100;

$im = imagecreatefromstring($data);
$new = imagecreatetruecolor($width, $height);
$x = imagesx($im);
$y = imagesy($im);
imagecopyresampled($new, $im, 0, 0, 0, 0, $width, $height, $x, $y);
imagedestroy($im);
header('Content-type: image/jpeg');
imagejpeg($new, null, 95);

thats all
 
1
Close
Perfect! It worked, thanks.
 
0
Close
Well, I guess I am pretty late
someone's problem has already been resolved

anyways, for any further SQL related queries,
you can pm me

regards!!!:|
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back