Lagi galau, :mad
Nih script lagi, resize & gabung 2 poto pake script php :terharu
Penjelasan nya kapan kapan ya gan, udah lumayan ngantuk :malu

class prosesImage{ 
 function __construct($jpg, $png){
  $this->resize($jpg);
  $this->merger($png);
  unlink("resized.jpg");
 }
 function resize($jpg){
  $src_img = imagecreatefromjpeg($jpg);
  $old_x = imagesx($src_img);
  $old_y = imagesy($src_img);
  if($old_x>$old_y){
   $ratio = 800 / $old_x;
   $y = $old_y * $ratio;
   $x = 800;
  }else{
   $ratio = 600 / $old_y;
   $x = $old_x * $ratio;
   $y = 600;
  }
  
  $thumb_w = $x;
  $thumb_h = $y; 

  $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
  imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); 
  imagejpeg($dst_img, "resized.jpg", 100);
  imagedestroy($dst_img);
  imagedestroy($src_img);
 }

 function merger($png){
  list($x, $y) = getimagesize("resized.jpg");
  $base_image = imagecreatefromjpeg("resized.jpg");
  $top_image = imagecreatefrompng($png);
  $merged_image = "result.png";
  
  imagesavealpha($top_image, true);
  imagealphablending($top_image, true);
  
  imagecopy($base_image, $top_image, 0, 0, 0, 0, $x, $y);
  imagepng($base_image, $merged_image);
 }
}
$image = new prosesImage("nagita slavina.jpg","top.png");


Ntu scriptnya, kira2 ntar jadinya kek gini :

Keren kagak? :cambuk
soalnye pake foto idola ane, nagita slavina :terharu
Categories:

0 komentar:

Posting Komentar

Komentar anda tidak langsung tampil, tetapi akan di moderasi dulu.