title: Php image resize in output
body: <p>I have this php function to resize image according to where i need it and the size i wish to display.
  But my problem is how to i set it to display resized image in html image element without setting the php content type to image?
  If i set content type to image it will display the image in the whole page and if i remove it it will output long unknown characters, how do i do this to get what i want?</p>
  
  <pre><code>    &lt;?php
      function CroppedThumbnail($imagename, $imgwidth, $imgheight){
  // Set a maximum height and width
  $width = $imgwidth;
  $height = $imgheight;
  // Content type
  //header('Content-Type: image/jpeg');
  // Get new dimensions
  list($width_orig, $height_orig) = getimagesize($imagename);
  $ratio_orig = $width_orig/$height_orig;
  if ($width/$height &gt; $ratio_orig) {
     $width = $height*$ratio_orig;
  } else {
     $height = $width/$ratio_orig;
  }
  // Resample
  $image_p = imagecreatetruecolor($width, $height);
  $image = imagecreatefromjpeg($imagename);
  imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
  // Output
  imagejpeg($image_p, $imagename, 100);
  return $imagename;
  }
  
  $filename1 = 'http://static1.techlosofy.com/wp-content/uploads/YouTube-Logo-Large.jpg';
  $filename2 = 'http://static1.techlosofy.com/wp-content/uploads/YouTube-Logo-Small.jpg';
  echo '&lt;img data="image1" src="'.CroppedThumbnail($filename1, 100, 100).'"/&gt;';
  echo '&lt;img data="image2" src="'.CroppedThumbnail($filename2, 100, 100).'"/&gt;';
      ?&gt;
  </code></pre>
  
  <p>I want to resize any image that i call this function on</p>