Creating 100 Megan Foxii
A couple of people have asked me how I created the image of 100 Megan Foxii (100 images of Megan Fox superimposed).
It’s actually really simple, using PHP. In fact, it only took about 20 lines of code:
<?php
// Get list of all photos
$aImg = array_diff(scandir('./photos/'), array('.','..'));
// Create blank white canvas
$im = imagecreatetruecolor(400, 600);
$white = imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im, 0, 0, 400, 600, $white);
// Place each image on to canvas, re-sized
foreach ($aImg as $img_path)
{
$filename = './photos/' . $img_path;
$tmpIm = imagecreatefromjpeg($filename);
list($width, $height) = getimagesize($filename);
$photoIm = imagecreatetruecolor(400, 600);
imagecopyresized ($photoIm, $tmpIm, 0, 0, 0, 0, 400, 600, $width, $height);
imagecopymerge($im, $photoIm, 0, 0, 0, 0, 400, 600, 3);
}
header('Content-type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>
Change the 400 (width) and 600 (height) in the code to whatever your output image size is; it just turns out that most of my images were around this size (it doesn’t matter if all of them are, as the script re-sizes the images).
You may also need to play around with the ‘3’ at the end of the imagecopymerge() function; it’ll need increasing a bit if you have less than 100 images, and decreasing if you use more than 100 images. Just play around and see what gives you the best effect (it defines the opacity of each image that is merged).
A Practical Guide to Web App SuccessWhether you’ve already started to build a web app, or you’re just starting to think about it, A Practical Guide to Web App Success tells you everything you need to know. Over the course of 25 densely-packed chapters, the book guides you through the lean web development process to help you plan, design, build and market a profitable web app quickly and inexpensively.
