[GD]: Open Existing Image(url) & Set A Transparent Color
lets say i output an image like this:
$img = array('somedomain.com/foo.jpg');
<img src="$img[0]" alt="" />
but it has a white background and i want to strip the white background to be transparent
how do i do that and output it inline again?
View Complete Forum Thread with Replies
Related Forum Messages:
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 !
Recognize Color In An Existing Image
If you have an existing jpeg/png picture file with an English sentence on it, can one determine the color of the words/font used (perhaps using GD with PHP)? I'm NOT talking about creating a new image with GD, and I don't want to translate the sentence in plain text (OCR). I just want to know how to automate recognizing a color in a certain position within a picture file.
View Replies !
Define The Transparent Color
I've made a script that takes images (in gif,jpg & png) and makes their thumbs in jpg format. Now, the problem is if I have a transparent gif when saved to jpg the part of the original picture that is transparent turns black in the new thumb. My question is: how can I define that the transparent part gets the color i want it to get (white is what i need) ? Actually, I now what in theory should be done. I should change the r,g,b values of the color that has aplha=127 (and that's not a problem with imagecolorset()), but also I should change the alpha of that color to 0. how can that be done ? My quess is that that is the right way to do it.
View Replies !
Creating Image From Uploaded Image And Transparent PNG
Say the client wants to be able to change the image, but not the text treatment, and doesn't have the Photoshop knowledge to actually replace it and re-save it themself. Is there anyway to use a PNG with the rounded edges, text treatment, and transparent center, have the client upload a standard rectangular-shaped image, and use PHP to layer the uploaded image underneath the transparent one, creating a new image file?
View Replies !
Transparent Image
Hi! Here's a piece of code: [begin] <?php Header('Content-type: image/png'); $sz = ""; $FileValue = 1000; $i = strlen($FileValue); for ( $j = 0; $j < 7-$i; $j++ ) { $sz = $sz . "0"; } $Img = imagecreate(56,13); $Gold = imagecolorallocate($Img,148,128,100); $Gray = imagecolorallocate($Img,32,32,32); ImageFilledRectangle($Img,0,0,55,12,$Gray); imagestring($Img,4,0,0,$sz.$FileValue,$Gold); imagepng($Img); ImageDestroy($Img); ?> [end] OK. Calling this script I have a png picture back. Now I add imagecolortransparent($Img,$Gray); just before imagepng() and OK again, I have a transparent picture back. But now, if I add: $r = imagerotate($Img,90,0); imagepng($r); just after the imagecolortransparent() instruction seen above, I get a rotated picture, but not transparent. How to solve that? I've used a plenty of tricks, no one works.
View Replies !
Transparent Text On Image?
Is it possible to place transparent text on an image? I want to display an image of some text in a fancy typeface, but superimpose text in a plain style, so that it can be copied and pasted; a bit like what you see in some PDF files, where the page image is visiable, the overlying text is not.
View Replies !
Take Existing Image
PHP Code: $logo = imagecreatefrompng("images/logo.png"); imageCopyMerge($img, $logo , 1, 1, 0, 0, 48, 48, 48); along with a bunch of other images, they show up faded and in some instances with some dark background.
View Replies !
Changing Existing Image
I am fetching data from an xml file where the format is: <firstname>David</firstname> <lastname>Rosberg</lastname> <division>ABC</division> <photolink>1_thumb.jpg</photolink> Using xforms i am able to change the firstname, lastname and divison fields but i am not able to change photolink from the webform. I need the user to change the existing image so that the new link is updated or replaced in the XML file.
View Replies !
Replace Existing Image
There is an XML file on the server which contains a photolink tag, storing the current location of the image. I want to enable the user (client-side) to upload a new image such that old path in XML file is replaced by the path of the new image.
View Replies !
Display Non-existing Image
if(!empty($a1[image])) { $im_array = explode("|", $a1[image]); $FirstImage = "<img src="re_images/$im_array[0]" width=250 height=200>"; $FirstImage1 = "<img src="re_images/$im_array[0]" width=30 height=20>"; $FirstImage2 = "<img src="re_images/$im_array[1]" width=30 height=20>"; $FirstImage3 = "<img src="re_images/$im_array[2]" width=30 height=20>"; $FirstImage4 = "<img src="re_images/$im_array[3]" width=30 height=20>"; $FirstImage5 = "<img src="re_images/$im_array[4]" width=30 height=20>";</a>
View Replies !
Select Image By Color
can any of u guys point me in the direction of a "select all images with this color" script? Like what they use @ istockphoto.com, where u get a pallette of colors and click the desired color, after wich a selection of images with the clicked color as dominant shows up.
View Replies !
Replace Color In Image With GD
I've been looking at php.net and here in the forums, but I cannot find the right function to replace a color in a image with GD. ie: I want to change the black color for white. Wich function should I use? I've been using imagecolortransparent() to transform the BLACK color to "transparent" but, I think is better to replace it to white.
View Replies !
GD And Changing The Color Of An Image
I'm trying to come up with a script that will change the color of a transparent png to a new color. Like #FF0000 to #0000FF. The images I'm using are solid color with a transparent background. Anyways it's not going so well. I have this script that works for palpated images but when I try to use it with an image that has alpha transparency it gets all weird on me and shows up as solid blocks of color. Code:
View Replies !
Apply Color To B/w Image
I have a grayscale image, (just three colors) and I want to use php to apply color to it, so it turns, say, blue. I have a ton of these greyscale images and a lot of colors, so I want to use php to do it when needed instead of doing them all by hand in photoshop. I have done some searching but I'm not even sure what to call this.
View Replies !
Replace One Color With Another In An Image?
I have the following script that replaces all red pixels on an image with a specified image tile, but I want to be able to swap the red with another hex color which I'll feed to the script. Could somebody show me how to do this? Code:
View Replies !
Change Image Color
I've made some progress today, and now have a map that will move to the correct area based on its thumbnail image. Many a thanks to vwphillips for sharing his javascript code to accomplish the map. Now I could use some suggestions on how to accomplish the next step in my project/experiment. And that is to be able to change the color of each country on the map to the color that is assigned to it in a database. The issue is that each country is not its own image. The map is actually composed of 100 sliced images that are 350px by 200px each. I'm not even sure its possible to segregate each country to its own image, as they consist of all different shapes.
View Replies !
Editing Colours In Existing Image- How?.
I'm having a little trouble finding out how to edit the colours of an existing image and output it through php. For example, if I tell it to read an image in a folder but change X colour, how would that be done? The only ways I've discovered so far involve images made there and then, on-the-fly, not existing files.
View Replies !
Bg Color Uploading Transaprent Image
I just have a simple upload and resize image for thumbnail code...and it works okay..my problem is.. if I'm uploading a transparent *.gif image it will create a black bg color for thumnail image..and for the original image as well..so is there any solution to this.I mean I want the image and the thumbnail still remain transparent when the uploading process done...not fill in the bg with black color..like what I have just now . PHP Code:
View Replies !
ImagePNG() - Write Text In An Existing Image Png.
I would like to write text in an existing image png. Like making a menu but in several languages. When I create a page with only the code below, it goes well. The text fits well in each 4 button which I make then reactive. On the other hand when I put this code in a cell of a table, it is the dump image which goes up. Here is the code: <? header("Content-type: image/png"); $im = imagecreatefrompng("images/4button.png"); $color = imagecolorallocate($im, 0, 0, 153); $string="Situation"; $px = (imagesx($im)-7.5*strlen($string))/2; imagestring($im,3,$px,16,$string,$color); $string="Piano Globale"; $px = (imagesx($im)-7.5*strlen($string))/2; imagestring($im,3,$px,61,$string,$color); $string="Contattarli"; $px = (imagesx($im)-7.5*strlen($string))/2; imagestring($im,3,$px,103,$string,$color); $string="Teletrasmissone"; $px = (imagesx($im)-7.5*strlen($string))/2; imagestring($im,3,$px,147,$string,$color); imagepng($im); imagedestroy($im); ?>
View Replies !
Image Resize Issue From Existing Script
I have been given a function that reads a folder and then creates thumbnails for every image in that folder, placing the thumb elsewhere. I now need to modify it so that it looks for one image only, and the value of that image is stored in a database. the script works, until now. Code:
View Replies !
Font Color In Jpeg Image (nearly) Always Orange
I am trying to run a basic script that displays an existing jpeg image and writes some text over it. Sounds simple, but I cannot seem to be able to colour the font correctly. In the example below it should be black but it comes out orange. In fact, even if I change the colour to 0, 0, 255 it's orange. I've read in the PHP documentation (the user contributed notes) that there are issues with jpeg font colouring. But I've not seen any details. Can anyone shed light on this for me please? The example code below is called as a function. The $image variable is a path to the existing image file and the $ttf variable is a path to a TrueType font. The $text variable contains a text string. header("Content-type: image/jpeg"); $base_image = imagecreatefromjpeg($image); $font = $ttf; $fontcolor = imagecolorallocate($base_image, 0, 0, 0); imagettftext($base_image, 18, 0, 10, 100, $fontcolor, $font, $text); imagejpeg($base_image); imagedestroy($base_image);
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 !
Open Image
I am using php to perform a query on a mysql table and then display the results on a page. Next to each result, i want to be able to display an image that pertains to that specific result. I do not want to upload theĀ images into the table due to space issues. Essentially, each result will have a 5 digit id variable that i am trying to name the images. So, for example, result a will have id 11111 so it would link to image 11111.jpg, result b will have id 22222, so it would link to image 22222.jpg. I tried the following without any luck- <IMG SRC="<?yourfield?>.jpg"> where yourfield is equal to the 5 digit number mentioned above. the only thing i get when the page is displayed is an empty image that is trying to point to ".jpg".
View Replies !
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 !
Open A Window And Fit An Image
The task is to open an enlarged version of a picture clicking on a thumbnail, so I would like the popup window fits the dimension of the big picture. The paths of the big pictures are stored in a mysql table and the size in pixel of each pic could be different. I started working on my task using also a bit of Java and sound like:
View Replies !
Open Window According To Image Specification
I am working on a realty script, and an idea was passed to me to have the script when a user views an ad open a popup window that matches the width and height of the image but i am lost. i am including my source that for any help you can provide. photos are called like this image.php?Id=30 PHP Code:
View Replies !
Open Source Image Gallery
I'm looking for an open source image gallery CMS, to provide a service similar to Flickr. I assume that Flickr is based on a proprietary system, but does anyone know of an open source solution that functions in a similar way? I've looked at Gallery and some other CMS's, but none of them have the user account systems and other features that I'd need.
View Replies !
Image Uploads Problems - Imagejpeg(): Unable To Open....
i have a image upload page that ive been assigned to fix, due to it apparently never working. I have a sneaky suspision that the storage directory for the images has not been set the required permissions. The main problem is that the server we are running the site on does not allow us access to the php.ini. Code:
View Replies !
Transparent GIF
I am trying to resize transparent GIF images, so I was reading, and they say to use fopen, fread, and read the first 13 bytes... OK, so I read in a transparent gif, and the first 13 bytes... and echo it out to the screen, and I get this: GIF89a�s�÷��What am I supposed to do with that? they then say "allocate that color as transparent, and use imagecopy(); to set the transparency back."
View Replies !
Transparent .png
This isn't totally related to php, but I am using a php generated page that is using transparent .png's. Anyway, when I view the page in Internet Explorer, the transparency within the png is replaced with grey?? But when I view it in Firefox it works fine?
View Replies !
Transparent GD Watermark.
Any one know what would be the best way to accomplish a transparent watermark on upload with GD that will work for Jpegs, Gifs and Pngs, using only GD in php 4?
View Replies !
Resize Transparent PNG
I have a basic script to resize a transparent png image. Code: $dimg = imagecreatetruecolor($newwidth, $newheight); imagecolortransparent($dimg, imagecolorallocate($dimg,0,0,0)); imagealphablending($dimg, false); imagecopyresampled($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); Problem is that my nice drop shadows are lost in resize. Does anyone know how I can keep them ?
View Replies !
Transparent Background
i'll try to explain myself the best i can, here is the problem: i have a html page and inside this i want to put an iframe that contains a php page. That's ok, i can do it and it works, but the problem is that i can't make that php document to have transparent background. it turns white. Is it because of the iframe? the php document has transparent background, but when i see it inside the iframe it doesn't work.
View Replies !
Two Transparent Colours
I have an image that I am opening and then merging onto another image, and it has two colours which I wish to make transparent, but it is not working, can you please give me an example of how to do this thanks. When I say that it is not working, I mean that when I allocate the second one, the first one is no longer transparent.
View Replies !
Transparent Overlay Watermark - On The Fly?
Is it possible to overlay a transparent watermark on an image - dynamically? I'd like the result to look like this example: <http://www.cycletourist.com/temp/photo.php> That is a bit of overkill, but you can see what I mean. The watermark image (a png image) is included separately below the photo. I tried using a class from phpclasses.org <http://www.phpclasses.org/browse/package/1580.html... but the result looks horrible. The transparency does not work. I found one other method through Google, <http://www.sitepoint.com/article/watermark-images-php> but it did not work, either. Can this kind of transparent overlay be done on the fly with GD lib?
View Replies !
Dynamically Transparent Gif's
Basically what i would like to do is dynamically set the transparency of a selection of images (GIF'S) depending on variables set in a My SQL Database. What i need to do is tint some jpg,s by setting the transparency of a solid blue gif which is set over the top of it in a table.
View Replies !
Imagegettftext Transparent Holes
I created an image, made it transparent, drew a rounded rectangle on it and then wrote on it with imagegettftext - where the text is there are transparent holes. $image = imageCreateTrueColor($width,$height); imageSaveAlpha($image, true); ImageAlphaBlending($image, false); $transparentColor = imagecolorallocatealpha($image, 255-$r, 255-$g, 255-$b, 127); imagefill($image, 0, 0, $transparentColor); $background = imagecolorallocate($image, $br, $bg, $bb); .......
View Replies !
Transparent Watermarks On Images
I'm using the code below to make a watermark and it's kinda working, but I want it semi-transparent as the PNG file is itself. Is there an easy way of overlaying transparent images in the GD library, so that the original image is merged in such as way that it can be seen through the watermark? Code:
View Replies !
Make Thumbnail Transparent
I have a script that will upload an image, then create a thumbnail of that image. When I upload an image with a transparent background the normal sized image comes out with a transparent background, but the thumbnail image comes out with a black background. Code:
View Replies !
Transparent Filled Polygon
I'm working on a map program where each building is clickable and when it's clicked the page is refreshed to show a map with the building highlighted (in red). I was wondering if it would be possible to highlight the buildings using some sort of combination of the imagepolygonfill function and a transparency function (i'd like the buildings to still be visible under the highlight), rather than having to create many different files with the different buildings highlighted.
View Replies !
Make A Colour Transparent
I would like to do is grab an image, determine what colour is at a certain pixel (maybe 10, 10) and then set that colour to transparent for the whole image. Basically it is so that I can dynamically place an image on various backgrounds for previewing. I am not worried about perfection (anit-aliasing, matte, etc).
View Replies !
.htaccess Transparent SESHID And Sessions
just putting the finishing touches on a shopping site and have run into errors in the process when users are blocking cookies. i am using: <IfModule mod_php4.c> php_value session.use_trans_sid 0 </IfModule> in my .htacess file to supress the PHPSESSID=22y3213etc. but it means that if a cookie isn't set the site fails to work properly. if i remove that from my .htaccess the site works fine because the PHPSESSID is passed around evey page, but it knackers things for SEO purposes. Code:
View Replies !
|