Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Pull In An Image From File Which Has A White Background


trying to pull in an image from file which has a white background make the white transparent and copy it onto a new image with a black background, the script below below works except for making the background transparent, anyone got any ideas? Code:




View Complete Forum Thread with Replies

Related Forum Messages:
Pull A Url Of An Image Out Of A Text File, And Then It Puts It In The Page.
im using a php script to pull a url of an image out of a text file, and then it puts it in the page.

My problem is, i have some images that are HUGE, that i want smaller, and SMALL images that i DON"T want bigger. Setting a set width in the image tag throws off the small images. Is there any way to say like maximum width is blah blah blah? So small images stay small, and big images are made smaller?

View Replies !
Pull Image From Mysql To Image Directory
Im trying to grab every image in my MySQL database then write them to a directory.
Thing is when I do this then view the image, it errors or shows the url of the image.
code:

View Replies !
Error In Converting GIF Image To Black & White
I have a doubt in php.I wrote a php program to convert colour Images to

balck & white.It is working fine with JPEG files and PNG files.When it
comes to GIF files I am not getting the colour Image.I think I found
the reason of getting error.But I am not able to solve it
I am pasting the code which I wrote

The reason I think is when I am extracting the RGB value from the
image,R and G will be zero everytime.But I am getting the value of B.
As a Result I am getting a Black Box instead of Black and white Image

$file = 'logo2.gif'
header('Content-type: image/gif');
$imgtype = "gif";
list($width, $height) = getimagesize($file);
$source = imagecreatefromgif($file);
$bwimage= imagecreate($width, $height);

for ($c=0;$c<256;$c++)
{
$palette[$c] = imagecolorallocate($bwimage,$c,$c,$c);

}

function yiq($r,$g,$b)
{
return (($r*0.299)+($g*0.587)+($b*0.114));

}

for ($y=0;$y<$height;$y++)
{
for ($x=0;$x<$width;$x++)
{
$rgb = imagecolorat($source,$x,$y);
$r = ($rgb >16) & 0xFF;//error is here I am getting a value of zero
for $r and $g
$g = ($rgb >8) & 0xFF;//error getting the value zero everytime
$b = $rgb & 0xFF;//Here I am getting value

$gs = yiq($r,$g,$b);
imagesetpixel($bwimage,$x,$y,$palette[$gs]);

}
}

imagegif($bwimage);

View Replies !
GD Image Loads And Then You See White Line Go From Top To Bottom
i have a gd image that loads and once it is clicked a pop-up will open and display the image again only at a bigger size. i am not resizing the image with gd; i am resizing with regular html image tag's width and height properties.

when the initial gd image loads for the first time; it loads normally, but when it loads in the pop-up window; it loads normally and then it is like it reloads itself again, because you can see a white line go from top to bottom of the image. i do not know what is causing this;

i was wondering if the gd image is being cached by the browser and displays at first; then the gd code loads from the php script and the white line is because the background of the pop-up is white and the cached image is being reloaded from the php script.

any way - anyone have any ideas? - anyone know how to prevent this? - would i us a no-cache header?

View Replies !
Remove The White Space And Then Resize The Image
I have an image which has an amount of white space around it. I want to remove the white space and then resize the image so that there is more of the image rather than the white space.

View Replies !
Invert A B&W Image (so That The Black Becomes White And Vice Versa).
I'm new to the GD functions and wondering if there's anything that would enable me to invert a B&W image (so that the black becomes white and vice versa).

View Replies !
Background Image
i created a calendar in php. i have this calendar displayed on another php page (index.php).

i added a background image to the calendar. it displays fine on the calendar alone but it won't display as a background image when i display it on index.php.

View Replies !
Background Text Image
How can I place text on a page like a watermark background. For
example, I may want to put FOR SALE in large red letters in the center
of a page at a 10% opacity then write text over it from the initial
point of origin. I've tried using style commands, but the results are
inconsistant.

View Replies !
Premade Gif That Set As The Background Of An Image
I have a few questions about GD in PHP. If I have a premade gif that I want to set as the background of an image Im making on the fly how would I do that?

