PHP crop tall images
<p>This is my code, but I dont know why but when I upload a vertical image it is resized and I get two black stripes on the sides.  With wide images it works well most of the time but with some images I get black stripes as well. How can I fix it?</p>

<p>My purpose is to crop every image, horizontal just a hint to fit my box, and vertical I want to crop so the width is the same and they are cut no top and bottom.</p>

<pre><code>$thumb_height  = 200;
$thumb_width   = 300;

    $thumb = imagecreatetruecolor($thumb_width, $thumb_height);
    if($width &gt;= $height) {
       // If image is wider than thumbnail (in aspect ratio sense)
       $new_height = $thumb_height;
       $new_width = $width / ($height / $thumb_height);
    } else {
       // If the thumbnail is wider than the image
       $new_width = $thumb_width;
       $new_height = $height / ($width / $thumb_width);
    }
    $output_filename_mid = 'uploads/'.IMG_L.$fileName;      
    imagecopyresampled($thumb,
                       $image,
                       0 - ($new_width - $thumb_width) / 2, // Center the image horizontally
                       0 - ($new_height - $thumb_height) / 2, // Center the image vertically
                       0, 0,
                       $new_width, $new_height,
                       $width, $height);
    imagejpeg($thumb, $output_filename_mid, 85);
</code></pre>
