title: PHP & JS - Jcrop - chosen PNG image has black background
body: <p>When I choose PNG file with transparent background in Jcrop container it is displayed with black background. When I crop it and save it, it is saved as <code>.png</code> file, but with black background as it was displayed in crop container.</p>
  
  <p>JS:</p>
  
  <pre><code>$('#image').Jcrop({
      bgColor: 'transparent',
      aspectRatio: 1,
      minSize: [180, 180],
      maxSize: [20000, 20000],
      onSelect: updateCoords,
      onChange: updateCoords,
      boxWidth: $('.modal-body', $imageUploadModal).width()
  });
  </code></pre>
  
  <p>PHP for saving images:</p>
  
  <pre><code>$target_w = $target_h = 400;
  
  $src = $request-&gt;request-&gt;get('src');
  $x = $request-&gt;request-&gt;get('x');
  $y = $request-&gt;request-&gt;get('y');
  $w = $request-&gt;request-&gt;get('w');
  $h = $request-&gt;request-&gt;get('h');
  
  ini_set('memory_limit', -1);
  
  $img_r = imagecreatefrompng($src);
  imagealphablending($img_r, true);
  
  $dst_r = ImageCreateTrueColor($target_w, $target_h);
  
  imagecopyresampled($dst_r, $img_r, 0, 0, $x, $y, $target_w, $target_h, $w, $h);
  
  $randomStringGenerator = new RandomStringGenerator();
  $filename = '/profile-pictures/'.$randomStringGenerator-&gt;generate(50).'.png';
  
  imagepng($dst_r, $filename);
  imagedestroy($img_r);
  imagedestroy($dst_r);
  
  ini_restore('memory_limit');
  </code></pre>
  
  <p>Any ideas what I could be missing? <code>bgColor</code> as I saw in multiple answers as solution does not have any effect and is not fixing the issue.</p>