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.





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 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 !
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 !
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 !
Trying To Make A Thumbnail But Fails
I created a file name image.php which contains only the following code:

<?php
function createThumbnail($picture,$thumb,$new_w,$new_h) {
$extension=substr($picture,strrpos($picture,".")+1);
switch (strtolower($extension)) {
case "jpg":
case "jpeg":
$src_img=imagecreatefromjpeg($picture);
break;
case "png":
$src_img=imagecreatefrompng($picture);
break;
case "gif":
$src_img=imagecreatefromgif($picture);
break;
case "bmp":
$src_img=imagecreatefromwbmp($picture);
break;
}

$old_x=imagesx($src_img);
$old_y=imagesy($src_img);

if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}elseif ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}else{
$thumb_w=$new_w;
$thumb_h=$new_h;
}

$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thum b_w,$thumb_h,$old_x,$old_y);

switch (strtolower($extension)) {
case "jpg":
case "jpeg":
imagejpeg($dst_img,$thumb);
break;
case "png":
imagepng($dst_img,$thumb);
break;
case "gif":
imagegif($dst_img,$thumb);
break;
case "bmp":
imagewbmp($dst_img,$thumb);
break;
}

imagedestroy($dst_img);
imagedestroy($src_img);
}
?>

This function successfully creates a thumbnail. The problem is that I
include it in another page (with include_once, just if it matters)
which creates a thumbnail, makes some db updates and then redirects to
another page. When trying to redirect with header("Location:
index.php"); it echos that header has already been sent from image.php.
The problem appears immediatly on include (I deleted the code that
calls the function to test it).
I think it is because I am using imagejpg(); function which outputs to
the browser but I don't know how to change this.

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 !
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 !
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 !
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 !
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 !
[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 !
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 !
No Libphp4.so File Created In Make Intstall Or Make.
I have done a make, and a make install on the 4.3.6 version, using
/usr/local/etc/php as the directory I make from. However, no matter what
I do, I do not see a php4lib.so that has been created. The documentation
I recieved (an IBM source) says that the following has to be added to the
httpd.conf file :

LoadModule php4_modulelib/apache/libphp4.so
..
..
..
AddModule mod_php4.c

here is the output from my make install :

[root@mail php]# make install
Installing PHP SAPI module: cgi
Installing PHP CGI into: /usr/local/bin/
Installing PEAR environment: /usr/local/lib/php/
[PEAR] Archive_Tar - already installed: 1.1
[PEAR] Console_Getopt - already installed: 1.2
[PEAR] PEAR - already installed: 1.3.1
Wrote PEAR system config file at: /usr/local/etc/pear.conf
You may want to add: /usr/local/lib/php to your php.ini include_path
[PEAR] DB - already installed: 1.6.2
[PEAR] HTTP - already installed: 1.2.2
[PEAR] Mail - already installed: 1.1.3
[PEAR] Net_SMTP - already installed: 1.2.3
[PEAR] Net_Socket - already installed: 1.0.1
[PEAR] XML_Parser - already installed: 1.0.1
[PEAR] XML_RPC - already installed: 1.1.0
Installing build environment: /usr/local/lib/php/build/
Installing header files: /usr/local/include/php/
Installing helper programs: /usr/local/bin/
program: phpize
program: php-config
program: phpextdist

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 !
Php Thumbnail
does anyone has a good script that will create a good thumbnail of a picture and save it to hdd.. i mean a script that he used and did the work good, i used like all the scripts avaible that google provides, they are or broken or they say that a image isn`t good, or just take the width and height from the image .

View Replies !
Thumbnail
when you view the graphics(glitter, layouts, etc..) it only displays 4 thumbnails - how can i have it display more thumbails? - i believe that is pulls from the file called thumbs.php which is coded as follows: Code:

View Replies !
Need Help With Thumbnail Function
I am using the following function to create thumbnail images on the fly. The image is created fine however I can't do any manipulation with it afterwards. For example I want to change image border when I put mouse cursor over it. The default image which is not converted from big image has this functionality. Also I can't see the source code of the page with thumbnail. Finally, The new thumbnail imege (which should be smller then original 4 times) is not created. Us there error in the code, or I am doing something wrong? Please help.

Here is code I use:

<?
Header("Content-type: image/jpeg");
$image = "1.jpg";
$defaultimg ="noimages.jpg";
if (file_exists($image)){
$img_orig = ImageCreateFromJpeg($image);
$new_width = imagesx($img_orig) / 4;
$new_height = imagesy($img_orig) / 4;
$img_sub = ImageCreateTrueColor($new_width,$new_height);
ImageCopyResampled($img_sub,$img_orig,0,0,0,0,$new_width,$new_height,imagesx($img_orig),imagesy($img _orig));
ImageJPEG($img_sub, '', 100);
ImageDestroy($img_orig);
ImageDestroy($img_sub);

echo" <img src=";
echo" $image";
echo" onmouseover="this.style.border=&#392;px solid blue'"";
echo" onmouseout="this.style.border=&#392;px solid black'"";
print" alt=";
echo" Click&nbsp;to&nbsp;Enlarge";
echo" >";}
else {
echo" <img src=";
echo" $defaultimg ";
echo" onmouseover="this.style.border=&#392;px solid blue'"";
echo" onmouseout="this.style.border=&#392;px solid black'"";
echo" >";}
?>

View Replies !
Thumbnail From Videos ?
anyone know a snippet or script that can take screenshot of a video and save
it as a thumbnail .jpg ?

View Replies !
Thumbnail Orientation
I'm using the code below to create thumbnails from photos. The code
works fine and thumbnails are created. However, thumbnails of vertical
photos are oriented as horizontal photos.

More info:
These photos come from a Nikon high end SLR digital camera. It's not my
camera so I have no control over how the image is taken.
If I open a vertical image in Photoshop (CS2), the image is oriented
correctly. When I try to create a thumbnail with php, the thumbnail is
always oriented incorrectly as Horizontal.

I did some further testing and tried opening the same image using
ImageMagic (on a Linux box). ImageMagic also sees the image incorrectly
as Horizontal.

There has to be some way to read the JPG file and determine if it's
meant to be a vertical or horizontal photograph. Are there any php
libraries that are capable of doing this?

Does anyone know the layout of a JPG binary well enough to tell me if
there is a specific flag set for orientation? ...

View Replies !
Video Thumbnail
I have many video on my server, wmv, mpeg, avi, etc...
I want to use php to catpure the first frame of the video into a
png/jpeg/mpg, how to?
thanks
from Peter (cmk128@hotmail.com)

View Replies !
Thumbnail Generator
Does anyone have a demo to look at for a very simple thumbnail generator for a jpg image? If a user uploads a jpg, and then a thumbnail is made of it.

View Replies !
Moving Thumbnail Possible In GD?
Is it possible to move the thumbnails(retrived from database) from right to left?
Please give function name or materials relating to it.

View Replies !
Thumbnail Without GD Library
I have a function that will create thumbnails of images but it requires the GD library. My new host doesn't have this and after contacting them there is no way to get it installed. Is there any other way of creating thumbnails that doesn't require the GD library? I would prefer a solution in PHP but if this is not possible then could it be done any other way?

View Replies !
Thumbnail Generation
I need to modify this code to upload the photo and create a thumbnail of that image in the thumbnails folder and was wondering of someone could help.  I first tried to just make it place the same image in both folders, but I don't know what I'm doing. It only follows the first upload command (either one places the image where it should, when it's first) and ignores the second... but I actually want it to generate a resized thumbnail anyway. Code:

View Replies !
GD Thumbnail Class
I am having a few problems with the following. Mainly speed, and apparent regeneration of thumbnails, even when they are cached. Code:

View Replies !
Thumbnail Function
I am creating a thumbnail with a function and want this function to return the file name so that it can be stored in the database - I also need to move the thumbnail to the destination on the server drive. Code:

View Replies !
Thumbnail Images
Does anyone have idea that how to thumbnail images, which are retrieved from database, then displaying them on webpage?

View Replies !
PHP Thumbnail Creation.
Does PHP's thumbnail creation ability cause high server load? I'm only doing about 10 thumbnails per page from images that aren't very large but my host is telling me that something in my PHP scripts is causing excessive server load.

Further to the above question, can a PHP script be written that creates a thumbnail then saves it as a file instead of as a temporary image?

View Replies !
Create Thumbnail
ive upload the pictures on this way:

<?php
if ($HTTP_POST_FILES["pict_1"]["name"]) {
  $dest="../destination/".$doc_id."_picture_name.jpg";
  copy($HTTP_POST_FILES["pict_1"]["tmp_name"], $dest);            
}
?>

this will resoult on server picture named example: 1_picture_name.jpg, 2_picture_name.jpg, etc. I want to upload (generate) the thumbnail picture in same time (paralell) as a picture with a same ID but a smaller size. (like: 1_th_picture_name.jpg, 1_th_picture_name.jpg...).

View Replies !
Display Thumbnail
I am tring to display a thumbnail without creating a a new image. I have a script that I reduce the image size to the size I need but I am having trouble displaying that image in a do while loop while pulling other info from a database.

I want to display all records in the database with a auto generated thumbnail for each record. The image name is stored in a field in the database. The original is stored in a folder.

View Replies !
Thumbnail Issues
im using the code. PHP Code:

$srcImg = imagecreatefromjpeg("/img1/$filename");
$origWidth = imagesx($srcImg);
$origHeight = imagesy($srcImg);

$thumbWidth = 200;
$thumbHeight = 133;

$thumbImg = imagecreate($thumbWidth, $thumbHeight);
imagecopyresized($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, imagesx($thumbImg), imagesy($thumbImg));

imagejpeg($thumbImg, "$filename", "img1/thumbs", 100);
......................

View Replies !
Thumbnail Directory
anyone know of a script that will read the contents of a directory and create a thubnailed list of all the images in the directory?

View Replies !
Colors Of The Thumbnail Seem To Be Off
I have a simple gallery that creates thumbnails from an image. Since my hosting provider upgraded it's version of GD, the colors of the thumbnail seem to be off:

http://www.vozz.ca/gallery/gallery2.php

like it's only displaying 256 colors or something? I had this simple script developed for me so I have no idea what functions I would need to place in my code, hopefully it's something simple.

View Replies !
Image Thumbnail
can anyone help me to get a script which shld be able to upload minimum 6 images and resize to generate thumbanail as well as save images in database.

View Replies !
Create Thumbnail For Jpg Or Gif Or Png
How can I create thumbnails using PHP? Code:

View Replies !
Thumbnail From Image In Db
i was looking for some php code that resizes images effectively creating a thumbnail without resaving and creating a new file. i found this but the problem is that it apparently only works with local urls linking to images files.

my images are stored in a mysql database and are retrieved with another php file called "getdata.php?id=x". this php file does work and i can view the original image fine. when i link to http:/mysite.com/pathto/thumbnail.php?url=getdata.php?id=x it gives me this error: Code:

View Replies !

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