1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| <?php
$url = '../images/upload/'.md5(uniqid(rand(), true));
if(in_array($_FILES['file']['type'], array('image/jpeg', 'image/jpg'))) {
$url .= '.jpg';
move_uploaded_file($_FILES['file']['tmp_name'], $url);
$destination = imagecreatefromjpeg($url);
}
else if($_FILES['file']['type'] == 'image/png') {
$url .= '.png';
move_uploaded_file($_FILES['file']['tmp_name'], $url);
$destination = imagecreatefrompng($url);
}
$source = imagecreatefrompng('../images/design/griffe.png');
$largeur_source = imagesx($source);
$hauteur_source = imagesy($source);
$largeur_destination = imagesx($destination);
$hauteur_destination = imagesy($destination);
$destination_x = $largeur_destination - $largeur_source;
$destination_y = $hauteur_destination - $hauteur_source;
imagecopymerge($destination, $source, $destination_x, $destination_y, 0, 0, $largeur_source, $hauteur_source, 100);
if(in_array($_FILES['file']['type'], array('image/jpeg', 'image/jpg'))) {
imagejpeg($destination, $url);
}
else if($_FILES['file']['type'] == 'image/png') {
imagepng($destination, $url);
} |
Partager