Unione di due immagini (con una delle due ruotata)

Giacomo Torricelli

Nuovo Utente
25 Apr 2013
7
0
0
32
www.mumbleideas.it
Ciao a tutti,
ho fatto queste due pagine:

merge.php
PHP:
<?php 
// Load the stamp and the photo to apply the watermark to
$im = imagecreatefromjpeg('images/ita.jpg');
$stamp = imagecreatefrompng('rotate.php?img=images/profilo.png');

// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);

// Copy the stamp image onto our photo using the margin offsets and the photo 
// width to calculate positioning of the stamp. 
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));

// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

rotate.php
PHP:
<?php
	if(isset($_GET['img'])) {
		header('Content-type: image/png');
		$img = $_GET['img'];
	} else {
		exit("You don't have access to this page");
	}
	
	$deg = -45;
	if(isset($_GET['deg'])) {
		$deg = $_GET['deg'];
	}
	
	//ROTAZIONE IMMAGINE
	$destimg = imagecreatefrompng($img);
	$transColor = imagecolorallocatealpha($destimg, 255, 255, 255, 127);
	$rotatedImage = imagerotate($destimg, $deg, $transColor);
	imagesavealpha($rotatedImage, true);
	imagepng($rotatedImage);

?>

In pratica la rotate.php mi crea una copia dell'immagine che gli do io da input e me la ruota di quanti gradi dico io e la merge.php DOVREBBE unire un'immagine di sfondo (statica) e un'immagine che io gli ruoto già tramite la rotate.php

Non capisco perchè non funzioni e mi visualizzi solo l'immagine si sfondo senza lo $stamp sopra.

Grazie,
Giacomo
 
L'ho modificato così ma non funziona comunque...
PHP:
<?php
	header('Content-type: image/png');
	$under = imagecreatefromjpeg('images/ita.jpg');
	$over = imagecreatefrompng('images/profilo.png');
	
	$destimg = $over;
	$transColor = imagecolorallocatealpha($destimg, 255, 255, 255, 127);
	$rotatedImage = imagerotate($destimg, -30, $transColor);
	imagesavealpha($rotatedImage, true);
	//imagepng($rotatedImage);
	//imagejpeg($under);
	//$rotatedImage -> Immagine ruotata
	//$under        -> Bandiera italia
	//$over         -> Immagine profilo default
	
	imagecopy($under, $rotatedImage, 0, 0, 0, 0, 50, 50);
	
?>
:incazz:
 

Discussioni simili