title: header('Content-Type: image/jpeg') makes black site
body: <p>I have a code to do thumbs like this:</p>
  
  <pre><code> switch (strtolower($imgOrginalsize['mime'])) {
              case 'image/jpeg':
                  $img = imagecreatefromjpeg($file);
                  $new = imagecreatetruecolor($w, $h);
                  imagecopyresampled($new, $img, 0, 0, 0, 0, $w, $h, $imgOrginalsize[0], $imgOrginalsize[1]);
                  header('Content-Type: image/jpeg'); // when I comment this everything works good, but with this I have a whole black site. What is wrong? In png it doesn't destroy my site.
                  imagepng($new, $pathToSave . $file_name, 9);
                  imagedestroy($new);
                  break;
              case 'image/png':
                  $img = imagecreatefrompng($file);
                  $new = imagecreatetruecolor($w, $h);
                  imagecopyresampled($new, $img, 0, 0, 0, 0, $w, $h, $imgOrginalsize[0], $imgOrginalsize[1]);
                  header('Content-Type: image/png');
                  imagepng($new, $pathToSave . $file_name, 9);
                  imagedestroy($new);
                  break;
              default:
                  die();
          }
  </code></pre>
  
  <p>Whole site is black when I add to my code header jpeg. In png It doesn't destroy it and everything works good. I cannot see where is my mistake. And site looks like this: </p>
  
  <p><a href="https://i.stack.imgur.com/m1dSY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m1dSY.png" alt="enter image description here"></a></p>