Here's a example of this function:
<?php
$img = new Imagick();
$img->readImage($image_file_name);
$img->whiteThresholdImage('grey');
$img->writeImage($thumb_file_name);
$img->clear();
$img->destroy();
?>