function averageImages($image_path)
{
    $imagick = new \Imagick(realpath($image_path));
    $imagick2 = new \Imagick(realpath("../images/TestImage2.jpg"));
    $imagick->addImage($imagick2);

    $averageImage = $imagick->averageImages();

    $averageImage->setImageType('jpg');
    header("Content-Type: image/jpeg");
    echo $averageImage->getImageBlob();
}