Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $targ_w = $targ_h = 150;
- $jpeg_quality = 90;
- $src = $_POST['n'];
- $img_r = imagecreatefromjpeg($src);
- $dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
- $new_src = str_replace('/temp','',$_POST['n']);
- imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
- $targ_w,$targ_h,$_POST['w'],$_POST['h']);
- imagejpeg($dst_r,$new_src,$jpeg_quality);
- $targ_w = $targ_h = 150;
- $newImage = imagecreatetruecolor($targ_w, $targ_h);
- imagealphablending($newImage, false);
- imagesavealpha($newImage, true);
- $transparent = imagecolorallocatealpha($newImage, 255, 255, 255, 127);
- imagefilledrectangle($newImage, 0, 0, $targ_w, $targ_h, $transparent);
- $src = $_POST['n'];
- $img_r = imagecreatefromstring(file_get_contents($src));
- $img_r_size = getimagesize($src);
- $width_r = $img_r_size[0];
- $height_r = $img_r_size[1];
- if($width_r > $height_r){
- $width_ratio = $targ_w / $width_r;
- $new_width = $targ_w;
- $new_height = $height_r * $width_ratio;
- } else {
- $height_ratio = $targ_h / $height_r;
- $new_width = $width_r * $height_ratio;
- $new_height = $targ_h;
- }
- imagecopyresampled($newImage, $img_r, 0, 0, 0, 0, $new_width, $new_height, $width_r, $height_r);
- $new_src = str_replace('/temp','',$_POST['n']);
- imagepng($newImage, $new_src);
- imagealphablending($target_image, false);
- imagesavealpha($target_image, true);
Add Comment
Please, Sign In to add comment