View Replies !
Random Background Image
I'm designing a site that needs to do the following: Select randomly from a series of about 5 different background images Store the selected image name in a session variable I'm pretty sure that I can setup it's selecting randomly from images and storing it in a session variable. The thing I can't figure out is how I should execute it most efficiently. Will it work to do a php file include of the php file that has the code.

View Replies !
Random Background Image + CSS
I have images stored in a server folder with metadata in Database.

The images are to be used as Background Images set in a .CSS file...

background: #fff url('../images/main_bg.jpg');

How do I display images by random in the CSS file?

Is it possible?

View Replies !
Text On A Background Image
it needs to have the background of another image (bg.jpg) and then have text printed on top of it. I have tried jpgraph but it was to hard to understand then i tried this:
    <?php 
        header ("Content-type: image/png"); 
        $img_handle = ImageCreate (230, 20) or die ("Cannot Create image"); 
        $back_color = ImageColorAllocate ($img_handle, 0, 10, 10); 
        $txt_color = ImageColorAllocate ($img_handle, 233, 114, 191); 
        ImageString ($img_handle, 31, 5, 5,  "My first Program with GD", $txt_color); 
        ImagePng ($img_handle);  ?>

View Replies !
Background Image Load Problem
I have a table with a large background image:

<table style='background-image: url(images/eagle_country_large.jpg); ..'>

The problem is that everything on the page loads except there is a big delay with the loading of the image.

It's not like a regular image loading. Somehow it looks like the page is finished, then a delay, and then the background picture appears. It's even worse on a dialup connection. Code:

View Replies !
Question About Adding A Background Image
I have searched and dug and I have looked at probly every thread on hear and I have still not been able to figure out how to put up a simple background image I have tried a couple things from different threads but when I enter in the code I either get light blue background, no page at all, or the same as what I started with.

Here is what I am adding (with many variations)

<body style="background: #CCFFFF url('../../images/adrian18.jpg');">'

It works fine in my editor (dreamweaverMX) but when I upload it I get nothing.

Please treat me like I am Stupid, the reason is because I don't know for sure If I have been editing the right file.

the file I have been editing is index.tpl under my /templates/ folder, because it sets my layout, I do also have a index.php in my root folder.

View Replies !
Pull Image From Video
Does anyone know how to pull an image from a video with php or do I have to use anther language to do this.


View Replies !
Image Create Default Background Color
I have a script that crops and image and resizes it, but that's not the problem.

If the image is smaller than the crop area, PHP just fills it in with black.

Is there a way to make PHP fill it in with white instead of black?

View Replies !
Pull Out An Image From A Mysql Database
I want to use the code below to pull out an image from a mysql database but nothing shows on the page and there was no error message to indicate any problem.What could be wrong. The image is actually in the database with all the details:

View Replies !
How To Pull Back That Autonumber To Be Used With The Image Name.
I'm hoping someone can help me with this. I have just acquired a script that does uploads for images and I wanted to link the process my mysql records. In my MySQL database, I have a primary key index which is an autonumber. what I want to do is this:

When I insert a record (which would include the image), I want the name of my uploaded image to be automatically changed to the autonumber of the record. I'm just not sure how to pull back that autonumber to be used with the image name.

View Replies !
Pull Image From MySqL And Display
I have a MySQL db with a table that contains a field which houses the name of an image e.g. image.jpg.

The image is in the same directory as all the other files so I dont need to type the path.when I echo the contents of the record is should show the image referred to in the db shouldn't it? well it's not.It just shows an ugly image place holder.

View Replies !
Remove A Black Background From An Image To Make It Transparent Using GD
is it possible to remove a black background from an image to make it transparent using GD. for example. can i pass the radius of the moon to GD (as it is on the image) and have it slice the moon out so to speak leaving it on a transparent background.

View Replies !
Upload File Without White Space In The Name
I don't know how to remove white space between two words if file name consist of two words. What should I put in the script below to remove the space? Code:

