Hello, please sign in or register
You are here: Home

Automatic Image Rotate n degrees and Merge

Here's what we want to achieve. Take the front cover of our brochure and a background image. Rotate the cover and merge to the background.

+ =

Here's the script.  Requires GD enabled

<?php
// File and rotation
$cover = 'cover.jpg';
$background = 'background.jpg';
$degrees = 17;

// Content type
header('Content-type: image/jpeg');

// Load
list($width, $height) = getimagesize($cover);
$cover = imagecreatefromjpeg($cover);
$new_width = 260;
$new_height = 295;
$foreground = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled( $foreground, $cover , 0 , 0, 0 , 0 , $new_width , $new_height , $width , $height );

$background = imagecreatefromjpeg($background);
list($width, $height) = getimagesize($filename);
// Rotate
$rotate = imagerotate($foreground, $degrees, 0);

imagecolortransparent($rotate, imagecolorat($rotate,0,0));
$merged = imagecopymerge($background,$rotate,0,0,-6,1,300,360,100);

// Output
imagejpeg($background, null, 100);
?>

 

Comments

Tory Burch Outlet
Marina-born Karena Reyes is positively hooked on Tory Burch Outlet video games, cake decorating. She's stimulated by going on a vacation and checking out different countries including Limassol,Cyprus.
Created 08/05/12
Nike Air Max
Sunnyvale-born Gunne Olander hobbies include Nike Air Max yoga andfitness, building dollhouses. Last but not least she is get most her enthusiasm by checking out a Los angeles kings icehockey-match at the ar...
Created 09/05/12
nike free run sko
San Jose-born and raised Zeynep is addicted to nike free run sko, radio controlled gizmos, writing. The things she prize among the most is following a Boston bruins ice-hockey-game in real life.
Created 12/05/12
nike air max
Burlington-born Rosenda hobbies and interests include nike outlet Nike Air Max, ancestry andgenealogy, hang gliding. And lastly, she is intrigued by following a New york islanders hockey-game in the arena.
Created 13/05/12
tory burch flats
Greengrocer Jame Lamendola is addicted to http://www.tory-burch--flats.com tory burch outlet .http://www.nikefreerun-30.com/ nike free 3.0 barbecuing fast cars. Lastly the thing that she cherish the most is travelling by air, exploring different citi...
Created 24/05/12
mulberry outlet
Created 25/05/12
mulberry outlet
Created 25/05/12
Rotating using jquery and save image using php
Hi, I am developing a application which rotate an image using jquery plugin and using php I am saving the image as exact. I am facing an issue rotated image with different position to place, when rotate the image position changes. I am not able to sa...
Created 05/06/12
nike free run
thanks for the great post. it reminds me that i have to bring more structure into my blogging. your blog is very interesting
Created 09/08/12
Adidas F50 Adizero
this blog is definitely an example of a huge help for me since i am just starting a blog myself
Created 26/09/12
Why the rotated picture has a black border
This article is good,but why the rotated picture has a black border?Can anybody fix it?
Created 05/06/13
shuaishsushu
www.louisvuitton.com michael kors uk
Created 23/09/14
ben
www.louisvuitton.com michael kors uk
Created 06/10/14
benshushu
michael kors outlet online coach outlet store online trav...
Created 06/10/14
wq123
This hilfiger outlet time swarovski jewelry something really timberland outlet strange, ...
Created 30/06/16
ninestab123
ninest123 One canada goose pas cher gucci outlet thing
Created 21/07/16
ZZZZ
michael kors handbags nike trainers
Created 05/10/16
leilei3915
20170408 leilei3915 kate spade outlet coach facto...
Created 08/04/17
michael kors factory outlet
adidas nmd pandora bracelet
Created 16/05/17
Title*
Comment

Prove you are not a robot

To prove you are not a robot, please type in the six character code you see in the picture below
Security confirmation codeI can't see this!
Contact
Name*
Email never shown*
Home Page

Author

Andrew Dodson
Since:Feb 2007

Comment | flag

Categories

Bookmark and Share