Imagerotate(), Producing A Black Background Color
I am having this Image, the background of the image is transparent
But on rotation using imagerotate(), it is producing a black background color.
This background color is coming on using any function on the original image
ie, like imagecopy() etc . I have used imagecolortransparent() to suppress the
color, but still the problem is coming.
View Complete Forum Thread with Replies
Related Forum Messages:
Color Background Cell Color Per Row
I am trying to create a display page for my database records, where each display-row has a different color than the previous one. I think I can do that if I where able to get the rownumber of the recordset. Than for each 'even' number I asign a color, and for each 'uneven' number a different one. Code:
View Replies !
Retaining Black Color
What I'm doing is changing the color of one image and then overlaying it on top of another with an opacity of around 35%. The bottom image contains pure black text. What I want to know is if there is a way to merge the two images while retaining the color of the black text underneath. A lot like using a multiply layer in Photoshop. I'm not even sure if this is possible, or if I'd be simply better off just having a separate layer/image just for my black text.
View Replies !
GD Imagecopy Problems With Black Background
This function is part of a class, it basically creates a new image in the dimensions specified, and then copies in the image held in $this->image. The image that is copied in will never be bigger than the new image (that is taken care of in another function) but one or both of the dimensions could be less than the new image (if the ratio isn’t the same). It all works perfectly, it creates a new true colour image, fills it in white, but then when it runs the imagecopy function it seems to forget the fact that I set the background to white, and the image that results has a black border. For example if I wanted a 100x100 image, and I was copying a 100x50 image in, I would end up with a 100x100 image with the old image centred vertically and a 25px black stripe above and below, I want those stripes to be white. Any ideas? function crop($width = null, $height = null) { // get the current widths and heights $current_width= imagesx($this->image); $current_height= imagesy($this->image); $crop_top = floor(($current_width - $width) / 2); $crop_left = floor(($current_height - $height) / 2); // create a new image resource $temp= imagecreatetruecolor($width, $height); $white= imagecolorallocate($temp, 255, 255, 255); imagefill($temp, 0, 0, $white); // copy image into new resource imagecopy($temp, $this->image, 0, 0, $crop_top, $crop_left, $width, $height); // destroy original image imagedestroy($this->image); // copy new image $this->image = $temp; }
View Replies !
Black Background On Rotated Images....
I need to rotate an image 5 degrees in PHP for a site I'm working on. The image rotates fine using the imagerotate() function, the problem is the background where it was before turns to black. Any ideas how to fix this?
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 !
ImageCopyResampled - How To Avoid Default Black Background?
I would like to know how to avoid the default black background color in ImageCopyResampled if origin and destination do not fit. ImageCopyResampled puts always a black background and if I try to fill it with another color and with ImageFill function, ... I get problems: Some images with a deep dark colors predominance or even with a deep light color predominance too, are filled with my color, as you know, applied with ImageFill. Code:
View Replies !
Background Color
I am totally baffled by what is happening in my code. I have a section of code (shown below with two comment lines inserted). They are essentially identical text boxes (names and variables different). Yet, the first comes up with a white background and the second comes up with a yellow/gold background....
View Replies !
Set Background Color
I am designing with flash and am sending variables on the end of a url to a php document which also contains a swf - I want to tell the php file what color to make the background in the html section I have:- <body bgcolor="<?php echo $bgcol">> I've tried moving the quote marks around but nothing seems to work - I also use php in the title and that is working fine - is it because it is inside a tag or something or do I have the wrong syntax?
View Replies !
Setting The Background Color Of A PNG
I'm attempting to set the background color of an image, but it doesn't seem to be working. The PNG image has a transparent background to begin with, but whenever I print the image out, the background is always white. Code:
View Replies !
Using Sessions To Change Background Color
I am trying to use session to store the background color throughout each page by session variables. I think the problem comes from the structure of my site. each page is accessed by ?topic=home or ?topic=tutorials It is setup as: example not actual code:
View Replies !
Table Background Color Based On Value
I'm trying to make this happen on query from my database . $h1 = 4; $h2 = 5; if ($h1 == 4){$color="green";} if ($h2 == 5){$color="yellow";} print "<table><tr>"; print "<td bgcolor=$color>$h1</td>"; print "<td bgcolor=$color>$h2</td>"; print "</tr></table>";
View Replies !
Change Background Color In Table From 2nd Row Onwards?
i am displaying data in a html table with five rows of five columns each, the first row is a title row with blue background, and the 2nd row onwards is the data rows with a radio button. When a user click first row, nothing should happend, but when the user clicks the radio button or any column of the row, I wish to select the radio value (clicked) and set the background color to silver for the entire row of five columns. Here is my javascript code which is working fine, except it removed the first row style background color, which I don't wish to remove. Code:
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 !
PHP (GD) Created Transparent PNG: AlphaImageLoader Makes Black Parts Transparent Instead Of Transparent Color Set With PHP
I have a problem with PHP (GD) created transparent PNG and Microsofts AlphaImageLoader. You will immediately see what the problem is if you view http://www.useful-scripts.biz/test/.../transpng_2.php with IE 7 or Firefox and then with IE 6. It seems that the AlphaImageLoader works correctly on a PNG image that has been created with an image processor and then uploaded, but not with a PNG image created with PHP. It seems to ignore the transparent color set with PHP and instead to render the black color transparent. The image in question was created using this code: <?php $source = imagecreatefrompng("parrot_orig.png"); $transp = imagecolorallocate($source,255,0,0); imagecolortransparent($source,$transp); imagefilledrectangle($source,15,15,70,70,$transp); imagepng($source,"parrot_php.png"); ?> The HTML used on the page is this:
View Replies !
Table Background Color Based On Results From MySQL Table
I am trying to get the "Did User Agree" field on a database query to be colored Green for "Agreed" Red for "Disagreed" and Blue for "Agreed (2nd Time)" .. I have my PHP setup to do the query just fine as of right now with alternating column colors, just can't seem to get the colors to work as I am hoping for. Can anyone help me get the Agreed? table's background color to the colors above? Code:
View Replies !
Imagerotate With GD
I am trying to do. I have two images. I need to rotate both of them (2 different degrees, which is determined by a random number), then I need to merge them together so that the center of both images are on top of each other. So far, I have both images, I rotate them, and I use imagecopymerge() to put them together. As far as I can tell, the reason for this is that they are square images (both 200x200), and depending on how they rotate, the corners of the boxes are kind of pushing the image in defferent directions, causing them both to shift around the page a little bit, and not line up properly when merged.
View Replies !
Imagerotate() Function
I've been trying to get imagerotate() working with PHP 4.4.3 and the latest version of GDlib. An error message is given saying the function is unrecognised.
View Replies !
Producing Catalogues On CD
I have produced an online catalogue using PHP. I want to do the same thing but have a complete application, database and all, on a CD. Presumably not possible with PHP, does anyone know of a way of doing this?
View Replies !
While Producing Duplicate Results
I'm trying to add the ability to attach categories and subcategories attributes to each post. I've created two tables (chap_category, and chap_sub_category) that stores the names and a unique id number for each. It's suppose to list the Categories that corresponds to the forum I'm adding a new post to. Under each of the Categories, its corresponding Sub-categories will be listed. But now it's listing the proper sub categories for the first category, for the second category it lists the first category's sub categories, for the third category it lists the first's sub-categories AND the second's subcategories...etc. PHP Code:
View Replies !
GD2 Producing Empty Images
I've found a problem with many of my PHP installations. I'm not sure whether it's a PHP problem, or an Apache problem, or something else again. The issue appears when we try to use the following snippet from the PHP docs for imagecreate(): <?php header("Content-type: image/png"); $im = @imagecreate(100, 50) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 255, 255, 255); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, "A Simple Text String", $text_color); imagepng($im); imagedestroy($im); ?> This brings up an empty page. FF Page Info shows a 0px x 0px png. I'm using Win2K on 2 of my 3 machines. On the 3rd, XP machine I'm using xampp which uses Apache 2, and it works on that one. Currently trying to install xampp on my main workstation (win2k), but can't get existing port 80 server cleared... That's another issue. Anyone have similar problems with GD2 in PHP?
View Replies !
Producing Snippets Of Text
I currently have the following code: $select = "SELECT * FROM text WHERE MATCH(content) AGAINST ('".$keyword."') LIMIT 0,50"; $query = mysql_query($select); while ($info = mysql_fetch_object($query)) { $results[] = $info->content; } foreach($results as $result) { echo $result."<br> "; };.
View Replies !
File_put_contents Producing Unusual Characters
I have a piece of code that goes through a list of words and places the word in a specific file, depending on the first letter of the word. For example, if the first letter were "A," then the word would be placed within the A.txt file. The problem is that output in the files is just a bunch of boxes, like the character encoding is somehow screwed up (which I don't understand how that could be possible). It's very strange. I can output the EXACT same info in an ECHO statement to the browser, and it appears just fine. I get no real errors. Here's the PHP code (every bit of it): ....
View Replies !
Result Query - Producing Extra Results?
what am i doing wrong here? $startrow=0; $limit=20; $qry = mysql_query("SELECT bodycare.*, haircare.* FROM bodycare, haircare WHERE bodycare.avail='true' AND haircare.avail='true' LIMIT $startrow, $limit")or die(mysql_error()); it should return 6 results between bodycare and haircare. instead it returns 8, - 4 repeats of the first haircare product and 4 of the second haircare product. There are only 2 haircare products in total and 4 bodycare, but the bodycare aren't turning up at all why? can you help me fix it?
View Replies !
This Class Returns HTML Content But Fails In Producing Globals, Why?
The following class is supposed to produce a series of HTML dropdowns and HTML text fields based solely upon variable names for month, day and year passed into it. Those variable names will correspond to actual variables with values that are passed into the preSelect() function inside the methods (that function is called from an outside parent script included). However, upon careful inspection the global function does not globalize anything within any method. // USE THIS CLASS TO GENERATE A SERIES OF DROPDOWNS AND TEXT FIELDS PERTAINING TO MONTH / DAY / YEAR class DropdownGenerator { var $hasMonth, $hasDay, $hasYear, $monthVar, $dayVar, $yearVar, $yearFieldLength, $monthArray; function DropdownGenerator($monthVar = '', $dayVar = '', $yearVar = '', $yearFieldLength = 4) { $this->yearFieldLength = $yearFieldLength; foreach (array('month', 'day', 'year') as $key => $val) { $this->{$val . 'Var'} = ${$val . 'Var'}; $this->{'has' . ucfirst($val)} = (strlen($this->{$val . 'Var'}) > 0) ? 1 : 0; if (strlen($this->{$val . 'Var'}) > 0) global ${$this->{$val . 'Var'}}; } $this->monthArray = array(༽' => 'January', ༾' => 'February', ༿' => 'March', ཀ' => 'April', ཁ' => 'May', ག' => 'June', གྷ' => 'July', ང' => 'August', ཅ' => 'September', ཆ' => 'October', ཇ' => 'November', ཈' => 'December' );
View Replies !
My Thumbnails Are Black
The code below is mean to create thumbs for all images in a folder however they just come out black. Is there an arror or is it a gd function that isnt supported with gd 2.0.28 Code:
View Replies !
Black Border
I'm trying to draw a black border around all my pictures. I get a border as the result but. The borders are all kinds of colors, different grays, white and black. It seems like random. I want black and only black. PHP Code: // Create border around image $black = imagecolorallocate($image,0,0,0); imageline($newimg, 0, 0, 0, $new_height, $black); imageline($newimg, 0, 0, $new_width, 0, $black); imageline($newimg, $new_width-1, 0, $new_width-1, $new_height-1, $black); imageline($newimg, 0, $new_height-1, $new_width-1, $new_height-1, $black);
View Replies !
Problem With "imagerotate"
Does the "imagerotate" function in PHP5 work correctly or am I doing something wrong? I'm using the code shown below to generate a simple rectangle and then to rotate it a specific number of degrees. The actual rotation itself seems to happen OK but the background color appears correctly only if the rotation is between 1 and 45 degrees; any other value and the background is black. And, in neither case does the "imagecolortransparent" work (I want the background to be transparent). $myImg = imagecreate($somelength,$somewidth); $myBG = imagecolorallocate($myImg,85,255,255); $RectColor = imagecolorallocate($myImg,200,200,200); $myBlack = imagecolorallocate($myImg, 0, 0, 0); imagefilledrectangle($myImg,1,1,($somelength-2),($somewidth-2), $RectColor); imagerectangle($myImg,0,0,($somelength-1),($somewidth-1), $myBlack); $myImage = imagerotate($myImg, $someangle, $myBG); imagedestroy($myImg); imagecolortransparent($myImage,$myBG); imagepng($myImage,"gMyRect.png"); imagedestroy($myImage);
View Replies !
Black Hat Or Not? Linking Technique Using PHP
I had an idea that I wanted to see what people think of it. I'm optimizing a site that is already built w/ very generic file naming and directory structure. In other words, I don't have directories or file names that intentionally have keywords in them. For the most part, its just a lot of index.php and one-word names. So now I'm trying to figure out a way to get some keyword URL's in there w/o trashing my directory structure. Here's what I'm thinking: Let's say I have a link already in the page that goes to index.php. What if I changed the link to keyword_term.php, then I put the following code in keyword_term.php: <?php $no_spider = "TRUE"; include "index.php"; ?> index.php would then have this in the header: <?php if ($no_spider = "TRUE") { echo "<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">"; } ?> I know it seems like more work than its worth, but the idea is that in the long run, I can optimize multiple pages for different keywords, while requiring little maintanence if I decide to edit the original index.php. I'm also using the $no_spider variable to aviod being penalized for duplicate content. My intention is not to get index.php indexed multiple times, just to allow other pages to link to it using different file names.
View Replies !
Black Line Over Frame
I'm having trouble with the frame i am creating.... for some reason there is a black space over the frame, sort of like a line. Here is the frame script: <frameset id="fMain" rows="530px,*" border="0"> <frame src="Main.php" name="Main" scrolling="no" style="border-rorder="0"> <frameset id="fBottom" <frame src="Bottom.php" name="Bottom" scrolling="no" /> </frameset> </frameset>
View Replies !
Uploaded Image Has Black Bar
I was wondering if anyone has ever encountered a problem with an uploaded and resized image that now has a black bar on the right side of the image? The image is uploaded and resized properly via a form, however the right 10% of the image is black.
View Replies !
Strange Black Lines
I've got an image resizing tool that I've adapted from one I've used before (which worked) and I'm having a few issues with it. The thumbnails generated are either squashed but look normalish OR the right size but with the black background from the imagecreatetruecolor function used. My code is: PHP Code: $im = @imagecreatefromjpeg($image); // Changes the image from a file path to an image resource. $type = @getimagesize($image); // Sets the image type. //$height = $type[0]; //$width = $type[1]; $height = imagesy($im); $width = imagesx($im); $imgw = 150; // Sets the width of the thumbnail $imgh = ($height / $width) * $imgw; //$imgh = round(($height / $width) * $imgw); $thumb = @imagecreatetruecolor($imgw,$imgh); // Creates blank thumbnail @imagecopyresampled($thumb, $im, 0, 0, 0, 0, $imgw, $imgh, $height, $width); // Copies main image into thumbnail. // Displays the resized image......................
View Replies !
Identifying Black Images
I would like to be able to identify completely black images in order that I can exclude them. I am thinking I could use gdlib but I cannot find a suitable function. If I can find the rgb of the image then I can exclude it.
View Replies !
Cropping Black Section
I am doing this sequence: $image_rsz = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($UploadName); imagecopyresampled($image_rsz, $image, 0,0,0,0, $final_width, $final_height, $width_orig,$height_orig); and uploading the resized image. The resizing looks right, but the JPEG file has a black section appended to the right of the image that is the same height as the resized image, but about 2 1/2 times the width of the picture. Is there something that needs to be done to crop off this excess? The original image, prior to resizing, did not have this.
View Replies !
Uploading Big Images Turn To Black!
First of all i've VDS Server so i can change any settings in PHP or Apache so all comments are welcomed... I am running a web site where users can upload images and its been online for 4 months and going well, but suddenly i discoverd that when uploading a picture that is about 1 MB 800x530 pixels or other which is 464 KB 1600x1200 pixels, then my script cant read their height and width then i get invalid dimensions and the image dont get resized at all and stays at their original width & height which breaks the page design! and this is when i was using: imagesx(); imagesy(); but i got the dimensions using "getimagesize()" and it was resized correctly but both images turned black! So where could be the fail! Please help me urgently because i think am losing users, i dono how come i didnt test big images b4 going live :( Here is the part where the fail & warnings come! if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { $info = getimagesize($uploadfile); $width = $info[0]; $height = $info[1]; $type = $info[2]; $attr = $info[3]; $image = "$uploadfile"; $newimage = "$uploadfile"; $image_quality = 75; $addborder = 0; $max_height = 480; $max_width = 640; // Main code switch( $info['mime'] ){ case 'image/jpeg': $src_img = @imagecreatefromjpeg($image); break; case 'image/gif' : $src_img = @imagecreatefromgif($image); } $orig_x = $width; $orig_y = @imagesy($src_img); if($width > 640 ¦¦ $height > 480) { $new_y = $max_height; $new_x = $orig_x/($orig_y/$max_height); if ($new_x > $max_width) { $new_x = $max_width; $new_y = $orig_y/($orig_x/$max_width); } $dst_img = @imagecreatetruecolor($new_x,$new_y); @imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_x, $new_y, $orig_x, $orig_y); } else { $dst_img = @imagecreatetruecolor($width,$height); @imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $width, $height, $orig_x, $orig_y); } @imagejpeg($dst_img, $newimage, $image_quality); @imagedestroy($src_img); @imagedestroy($dst_img); $_SESSION["img"] = "$uploadfile"; $formVars["userfile"] = "$uploadfile"; $img = "$uploadfile"; if($width > 640 ¦¦ $height > 480) { $_SESSION["x"]="$new_x"; $_SESSION["y"]="$new_y"; } else { $_SESSION["x"]="$width"; $_SESSION["y"]="$height"; } }
View Replies !
Why Are My Images Coming Out As Black Jpegs?
I've written a script to create thumbnails of my images. Here is my code: list($width, $height) = getimagesize($filename); $new_height = 100; $new_width = ($new_height / $height) * $width; $image_p = imagecreate($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_p "images/thumbs/1.jpg", 100); When I look at images/thumbs/1.jpg it's just a blank image. Anyone have any ideas why this would happen and how I can fix it?
View Replies !
Imagecreate Output A Solid Black Image
I'm making thumbnails. I want to first scale down the image before I crop it even smaller. The code below only creates a solid black square. Actually, only $final_im creates an image that's solid black. If I used $im as the output file (if I use this instead: imagejpeg($im, "$new_name") ), it's fine (albeit a very low quality image that does not have the dimensions I desire). I figure the problem lies at the //create final thumbnail section of the code. But, again, everything looks right. I would try other functions like imagecopyresizedbicubic , or imagecopyresampled but my server is using an older GD version, and I cannot upgrade it (ISP's server). PHP Code:
View Replies !
Creating Black Images When Trying To Create Thumbnails
I am trying to create thumbnails. However, I am only creating black image with the correct thumbnail size. I am using php 5.1.6 and GD 2.0.28. Below is the code that I am using. function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth) { $srcImg = imagecreatefromjpeg("$imageDirectory/$imageName"); $origWidth = imagesx($srcImg); $origHeight = imagesy($srcImg); $thumbHeight =200; $thumbWidth =100; if($origWidth $origHeight && $thumbHeight < $origHeight){ $thumbHeight = $origHeight / ($origWidth / $thumbWidth); } else if ($origWidth < $origHeight && $thumbWidth < $origWidth) { $thumbWidth = $origWidth / ($origHeight / $thumbHeight); } else { $thumbWidth = $origWidth; $thumbHeight = $origHeight; } $thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight); imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, origWidth, $origHeight); imagejpeg($thumbImg, "$thumbDirectory/$imageName"); } if(!file_exists("/home/alanna/public_html/pics/thumb/")){ if(!mkdir("/home/alanna/public_html/pics/thumb/")){ echo "error making thumbs directory"; } } if(file_exists("/home/alanna/public_html/pics/thumb/". $imagename)){ echo "File already exists"; } else { createThumbnail("/home/alanna/public_html/pics/full/", $imagename, "/ home/alanna/public_html/pics/thumb/", 100); }
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 !
Createimagefromjpeg With URL's Produces Black Image
i only see a black image when i use createimagefromjpeg with URL. i even used a native url and it is still the same. when i use direct path, i can see the image though. what could the possible cause be? this is run on linux server and allow_url_fopen is turned on.
View Replies !
Imagecreate :: Resized Images Appear As Black Squares
I dont know why this is happeneing, but all my resized images are being saved as just black squares. It uploads an image of the correct size, to the correct directory. problem is its just a vlack square that it creates. i cant get it to actually put the origional into it. From looking at the code i cant honestly understand why this doesnt work Code: <?php $image = imagecreatefromjpeg("../../member_pics/full_size/".$new_filename); if ($image === false) { die ('Unable to open image'); } $width = imagesx($image); $height = imagesy($image); // New width and height $new_hieght = "100px"; $new_width = "100px"; .........
View Replies !
Problem W/ Imagecreate() To Pdf ->image Printing Black Fuzz
this may be an issue with printer or something but i was wondering if anyone had seen this before?? info.... -the application is a work order request form that generates a pdf of form w/ user's input filled in. -a unique "request number" is created and is put in the pdf via imagecreate() - black text on a white background. for some people, the image/request number displays fine but when printed, is a black fuzzy block (see image below) taken from scan of printed form: http://www.alumni.uga.edu/it/beta/request_num_pdf.gif
View Replies !
Producing Strange Characters, ""...?
I've got a couple strange characters showing up at the top of a few of my PHP pages, but I'm not sure what's causing them. Have anyone seen something like this?  It's being outputed before any of my HTML. I've got all kinds of library/class files loaded, session management and a load of setup vars/constants. I can't seem to figure out what is causing it.
View Replies !
|