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.
I have following code in my Peer class:
public function getImagesPath()
{
$file_srcs = false;
$fp = $this->getPhoto->getBlobData();
if ($fp !== null)
{
$file = stream_get_contents($fp);
$file_srcs = '/uploads/gallery/'.$this->getId().'.jpg';
}
return $file_srcs;
}
I then call this in my template, like so:
$path = $item->getImagesPath();
if ($path)
{
echo '<img src="'.$path.'" alt="Thumbnail for '.$photo->getName().'" width="153" height="153" />';
}
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.
Is there anyway, in which I could resize/crop the images before they are displayed?
Thanks