title: Resizing images - Symfony
body: <p>I have a number of images that are sotred as blob data in my database.
  I am aware this isn't a good idea, but it's what I'm using.</p>
  
  <p>I have following code in my Peer class:</p>
  
  <pre><code>public function getImagesPath()
  {
    $file_srcs = false;
    $fp = $this-&gt;getPhoto-&gt;getBlobData();
  
    if ($fp !== null)
    {
        $file = stream_get_contents($fp);
        $file_srcs = '/uploads/gallery/'.$this-&gt;getId().'.jpg';
  
    }
  return $file_srcs;
  </code></pre>
  
  <p>}</p>
  
  <p>I then call this in my template, like so:</p>
  
  <pre><code>            $path = $item-&gt;getImagesPath();
              if ($path)
              {
                  echo '&lt;img src="'.$path.'" alt="Thumbnail for '.$photo-&gt;getName().'" width="153" height="153" /&gt;';
              }
  </code></pre>
  
  <p>Now this works well, but, I have some images that are either square in shape, or rectangular.
  Giving them a size/width in the img src distorts some of them.</p>
  
  <p>Is there anyway, in which I could resize/crop the images before they are displayed?</p>
  
  <p>Thanks</p>