Issue
I am creating an image with parts from another image. I use imagecopy to but the "parts" togheter. Some parts need to be flipped horizontal.
For example this part:
imagecopy($output, $input, 0,8, 44,20, 4,12);
How do i flip this part horizontal??
I have tried this:
imagecopy($output, $input, (0 - 1),8, 44,20, 4,12);
But it does not work.
I have searched for ages, but cant find anything that works
My script looks like this:
$input = imagecreatefrompng($image_file);
$output = imagecreatetruecolor(50, 40);
imagecopy($output, $input, 4,8, 20,20, 8,14);
imagecopy($output, $input, 12,8, 44,20, 4,14);
imagecopy($output, $input, 4,20, 4,20, 4,14);
imagecopy($output, $input, 8,28, 4,20, 4,14);
imagecopy($output, $input, 32,8, 52,20, 4,14);
imagecopy($output, $input, 24,20, 12,20, 4,14);
imagecopy($output, $input, 28,28, 12,20, 4,14);
imagecopy($output, $input, 4,0, 40,8, 8,9);
imagecopy($output, $input, 24,0, 56,8, 8,9);
header('Content-Type: image/png');
imagepng($output);
imagedestroy($output);
imagedestroy($input);
Solution
I want to share the answer some years later... :)
Change:
imagecopy($output, $input, 8, 20, 4, 20, 4, 12)
To:
imagecopyresampled($output, $input, 8, 20, (8 - 1), 20, 4, 12, 0 - 4, 12);
Which will flip the part of the image horizontal.
Answered By - 2by Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.