Вопрос по php – Файл PNG НЕ сохраняет прозрачность?

1

Error: User Rate Limit Exceeded

$ROOTDIR = $_SERVER["DOCUMENT_ROOT"];
$ROOTFILE = "http://www.scottandjessiecooper.com/webtutorials/images/smiley.png";
$NEWFILE = "$ROOTDIR/images/tmp/new_smiley.png";

Error: User Rate Limit Exceeded

function save_image($root, $saveto){
    copy($root, $saveto);
}
save_image( $ROOTFILE, $NEWFILE ); // root can be file or url

Error: User Rate Limit ExceededNEEDError: User Rate Limit ExceededIMAGE_RESOURCEError: User Rate Limit ExceededROOTFILEError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

if ( file_exists( $NEWFILE ) ) unlink ($NEWFILE);
$image = imagecreatefrompng( $ROOTFILE );
imagepng( $image, $NEWFILE );
imagedestroy( $image );

Error: User Rate Limit Exceeded

<img src="<?=$NEWFILE?>" />

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededsavingError: User Rate Limit Exceeded

if ( file_exists( $NEWFILE ) ) unlink ($NEWFILE);
$image = imagecreatefrompng( $ROOTFILE );
header('Content-Type: image/png');
imagepng( $image );
imagedestroy( $image );

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Ваш Ответ

5   ответов
4

Error: User Rate Limit Exceeded
Error: User Rate Limit ExceededimagecreatefrompngError: User Rate Limit Exceeded AlexMorley-Finch
Error: User Rate Limit Exceeded
2

GDPHP.

PNGRGB modeIndexed mode.

Error: User Rate Limit Exceeded
1

$info = getimagesize("smiley.png");
$image = imagecreatefrompng("smiley.png");
$image_new = imagecreatetruecolor($info[0],$info[1]);       
if ( ($info[2] == IMAGETYPE_GIF) || ($info[2] == IMAGETYPE_PNG) ) {
  $trnprt_indx = imagecolortransparent($image);   
  if ($trnprt_indx >= 0 ) {   
     $trnprt_color    = imagecolorsforindex($image, $trnprt_indx);   
     $trnprt_indx    = imagecolorallocate($image_new, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);   
     imagefill($image_new, 0, 0, $trnprt_indx);   
     imagecolortransparent($image_new, $trnprt_indx);
  }
  elseif ($info[2] == IMAGETYPE_PNG) {
     imagealphablending($image_new, false);   
     $color = imagecolorallocatealpha($image_new, 0, 0, 0, 127);   
     imagefill($image_new, 0, 0, $color);   
     imagesavealpha($image_new, true);
   }
}
imagecopy($image_new,$image,0,0,0,0,$info[0],$info[1]);
imagepng($image_new,"smiley2.png");
1

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

imagesavealpha($image, true);
imagepng( $image, $NEWFILE );

Error: User Rate Limit ExceededcopyError: User Rate Limit Exceeded

0

$black = imagecolorallocate($im, 0, 0, 0); 
// Make the background transparent 
imagecolortransparent($im, $black);

Error: User Rate Limit Exceeded AlexMorley-Finch
Error: User Rate Limit Exceeded AlexMorley-Finch
Error: User Rate Limit Exceeded

Похожие вопросы