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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.