Php ile iki resmi birleştirme.
İki resmi birleştirip yeni bir image oluşturma
<?php
$files = $_FILES;
$file_name = tr_to_utf($value);
//1. fotoğraf
$file1 = $files['front'];
$source_path1 = $file1['tmp_name'];
$file_size1 = $file1['size'];
$ext1 = pathinfo($file1['name']);
//2. fotoğraf
$file2 = $files['back'];
$source_path2 = $file2['tmp_name'];
$file_size2 = $file2['size'];
$ext2 = pathinfo($file2['name']);
//dosya yolu
$today_root = "uploads/" .date('y-m-d');
if(isset($file1) AND isset($file2) AND $file_size1 != 0 AND $file_size2 != 0){
img_merge($source_path1,$source_path2,$file_name,$directory);
}
function img_merge($file1,$file2,$file_name,$directory){
$image1 = $file1;
$image2 = $file2;
$directory = $directory.'/'.$file_name.'.png';
list($width1,$height1) = getimagesize($image1);
list($width2,$height2) = getimagesize($image2);
$image1 = imagecreatefromstring(file_get_contents($image1));
$image2 = imagecreatefromstring(file_get_contents($image2));
$x1 = imagesx($image1);
$y1 = imagesy($image1);
$new_width = $width1+$width2;
$new_height = $height1+$height2;
$new_image = imagecreatetruecolor($new_width,$new_height);
imagecopyresized($new_image, $image1, 0, 0, 0, 0, $width1, $height1,$x1,$y1);
imagecopymerge($new_image, $image2, 0, $height1, 0, 0, $width2, $height2, 100);
if(imagepng($new_image,$directory)){
return true;
}
else{
false;
}
}
?>
PHP merge resim birleştirme Php
4/
5
Oleh
Root