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.





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 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 !
[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 Replies !
Can You Define An Array Constant With Define()?
I have a list of related defines like:

define( "FRUIT1", "apple" );
define( "FRUIT2", "banana" );
define( "FRUIT3", "orange" );

I'd rather keep these defined in one file only so that later when I decide to modify or add to the list I don't have to mess with all my other files.

Elsewhere, I'd like to loop through the constants and be able to obtain their values. This code is fine except that printf() and echo() return the constant name not the value:

$i = 1;

while( defined( "FRUIT$i" ) )
{
echo 'FRUIT$i'
$i++;
}

Ideally, I could define an array constant like this:

define( "FRUIT", { "apple", "banana", "orange" } );

but I don't think PHP allows this. I'd rather not define these as variables and have to mess with calling them in as global variables later, etc.

Any ideas? At the very least, perhaps someone knows how to trick a function like echo() to 'echo( FRUIT1 )' rather than 'echo( "FRUIT1" )'.

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 !
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›&#65533;s&#65533;÷&#65533;&#65533;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 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 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 !
GD: Testing A Pixle To See If It's Transparent?
How would I determine if a pixel is 100% transparent on a given image?

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 !
Find Out If An Image Is A Transparent Gif
Does anybody know if there's an easy way to find out if a given image is a transparent gif? (GIF89a)

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 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 !
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 !
Add Transparent Copyright Text To Image
I need a way to add a transparent copyright message (e.g. copyright 2002 together with my company logo) to my photos on the fly. My photos come in many different formats, such as PNG, GIF and JPEG.

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 !
GIF Resize Resample Transparent Fill
I am currently trying to create what I would think is simple. I want to create a image.php file and have it resize a 80 x 80 image to 29 x 29 with out losing the quality. When I try to have the gif image imagefill with the color white (255,255,255) it holds up and ends with a timeout. The gif images also have the black pixels if i don't try filling.

Does anyone know a simple script to just resize a gif/jpg file? All documentation has been pretty bad so this is first time posting.

View Replies !
Create Or Resize Transparent .png - Drop Shadow - GD IM
I've searched and d/l'd but cant seem to find a way of creating
a semi-transparent drop shadow for an image.

Let me say, be fore I go on, I *do not* want one of those scripts that
resizes your image a bit to the left and bottom, and then grafts a
shadow onto it. I want to use a full shadow (it would be about as big
as the image) and shift it a bit with CSS. So, I will have the image
sitting in a DIV which will have the shadow as a bg. This works fine
doing it manually.

So, I would like to find one of two alternatives:

1. (best) Create the shadow from given parameters(size, darkness,
spread, etc.) I will write the .png to a folder, I dont really need to
create it dynamically each time, but want the ability for the future
(galleries) and for when I'm in development and images are changing,
moving around, etc.

2. (will work) Take a pre-existing shadow and resize it as needed, but
has to keep the transparency.

View Replies !
How Do I Echo A Binary Array (transparent Pixel)
What am I doing wrong here? I want to display a transparent pixel...

<?
$transparent1x1 = array (71, 73, 70, 56, 57, 97, 1, 0, 1, 0, -128, 0,
0, 0, 0, 0, 0, 0, 0, 33, -7, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0,
1, 0, 0, 2, 2, 68, 1, 0, 59);
header("Content-type: " . image_type_to_mime_type (IMAGETYPE_GIF));
echo $transparent1x1;
?>

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 !
Security - Detect If A Client Is Connecting Through A Proxy(inluding Transparent) Or Not.
I want to detect if a client is connecting through a proxy(inluding transparent) or not.  What measures can I take to authenticat the source of the request before I even ask for login details. $_SERVER['REMOTE_ADDRESS'] is the only thing I can think of using but surely it is not sufficient to trust its value.

View Replies !
Put Transparent Layer That Disable Page Element At The Time Of Processing Ajax
I have made web page in php with the help of ajax and javascript. I want to do whenever page processing for ajax for that time I want to put some transperent layer that will disable the back pages element.. I have seen one site but I dont remember.

View Replies !
Define()
When I create different directories, my header and footer no longer show up because they're not in the same directory. I want to create a directory structure to make it a little easier for me to navigate and organize my site. I've seen define() used to set a directory path for includes, but i'm unsure of how it works. I'm thinking I would have to make a config.php and set all my path to my included files. I'm lost after that.

View Replies !
Define ()
I have the following code: PHP Code:

$path = "/home/web/public_html/user/images/".$_SESSION['Userid']."";
echo $path;
define('SFU_REALPATH', '/home/web/public_html/user/images/$_SESSION[Userid]');

When I echo $path it shows up as:
/home/web/public_html/user/images/2

but when I do echo SFU_REALPATH it shows up as:
/home/web/public_html/user/images/$_SESSION[Userid]

Why doesn't it resolve in the define() but does outside of it?

View Replies !
DEFINE
I use a smarty template system, where the language is stored in defined vals and I just pass them to the appropriate variable: Code:

View Replies !
Using Define Or Not?
what is the advantage of using:

define (VAR, "this and that");

over

$VAR = "this and that" ;

is one method frowned upon? depreciated?

or is it down to personal choice?

View Replies !
Define $q_
PHP Code:

//month as current month
$present_month = getdate();
$q_month = $present_month["month"];

View Replies !
Define Vars
I have a form with this vars:

var1
....
var50

is there any workaround that instead i do this: PHP Code:

View Replies !
Define What Can And Can't Be Done With Sessions
I am looking at the posibility of using session management in my site. I was wondering whether someone could clearly define what can and can't be done with sessions. I have managed to pass everything apart from database resource ids and class objects.

My question is, Is this possible and if so how? I would also be interested on peoples views on PHP Session management, whether it is worth while incorporating it into your site.

View Replies !
PHP3 And Define()
I know this might be an odd question, but does PHP version 3 support the define() function?  What little PHP 3 documentation I have doesn't seem to contain the function, but I would think PHP 3 would support constants.  I realize that upgrading and using PHP 4 and PHP 5 would give me the define() function, but that's not what I'm looking for, just the answer to this specific question.

When the manual says, "PHP 4, PHP 5" and excludes "PHP 3" it's not always accurate, as there are many functions supported by PHP 3 not listed in the current manual.

View Replies !
Strpos() To Define PHP SELF
I'm trying to make a script that can be placed at the top of an included file. For example if I place this script in config.php then only index.php or admin.php could include it without dying with the error. For some reason the if statement doesn't work as I had expected. Any file (eg: test.php) I include config.php into, still loads without dying.


$self = $_SERVER["PHP_SELF"];
$index = strpos($self, "index.php");
$admin = strpos($self, "admin.php");

if (($index === false) ¦¦ ($admin === false))
{
die ("You can't access this file directly...");
}

However this works...

if ($index === false) // or admin.php, either works, but only one.
{
die ("You can't access this file directly...");
}

I've also tried doing this with index.php and admin.php in an array, and it still doesn't work as expected. I'd prefer to have the script be something like the following. Naturaly it does notwork either when having two strpos() functions.

$self = $_SERVER["PHP_SELF"];

if ((!strpos($self, "index.php")) ¦¦ (!strpos($self, "admin.php")))
{
die ("You can't access this file directly...");
}

View Replies !
How Would I Define A Variable From This?
How can i assign the result for the return of user.username to a variable in this function? Code:

View Replies !
Define Your Ideal IDE
While lurking at Delphi, I thought of coming up with better IDE for PHP. So, define your ideal IDE. Just explain the killing features you want or expecting instead of mentioning other available IDEs.

View Replies !
Define Question
I have defined the following like so:

define('FIELD_ONE_NAME','client');

What i then want is to use that value (in this case its 'client') as a variable

So i will then have access to $client

Is this possible? I thought the syntax was something like:

PHP Code:

View Replies !
Use A Variable Before Define It
the code like : PHP Code:

echo $var;
/*
............some code


*/
$var=111;

any idea ?

View Replies !
Define Instead Of Text
I am using an open source shopping cart and I'd like to make a category heading an image instead of text. This is what was there originally:

define('BOX_HEADING_CATEGORIES', 'Categories');

I have looked all over the web and found a couple of ways to do this, but neither work. I am not receiving error messages but the images do not show up. The first is:

define('BOX_HEADING_CATEGORIES', '<img src="/images/myimage.jpg">');

and the second is:

define('BOX_HEADING_CATEGORIES', '[img]/images/myimage.jpg[/img]');

What will work for this?

View Replies !
Define As A Class Name
I have the following code:

define('MYCLASS', 'this_class');

$myobj = new MYCLASS();

php complains that it can't find the class MYCLASS.

$MYCLASS = MYCLASS;
$myobj = new $MYCLASS();

View Replies !
Loop In A Define
I'm struggling on the syntax for adding in a loop to a define statement. Is there a way to do this? I'm looking to do something like the following

define("NAME_LIST", " while($row = mysql_fetch_array($result) {
echo $row['username'];
} ");

View Replies !
'const' And 'define()'
What is the difference between 'const' and 'define()' ? When would I prefer using 'const' over 'define', or vice versa? It seems if i do:

const secondsInMinute = 60;
define("secondsInMinute", 60);

View Replies !
Some Advice On Define()
Is there any advantage to using define() instead of just setting a variable?
I've not really used define before, but was just wondering what difference it made:

<?php
// What's the difference between this:
define('MY_VARIABLE', 'my value');

// and this:
$myvariable = 'my value';
?>

View Replies !
Define And Variables
I'm working with the PHP define and I'm trying to figure out if it's possible to get the value of a defined by using a variable, I've tried the code below but no luck. Display 1 returns the value two, but Display 2 returns the value one (trying to set it up so it would return the value of the defined).

$jcm1='one'
$jcm2='two'
$jcm3='one'

define($jcm1, $jcm2);

echo 'Display 1: '.one;
echo '<br />'
echo 'Display 2: '.$jcm3;

View Replies !
Include - Define It From Within Each File.
I want to include a file in my files include('header.inc');

but I want to define a variable from within the script.
like this

include('header.inc');
$title="homepage";

something like that. $title will be used in header, but I want to be able to define it from within each file, so that I can name pages, yet have all the html in each of the included files.

View Replies !
Define More Than One Constructor With Different Arguments
Does anyone know if you can define more than one constructor with different arguments in a php class?

View Replies !
How To Define A New Global Function?
Very frequently, I need to use codes like this to see output clearly:

$a=print_r($var,true);
echo "<pre>$a</pre>";

How can convert this piece of code to a global function (for example:
echopre) in Php so that I can use echopre($data) anywhere in php
program (in my server)?

View Replies !
Universally Define __call( ) ?
I want to universally define the __call() method, so that every class
in my application does the same thing if a non-existant function is
called.

In actionscript I could do this by adding the definition to the
prototype for Object.

Is there any way to do that in php 5? I could make every one of my
classes inherit from like an Object class that I define,

View Replies !

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