1

I'm creating a minecraft skin generator, but the php code doesn't show me the transparent image:

This is what it shows me: image: https://i.stack.imgur.com/pmldC.png

I can't put the images to show

It shows me the black background and what I'm trying to achieve is to make it transparent (white color)

Thus: image: https://i.stack.imgur.com/Q6D5y.png I can't put the images to show

This is the code I'm using:

<?php
// Crear instancias de imágenes
$origen = imagecreatefrompng("https://jose89fcb.es/SkinMinecraftVistaPreviaDiscord/navidad/Traje_entero.png");
$destino = imagecreatefrompng("http://textures.minecraft.net/texture/3084a678ada05e08058555c11383be71bf8419fa0c2fc89b5aa0be8d00aeb9a0");
$contenedor = imagecreatetruecolor(imagesx($destino), imagesy($destino));
 
//ver el tamaño de la original
// Copiar
imagecopy($contenedor, $destino, 0, 0, 0, 0, imagesx($destino), imagesy($destino));
imagecopy($contenedor, $origen, 0, 0, 0, 0, imagesx($origen), imagesy($origen));

 
// Imprimir y liberar memoria
header('Content-Type: image/png');
imagepng($contenedor);
 
imagedestroy($destino);
imagedestroy($origen);
imagedestroy($contenedor);
?>

These two images should be displayed in the same image: https://textures.minecraft.net/texture/3084a678ada05e08058555c11383be71bf8419fa0c2fc89b5aa0be8d00aeb9a0

https://jose89fcb.es/SkinMinecraftVistaPreviaDiscord/navidad/Traje_entero.png

Remaining the images like this: https://i.stack.imgur.com/7qdzI.png

Where is the problem?

Thank you very much in advance!

Can someone help me, thank you very much

julinha
  • 11
  • 2
  • Did you try [this](https://stackoverflow.com/a/15246907/128761)? Read at transparent background part. – vee Dec 09 '22 at 18:32
  • I've tested and it work, just check variable correctly from `$image` to be `$contenedor` – vee Dec 09 '22 at 18:56
  • appears the same I have tried with this code, but only an image appears: imagealphablending( $contenedor, false ); imagesavealpha( $contenedor, true ); – julinha Dec 09 '22 at 18:56
  • There are 4 lines of code but you use just 2? – vee Dec 09 '22 at 18:57
  • shows me a transparent box above: https://i.imgur.com/FXb0niZ.png – julinha Dec 09 '22 at 19:04

0 Answers0