PNG images become black colored during create image

Ads
 

PNG images become black colored during create image

if($sFileExtension == "PNG" || $sFileExtension == "png")
{
$img1 = @imagecreatefrompng($file);
}
else
{
    $img1 = imagecreatefromjpeg($file);
}
$width1 = @imagesx($img1);
$height1 = @imagesy($img1);
if ($width1 > $height1)
{
    $y1 = 0;
    $x1 = ($width1 - $height1) / 2;
    $smallestSide1 = $height1;
}
else
{
    $x1 = 0;
    $y1 = ($height1 - $width1) / 2;
    $smallestSide1 = $width1;
}
$thumbSize1 = 160;
$thumb1 = imagecreatetruecolor($thumbSize1, $thumbSize1);

imagecolortransparent($thumb1, imagecolorallocatealpha($thumb1, 255, 255, 255, 127));
imagealphablending($thumb1, false);
imagesavealpha($thumb1, true);
@imagecopyresampled($thumb1, $img1, 0, 0, $x1, $y1, $thumbSize1, $thumbSize1, $smallestSide1, $smallestSide1);

if($sFileExtension == "PNG" || $sFileExtension == "png")
{
    imagepng( $thumb1, $file);//third parameter is $quality its option
}
else
{
    imagejpeg( $thumb1, $file);//third parameter is $quality its option
}
View Answers

Ads









Related Tutorials/Questions & Answers:
PNG images become black colored during create image
PNG images become black colored during create image  if($sFileExtension == "PNG" || $sFileExtension == "png") { $img1 = @imagecreatefrompng($file..., $smallestSide1); if($sFileExtension == "PNG" || $sFileExtension == "png") { imagepng
how to re size image proportionately using java for different images like jpeg, png, gif.
how to re size image proportionately using java for different images like jpeg, png, gif.  hi, i need sample code for re size image proportionately using java for different images like jpeg, png, gif, this code for my
Advertisements
Retrieving images from the oracle database using jsp and create that rretrieved image as hyperlink
Retrieving images from the oracle database using jsp and create that rretrieved image as hyperlink  I want to insert images into oracle database.I want to retrieve images using jsp and I want to display on the browser.The
How to change the color of a base64-encoded png image JQuery?
How to change the color of a base64-encoded png image JQuery?  I am going to change the colors of the pixels of a png image(which is in base64 format...;; //"data:image/png
combining 5 images and text in between to one single image in java
combining 5 images and text in between to one single image in java  Hi I have to combine 5 images and text in between to one single image. I have... and create and single image for download. any help would be appreciated. Thank you
create dynamic image gallery jquery
create dynamic image gallery jquery  How to create a dynamic image gallery in Jquery
noise during print screen
noise during print screen  hi there, i have a java program which can print screen every 1 seconds... but during the print screen, the image seems will have some noise and ends up half page of the image will be black screen
PNG and JPG
PNG and JPG  hii, When to use PNG or JPG in iPhone development?   PNG's are pixel perfect (non-lossy), and require very little extra CPU... process. But the typical compression and image quality is usually quite sufficient
How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java
How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java  How To Store Multilple Images In MySQL database dynamically with image uploader
Animating Images in Java Application
images. Image are given below: In this program, images are displayed one... has been used to show images on the frame one by one during the 1000... Animating Images in Java Application   
How to create a JTable cell containing Image hyperlink?
How to create a JTable cell containing Image hyperlink?  I'm trying to find out how to create a JTable cell which contains Image, which should be clickable like an hyperlink. I'm able to load Image using default image renderer
Image Size
file name that has the extension either GIF, JPEG or PNG and returns an image... Image Size       This Java awt (Abstract Windowing Toolkit) tutorial describes about the image size
how to create menubar and the below background color/image in java swing
how to create menubar and the below background color/image in java swing  how to create menubar and the below background color/image in java swing
images
images  code for displaying image in java swings
How to make an animated black & white focus on the color photograph, animated black & white focus on the color photograph
How to make an animated black & white focus on the color photograph... interesting because I have tried here to make a black and white focus on the colored picture. Take a picture: First take colored picture to modify. Draw a circle
ModuleNotFoundError: No module named 'colored'
ModuleNotFoundError: No module named 'colored'  Hi, My Python... 'colored' How to remove the ModuleNotFoundError: No module named 'colored... to install padas library. You can install colored python with following command
ModuleNotFoundError: No module named 'colored'
ModuleNotFoundError: No module named 'colored'  Hi, My Python... 'colored' How to remove the ModuleNotFoundError: No module named 'colored... to install padas library. You can install colored python with following command
Java Write To Image File Example
need to do the following At first create an instance of your original Image file as /* Create new Image File Object */ File origionalImage = new File("myImage.jpg"); Create an ImageBuffer object of Origional Image as /* Read
Java Script With Links and Images
of JavaScript and create your first JavaScript program. JavaScript Images... that need to be edited to create JavaScript image swapping.  The JavaScript..., in this case black) then changes to display a second image in this place.  
images upload
images upload  I use netbeans IDE 6.8 How i upload any image from any folder to web page
uistatusbarstyle black translucent is not available on this device
uistatusbarstyle black translucent is not available on this device  .... And i am displaying images in a scroll view, i get this error while view get loads. uistatusbarstyle black translucent is not available on this device
Version of com.keypoint>png-encoder dependency
List of Version of com.keypoint>png-encoder dependency
ModuleNotFoundError: No module named 'myon-png'
ModuleNotFoundError: No module named 'myon-png'  Hi, My Python... 'myon-png' How to remove the ModuleNotFoundError: No module named 'myon-png... to install padas library. You can install myon-png python with following
ModuleNotFoundError: No module named 'png_util'
ModuleNotFoundError: No module named 'png_util'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'png_util' How to remove the ModuleNotFoundError: No module named 'png_util
ModuleNotFoundError: No module named 'png_util'
ModuleNotFoundError: No module named 'png_util'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'png_util' How to remove the ModuleNotFoundError: No module named 'png_util
dyanamic upload of images using struts without database connection
dyanamic upload of images using struts without database connection  I want to upload images dynamically with out using data base..and want to create image for every user in my db
how can create pop() method in this program ,Or how can delete image in it when i press pop button in runtime ??? please help me ...
how can create pop() method in this program ,Or how can delete image in it when...(new BorderLayout()); //Load the pet images and create an array of indexes...;// these image that put in program must be in the same folder that saved the program
ModuleNotFoundError: No module named 'colored-glog'
ModuleNotFoundError: No module named 'colored-glog'  Hi, My Python... 'colored-glog' How to remove the ModuleNotFoundError: No module named 'colored-glog' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'colored-glog'
ModuleNotFoundError: No module named 'colored-glog'  Hi, My Python... 'colored-glog' How to remove the ModuleNotFoundError: No module named 'colored-glog' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'colored-traceback'
ModuleNotFoundError: No module named 'colored-traceback'  Hi, My... named 'colored-traceback' How to remove the ModuleNotFoundError: No module named 'colored-traceback' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'colored-traceback'
ModuleNotFoundError: No module named 'colored-traceback'  Hi, My... named 'colored-traceback' How to remove the ModuleNotFoundError: No module named 'colored-traceback' error? Thanks   Hi, In your

Ads