title: imagecreatefrompng() transparent part of png is black
body: <p><img src="https://i.stack.imgur.com/otgIp.png" alt="elaphant"></p>
  
  <p>I am creating a poster using PHP and I want to add figures on the poster. </p>
  
  <p>I use the following code to add them:</p>
  
  <pre><code>$src1 = imagecreatefrompng("m2.png");
  $widthsrc=0;
  $heightsrc=0;
  list($widthsrc, $heightsrc, $typesrc, $attrsrc) = getimagesize("m2.png");
  
  $background = imagecolorallocate($src1, 0, 0, 0);
  imagecolortransparent($src1, $background);
  imagealphablending($src1, false);
  imagesavealpha($src1, true);
  
  imagecopyresampled($my_img,$src1,$line2X1+100*$resize,$line2Y1,0,0,1000*$resize,1000*$resize,$widthsrc,$heightsrc);
  </code></pre>
  
  <p>The problem is that the places that the figures should be transparent, they are black.</p>
  
  <p>I have already looked at the following posts:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/2611852/imagecreatefrompng-makes-a-black-background-instead-of-transparent">imagecreatefrompng-makes-a-black-background-instead-of-transparent</a></li>
  <li><a href="https://stackoverflow.com/questions/23502749/php-resizing-png-images-generate-black-background">hp-resizing-png-images-generate-black-background</a></li>
  <li><a href="https://stackoverflow.com/questions/16278340/png-has-black-background">png-has-black-background</a></li>
  </ol>
  
  <p>But I haven't been able to create a solution that works for me.</p>