Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form method="post" enctype="multipart/form-data">
- <input type="file" name="image">
- <input type="submit">
- </form>
- <?php
- if(isset($_FILES["image"])){
- // makeDP
- $sourcePath = $_FILES["image"]["tmp_name"];
- $design = "frame-1.png";
- $src = imagecreatefromstring(file_get_contents($sourcePath));
- $fg = imagecreatefrompng(__DIR__ . "/produk/$design");
- list($width, $height) = getimagesize($sourcePath);
- $croppedFG = imagecreatetruecolor($width, $height);
- $background = imagecolorallocate($croppedFG, 0, 0, 0);
- // removing the black from the placeholder
- imagecolortransparent($croppedFG, $background);
- imagealphablending($croppedFG, false);
- imagesavealpha($croppedFG, true);
- imagecopyresized($croppedFG, $fg, 0, 0, 0, 0, $width, $height, 400, 400);
- // Start merging
- $out = imagecreatetruecolor($width, $height);
- imagecopyresampled($out, $src, 0, 0, 0, 0, $width, $height, $width, $height);
- imagecopyresampled($out, $croppedFG, 0, 0, 0, 0, $width, $height, $width, $height);
- ob_start();
- imagepng($out);
- $image = ob_get_clean();
- // makeDPend
- $str="";
- $chars = "addzifiabcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- $size = strlen($chars);
- for($i = 0;$i < 10;$i++) {
- $str .= $chars[rand(0,$size-1)];
- }
- $url = $str;
- $loc = "order/" . $url . ".png";
- file_put_contents($loc, $image);
- echo $loc;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement