Jump to content

[SOLVED] display image background color


contra10

Recommended Posts

my mistake, i must have been trying to call something new...do u know if there is a way though to have a backgorund color to an image...right now my image shows from an iframe and the page color is white...if i use html to change the page color my photo turns back into binary data

if you are wanting to place a background color behind the photo so that there is padding around the image so that the background color shows up as if the image is sitting on a background...

 

i would place the image inside a div and set the div to a particular color and give padding to that div

i tried inside the syntax and outside with div...if outside i get the image in binary data while inside the syntax

 

<?php
$query = mysql_query('SELECT image FROM `tbl_images` WHERE `userid`= "'.$id.'"');
$row = mysql_fetch_assoc($query);
$content = $row['image'];



$desired_width = 40; 
$desired_height = 40; 

$im = imagecreatefromstring($content)or die("Can not select the database: ".mysql_error());; 
$new = imagecreatetruecolor($desired_width, $desired_height)or die("Can not select the database: ".mysql_error());; 

$x = imagesx($im); 
$y = imagesy($im); 

imagecopyresampled($new, $im, 0, 0, 0, 0, $desired_width, $desired_height, $x, $y)or die("Can not select the database: ".mysql_error());; 

imagedestroy($im); 

header('Content-type: ' . $row['type'] .'');
echo "<div background-color:green;'>imagejpeg($new, null, 85)</div>";
}
?>

 

i get nothing shown

 

did i place the div syntax wrong

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.