I'm building an image board and I want to make sure there's no malicious php code inside of uploaded images before they get written to disc, and I want to use IMagick instead of GD because its writeImages method preserves gif animation.
I've been testing my code on the example image on this page: (it's just php_info())
http://php.webtutor.pl/en/2011/05/13/php-code-injection-a-simple-virus-written-in-php-and-carried-in-a-jpeg-image/
I've been able to remove the php using GD:
$im = imagecreatefromjpeg($_FILES['image_upload']['tmp_name'][index]);
imagejpeg($im, $file_path);
I just use call_user_func in order to adapt it to different image formats:
call_user_func("imagecreatefrom" . $mime_type, $_FILES['image_upload']['tmp_name'][index])
call_user_func("image" . $mime_type, $im, $file_path);
But like I said, animated gifs get turned into static gifs this way. So how do I do the same thing with IMagick?