}
    /* Write to a file */
    if ($resizeImage) {
        $im->resizeImage(900, 80, 1, 0.5);
    }
    switch ($case) {
        case "write_img":
            $im->writeImage("img/" . $_GET["file"]);
            break;
        case "show_img":
            header("Content-Type: image/jpg");
            echo $im->getImageBlob();
            break;
    }
} else {
    cropImage_common($filename, 80, 80);
}
function cropImage_common($filename, $width, $height)
{
    // Content type
    header('Content-Type: image/jpeg');
    // Cacul des nouvelles dimensions
    list($width_orig, $height_orig) = getimagesize($filename);
    $ratio_orig = $width_orig / $height_orig;
    if ($width / $height > $ratio_orig) {
        $width = $height * $ratio_orig;
    } else {
        $height = $width / $ratio_orig;
    }
    // Redimensionnement
    $image_p = imagecreatetruecolor($width, $height);
    $type_image = "common";
    //(common || imagemagick)
}
$root_path = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], "/"));
$filename = $root_path . "/store/" . $_GET["file"];
$width = 80;
$height = 80;
switch ($type_image) {
    case "imagemagick":
        $im = new Imagick($filename);
        $im->cropThumbnailImage($width, $height);
        header("Content-Type: image/jpg");
        echo $im->getImageBlob();
        break;
    case "common":
        cropImage_common($filename, $width, $height);
        break;
}
function cropImage_common($filename, $newWidth, $newHeight)
{
    $originalFile = $filename;
    $info = getimagesize($originalFile);
    $mime = $info['mime'];
    switch ($mime) {
        case 'image/jpeg':
            $image_create_func = 'imagecreatefromjpeg';
            $image_save_func = 'imagejpeg';
            $new_image_ext = 'jpg';
            break;
        case 'image/png':
            $image_create_func = 'imagecreatefrompng';