I'm trying to write a function which takes an image filepath and returns the filepath to an image which is horizontally flipped from the original.
So I have this function, which takes an image resource and returns an image resource.
function img_flip_h($im)
{
$x_i = imagesx($im);
$y_i = imagesy($im);
$newimg = imagecreatetruecolor($x_i, $y_i);
for ($x = 0; $x < $x_i; $x++) {
for ($y = 0; $y < $y_i; $y++) {
imagecopy($newimage, $im, $x, $y_i - $y - 1, $x, $y, 1, 1);
}
}
return $newimg;
}
I've been looking on the php gd function reference for something that looks like it would return a resource at the beginning of this function and return a filepath at the end but haven't found anything. Any ideas?