Advertisement
taktikhek

Untitled

Jun 30th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. $sourcePath = $_FILES["file"]["tmp_name"];
  2. $design = "frame-1.png";
  3.  
  4. $src = imagecreatefromstring(file_get_contents($sourcePath));
  5. $fg = imagecreatefrompng(base_url('/assets/upload/image/produk/frame-1.png'));
  6.  
  7. list($width, $height) = getimagesize($sourcePath);
  8. $croppedFG = imagecreatetruecolor($width, $height);
  9. $background = imagecolorallocate($croppedFG, 0, 0, 0);
  10. // removing the black from the placeholder
  11. imagecolortransparent($croppedFG, $background);
  12. imagealphablending($croppedFG, false);
  13. imagesavealpha($croppedFG, true);
  14. imagecopyresized($croppedFG, $fg, 0, 0, 0, 0, $width, $height, 400, 400);
  15. // Start merging
  16. $out = imagecreatetruecolor($width, $height);
  17. imagecopyresampled($out, $src, 0, 0, 0, 0, $width, $height, $width, $height);
  18. imagecopyresampled($out, $croppedFG, 0, 0, 0, 0, $width, $height, $width, $height);
  19.  
  20. ob_start();
  21. imagepng($out);
  22. $image = ob_get_clean();
  23. // makeDPend
  24.  
  25. $str="";
  26. $chars = "addzifiabcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  27. $size = strlen($chars);
  28. for($i = 0;$i < 10;$i++) {
  29. $str .= $chars[rand(0,$size-1)];
  30. }
  31.  
  32. $url = $str;
  33. $loc = base_url('/assets/upload/image/order/') . $url . ".png";
  34. file_put_contents($loc, $image);
  35. echo $loc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement