contra10 Posted January 7, 2009 Share Posted January 7, 2009 im trying to have a background color for my image <?php body('background-color: red' ); header('Content-type: ' . $row['type'] .''); imagejpeg($new, null, 85); ?> a body function doesn't work Link to comment https://forums.phpfreaks.com/topic/139806-solved-display-image-background-color/ Share on other sites More sharing options...
trq Posted January 7, 2009 Share Posted January 7, 2009 There is no such php function as body. Link to comment https://forums.phpfreaks.com/topic/139806-solved-display-image-background-color/#findComment-731472 Share on other sites More sharing options...
contra10 Posted January 7, 2009 Author Share Posted January 7, 2009 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 https://forums.phpfreaks.com/topic/139806-solved-display-image-background-color/#findComment-731981 Share on other sites More sharing options...
contra10 Posted January 7, 2009 Author Share Posted January 7, 2009 im trying to get a background colour for my photos but it keeps messing up when i put an actual colour, wheter in html <body bgcolor="black"> outside the php or within the php syntax Link to comment https://forums.phpfreaks.com/topic/139806-solved-display-image-background-color/#findComment-732011 Share on other sites More sharing options...
dennismonsewicz Posted January 7, 2009 Share Posted January 7, 2009 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 https://forums.phpfreaks.com/topic/139806-solved-display-image-background-color/#findComment-732013 Share on other sites More sharing options...
contra10 Posted January 7, 2009 Author Share Posted January 7, 2009 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 https://forums.phpfreaks.com/topic/139806-solved-display-image-background-color/#findComment-732031 Share on other sites More sharing options...
dennismonsewicz Posted January 7, 2009 Share Posted January 7, 2009 change this echo "<div background-color:green;'>imagejpeg($new, null, 85)</div>"; to echo "<div style='background-color:green;'>" . imagejpeg($new, null, 85) . "</div>"; Link to comment https://forums.phpfreaks.com/topic/139806-solved-display-image-background-color/#findComment-732033 Share on other sites More sharing options...
Brian W Posted January 7, 2009 Share Posted January 7, 2009 you said something about using an I frame for displaying the image. You can grab that image with something like: <img src="image.php?ID=<?php echo $id; ?>" /> that would avoid the whole iframe thing. Link to comment https://forums.phpfreaks.com/topic/139806-solved-display-image-background-color/#findComment-732042 Share on other sites More sharing options...
contra10 Posted January 7, 2009 Author Share Posted January 7, 2009 ye that works the way i wanted it too...thanks both of u guys and other way workds as well Link to comment https://forums.phpfreaks.com/topic/139806-solved-display-image-background-color/#findComment-732045 Share on other sites More sharing options...
contra10 Posted January 7, 2009 Author Share Posted January 7, 2009 using ifram i should have set transparency....duh to myself Link to comment https://forums.phpfreaks.com/topic/139806-solved-display-image-background-color/#findComment-732046 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.