Yii Framework Forum: Help with image resize - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Help with image resize blob images stored in database Rate Topic: -----

#1 User is offline   frocco 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 232
  • Joined: 17-February 10

Posted 25 February 2010 - 09:26 AM

Hello,

I have images stored in a database that need to be resized when display in a list (table)

if I just put a height, width, they are distorted.

I only have a blob field, no type or other info.

I am displaying it like:
<img alt="no image" src="data:image/jpg;base64,<?php print base64_encode($row->Picture)?>">


Any idea on what I can do?

Thanks

Frank
Regards,

Frank
0

#2 User is offline   wyldie 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 22-May 09

Posted 25 February 2010 - 09:50 AM

If you're relying on the HTML renderer to control the size then just placing 1 dimension will scale the image
<img alt="no image" src="data:image/jpg;base64,<?php print base64_encode($row->Picture)?>" height="100">

Alternatively, set the source to a controller/method that reads the data from your table and pass the blob information into an image library such as GD or Imagick and do proper scaling on the server.
CHtml::image($this->createUrl("photo/show", array("id"=>$row->id, "height"=>100, "width"=>100)));

0

#3 User is offline   frocco 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 232
  • Joined: 17-February 10

Posted 25 February 2010 - 09:59 AM

Thank you...

Regards,

Frank

View Postwyldie, on 25 February 2010 - 09:50 AM, said:

If you're relying on the HTML renderer to control the size then just placing 1 dimension will scale the image
<img alt="no image" src="data:image/jpg;base64,<?php print base64_encode($row->Picture)?>" height="100">

Alternatively, set the source to a controller/method that reads the data from your table and pass the blob information into an image library such as GD or Imagick and do proper scaling on the server.
CHtml::image($this->createUrl("photo/show", array("id"=>$row->id, "height"=>100, "width"=>100)));


Regards,

Frank
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users