View Replies !
Run The Index.php File In The Browser And Get A Blank White Screen.
I'm running Win2003 Server with IIS, PHP 5.2, and MySql 5. PHP works in some cases, for example, I have phpMyAdmin running fine, WordPress running fine, and a few other basic sites. However, I've tried to install other PHP applications (the case at hand being OS Commerce), where it seems the PHP code doesn't run.  I install the files, run the index.php file in the browser and get a blank white screen. I've checked for the opening tag issue <? vs. <?php and everything is set to <?php.  I'm wondering if there is a setting in the php.ini file that I am missing? Not sure what to do next.

View Replies !
File Uploading - How To Remove White Space Between Two Words
I don't know how to remove white space between two words if file name consist of two words. What should I put in the script below to remove the space? PHP Code:

if (isset($_POST['btnAdd'])) {
$uploaddir = 'certificates/'
$uploadfile = $uploaddir . $_FILES['file']['name'];

if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile))
{
$temp = explode('/', $_FILES['file']['name']);

$certificate = 'certificates/' . urlencode(end($temp));
}
else
{
$certificate = ''

}

View Replies !
Pull Random File
I am trying to get one of x amount of files from a dir. The code below works but sometimes it returns empty. PHP Code:

$files = array();
        if ($handle2 = opendir("../media/random")) {
            while (false !== ($file = readdir($handle2))) {
                if ($file != "." && $file != "..") {
                    $files[] = $file;        
                }    
            }
        closedir($handle2);
    }    
    $getRand = mt_rand(1, count($files));
    for($i = 0 ; $i < count($files) ; $i++) {
           $file2 = $files[$getRand];    
    }
    $output .="&files=".$file2;
    echo $output;
Cany oneone see why it would return empty?

View Replies !
Pull The Text Out Of This Html File
i need to pull the text out of this html file using php here what it looks like Code:

View Replies !
How To Pull 1 Line Of Data From A File? NO MYSQL
I have this file that has 2 lines in it. Heres how the files looks.

file: fbddata.lbn

line1:uncle1234562
line2:

As you can see, on line 2 there is actually no data but the file still seems to have a 2 lines. But when I pull the info from the file using the "include" or "require" command it just pulls the 1st line of data. BUT..when I try to use the "include" or "require" php commend within a HTML link code like this....

<a herf="www.mysite.com/Lavishphpfreak/<?php include("fbddata.lbn" ?>/ilovephp.php>LINK[/url]

it gives me a link that this...

http://www.mysite.com/Lavishphpfreak/uncle1234562
/ilovephp.php

now did you notice the code that was added to the link. I have figured out that its doing this because of the blank line 2 thats in the fbddata.lbn im trying to pull the data from. Of course the easy way to fix this would be to just go into the file and delete the blank like 2 but i can't do this because i dont have permission to edit the file. Its created using "root".

So does anyone know of a php code that will just pull the 1st line of data from within a file. I can't use mysql cause this is NOT in a database..and plus I haven't advanced to databases yet.

View Replies !
Pull Down Menu Generating A List Off Another File
Is there a way I can make a pull down menu generating a list off another file of all the destination case coming from the file locations.php?

locations.php

