Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
$dir = scandir("./images");
unset($dir[0]);
unset($dir[1]);
$file = "images/".$dir[rand(2, count($dir))];
header("Content-type: image/jpg");
$source = imagecreatefrompng($file);
$size = getimagesize($file);
$width = $size[0];
$height = $size[1];
$x = floor($width - 200) / 2;
$y = floor($height - 100) / 2;
$target = imagecreatefromjpeg('teaser.jpg');
imagecopyresized($target, $source, 0, 0, $x, $y, 1078, 539, 200, 100);
imagejpeg($target);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.