function affineTransformImage($image_path) { $imagick = new \Imagick(realpath($image_path)); $draw = new \ImagickDraw(); $angle = 40 ; $affineRotate = array( "sx" => cos($angle), "sy" => cos($angle), "rx" => sin($angle), "ry" => -sin($angle), "tx" => 0, "ty" => 0, ); $draw->affine($affineRotate); $imagick->affineTransformImage($draw); header("Content-Type: image/jpeg"); echo $imagick->getImageBlob(); }