switch ($destination){
case "Las Vegas":
echo "Bring an extra $500";
break;
case "Amsterdam":
echo "Bring an open mind";
break;
case "Egypt":
echo "Bring 15 bottles of SPF 50 Sunscreen";
break;
case "Tokyo":
echo "Bring lots of money";...........

View Replies !
Pull Data From The Database And Generate A Normal Text File
I have a database that is correctly storing characters like the trademark symbol, copyright,ect. I then pull data from the database and generate a normal text file from it. I do not do anything other then echoing out the direct database info into a variable and then building the file from the variable.

When I open the text file, ALL my trademarks, copyright, apostrophies, anything other then alphanumeric becomes question marks. "?" I have no idea how to fix this. Can anyone lead me in the right direction on what needs to be done to fix this. The database charset is 8859-1 I beleive, and my html pages are also 8859-1 and also render the data wrong, same "?"

View Replies !
Pull The File Name And Type From The Database To Fill The Correct Headers?
I have a file that I stored on my server. I put the file name and the file type in the database. These are word and excel and pdf files.

I tried to pull the file name and type from the database to fill the correct headers and open the file. It doesn't seem to be working though. Can someone please take a look at what I tried to do: Code:

View Replies !
Writing A Blob Image Out To A File - Jpg Image Looks Weird?
I've got simple watermarking working. I write a Blob image out from my db to a temp file and then overlay the watermark image to create 1 whole image.

The watermark is perfect, but the exported blob behind it looks all garbled - parts are visible but its not right!

I've looked at the temp file thats created by the line "fwrite($t_img, $data);" and the image looks corrupt, but displaying this field using usual php methods the blob looks fine.....

Here's the code :-

@MYSQL_CONNECT("$server","$user","$password");
@mysql_select_db("$database");
$query = "SELECT image, mime_type, image_width, image_height FROM items WHERE ID='$id'";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,"image");
$type = @MYSQL_RESULT($result,0,"mime_type");
$image_width = @MYSQL_RESULT($result,0,"image_width");
$image_height = @MYSQL_RESULT($result,0,"image_height");
// Write blob data out to temp image file to prep for Watermark
// creating a temp image name
$t_img_name = tempnam ("./temp", "timg");
$t_img = fopen($t_img_name, "w");
// $content is the blob field with the image.
fwrite($t_img, $data);
fclose($t_img);
//-$size = getimagesize($t_img_name);
//echo $size[0]." - ".$size[1];
$img = imagecreatefromjpeg($t_img_name);
$watermarkImage = 'images/watermark2.png'
$x = 165;
$y = 130;
imagesetbrush($img, imagecreatefrompng($watermarkImage));
imageline($img, $x, $y, $x, $y, IMG_COLOR_BRUSHED);
imagejpeg($img);
// End of watermark protection
// don't forget to delete the temp file after all.
//unlink($t_img_name);
$type = "image/jpg";
if(strlen($data) < 1) {
header("Location: ./images/nopicsubmitted.jpg");
} else {
//header("Content-type: $type");
header("Content-Type: application/octet-stream");
echo $img;
}

Can anyone spot if i've made a mistake, used wrong function or syntax etc?

View Replies !
Getting Rid Of White Space
Anyone have a quick simple way of getting rid of white space in the middle of a string? I've tried str_replace("  ", " ", $string) but doesn't seem to do it, I guess it doesn't work with spaces?

View Replies !
White Space
How do you replace white space that you are pulling from the DB and add <BR> so text displays properly with spaces? The <pre> tag does this but now my text word wrapped far to the right.

View Replies !
Trim After Last White Space
I have the following code which returns the first 100 characters. Now I would like to trim everything after the last white space. PHP Code:

View Replies !
White Space Position
how do i find if there is white space in a string eg. "hello how are you?" also how do i return the position of that white space?

View Replies !
Trim White Spaces
I want to trim all white spaces our of a string and also any other characters other than numbers and letters.

It is for a domain name script so it needs everything removed other than numbers and letters

I have this so far but this only does white space??

$text = preg_replace('/s+/', ' ', $text);

View Replies !
White Space Manipulation
got a string i.e. "Hello World 2007".

aim is to remove only one white space when prompted ie. remove the first and end up with "HelloWorld 2007" or the 2nd and achieve "Hello World2007". Could be a string with more white space.

Any functions that single out a specified character? but only 1 such as take the 2nd white space but leave the first?

View Replies !
How Add White Spaces At The End Of String
Someone can help me in this situation:

I need produce this output : "[xxx ]" . If the string dont have 10 characters i want put white spaces on the right......

View Replies !
Removing White Space
I wish to remove some whitespace within my string. I have the following:

'rh1 1qz'

I wish to print it:

'rh11qz'.

View Replies !
White Space Problem
I'm trying to retrieve an image from my database, the code i have works for anything with out a space but once there is a space in a title it only sends the first word. I have tried str_replace, and addslashes to no avail. Code:

View Replies !
Replace White Space With <br />
I want to replace:

"hi

hi"

the white space in the above so it looks like this

"hi

hi"

Is this possible?

View Replies !
Convert White Spaces
when it comes to using a form and specificly a "textarea", I wanna convert line returns to a "<br>" before it gets inserted into my database. Also be capable later switching it back. *Editing page - existing info fed into textarea.

