I just discovered this forum and I hope you will be able to help me
I have this weird problem with this code :
Code: Select all
<?php
// ouvre l'image d'origine
$theimage = "upload/images/tmp/logo.png";
$im = imagecreatefrompng($theimage);
// détermine sa taille
$size = getimagesize($theimage);
$w = $size[0];
$h = $size[1];
// crée l'image de sortie
$im2 = imagecreatetruecolor($w/2,$h/2);
imagealphablending($im2,false);
imagesavealpha($im2,true);
// remplit l'image de sortie
imagecopyresampled($im2,$im,0,0,0,0,$w/2,$h/2,$w,$h);
// affiche l'image
header("Content-type: image/x-png" );
imagepng($im2);
?>
Now here is the tricky part : I'm using KCfinder for image uploading/management and I created a page where you can "jcrop" any image from the library.
Please, keep in mind that, to avoid any problem, I set all folders and file to 777 !!
Everything works fine with jpeg (imagecreatefromjpg) image part (same code except for the function calls) !
My problem comes with png images uploaded with KCfinder, somehow, they don"t have the same owner/group or something but I cannot understand how this could change anything with a 777 permission.
If I use imagecreatefromJPG for my png, it works but I lose the png's transparency.
If I use the code above with a ftp uploaded picture, it works !
If I use the code above with a KCFinder uploaded picture, I get this error :
Code: Select all
Warning: imagecreatefrompng() [function.imagecreatefrompng]: 'upload/images/tmp/logo.png' is not a valid PNG file in /test.php on line 4