View Replies !
White Space Missing
I have tutorials stored in my database. But when I retrieve the information there are white spaces between some words missing. The field is of format Text. The information is being added to the database via PHP. I used phpMyAdmin to go in and look at the info contained within the database and yes the spaces are missing there also. Any ideas anyone? 

All entries in this Text field called content are behaving the same. so just to update as I am still looking in to this right now, It appears that because I used a textarea to input the code the line breaks have been removed from the textarea input and no spaces have been included.

View Replies !
Remove White From Images
I am trying to set up a script to remove the white background from an image and make it transparent. I managed to almost do this in GD by doing the following: Code:

function maketransparent($oldfile,$newfile)
{
$im = imagecreatefromjpeg($oldfile);
$img = imagecreatetruecolor(500,424);
$trans = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
imagecolortransparent($img,$trans);
imagecopy($img,$im,0,0,0,0,500,424);
imagetruecolortopalette($img, true, 256);
imageinterlace($img);
imagepng($img,$newfile);
imagedestroy($img);
}

That works however it only removes parts of the image that are exactly White (#FFFFFF), I need some sort of threshold so that it removes colours that are near white aswell.

View Replies !
Trim: Take Out White Spaces
I have a form for use to enter...

But sometimes people like to add many return carriage, new lines.

So I want to strip it out.. The below code doesn't work. Why is that?

Is it because it's can't recogize as "hey .....

View Replies !
Getting White Space Error
I've tried moving stuff around changing quotes still get a whitespace escaped error here is the query.

<?php
mysql_query("INSERT INTO `items` 
(`Status`,`Attack`,`Defense`,`HP`,`ItemClass`,`Version`) 
VALUES('0','$items['attack']','$items['defense']','$items['hp']','$item['class']','$_POST['version']')"
or die(mysql_error());
?>
{/code]

View Replies !
Strip White Space
How can I strip white space from the beginning and end of a string??

" FRED JOHNS "
SHOULD BE

"FRED JOHNS"

View Replies !
White Space String
I need to be able to check for a string with nothing but whitespace. The problem I am having with one of my forms is people can just hit the space bar a couple of times and it will return true when i check for $var != ''

I tried a couple of ctypes_ with no luck. Any suggestions?

View Replies !
White Space In Select Option
I'm having a problem with a <select><option> which has white space in
values...

When I post the data I only get the first word (up to the white space).
"Testing white space" becomes "Testing" after posting

<select name="descr" id="descr">
<option value=Testing white space>Testing white space</option>
<option value=Testing white space two>Testing white space two</option>
<option value=Testing white space th>Testing white space th</option>
</select>

I am using form method = post and have also tried method = get

How do I get the full string from the value field.

View Replies !
White (blank) Web Pages With PHP3
Does anyone know why certain php files that work fine on my local win32 system,
(win98 with Apache, MySQL and PHP3) when uploaded to my ISP's web server running FreeBSD, do not work ? A blank web page is returned, no error msgs)

This particular problem exists with a search engine script downloaded from www.dirtdobber.net. The script works like a charm on my local system. Could it be a memory allocation setup problem with MySQL and PHP3 on my ISP's systems ?

View Replies !
Black & White Images Using The GD Library
Is there a simple way of making an image black and white only using the GD Library?

View Replies !
Refresh The Pages Goes All White And Blank
I have created a page which had the PHP as listed below and the page works fine however if the user clicks refresh the pages goes all white and blank. I was just wondering why it does this? Code:

<?php
session_start();
include ('db.php');
$link_id = db_connect('');

$g = "SELECT ff, nn e FROM cu WHERE Id = '". $HTTP_SESSION_VARS ["Id"]."'";

$rs = mysql_query($g, $link_id);


if (mysql_num_rows($rs) > 0 )

{

View Replies !
Recode From Color To Black And White
try to recode my php code below from generating just a black and white image. the code below takes time to process cause its trying to generate as much colors as it could receive from its source, but the thing is, the source is just passing black and white colors.. Code:

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved