user3151681
user3151681

Reputation: 35

how to enlarge the size of an image fetched from database using only php

I want to know is there any inbuilt function in php through which I can display an image greater than the size stored in database(i.e. greater than the original size).

I know it can be done using the HTML/CSS properties height and width but I want it done through php only.

I tried imagecreatefromjpeg($filename); but it takes file or directory name in place of $filename and my image is in a database.

Here is a part of my code:

    while( $result=mysqli_fetch_array($runquery))
    {
        echo'<img src="data:image/jpeg;base64,'base64_encode($result['image']).'"/>';
    }

Upvotes: 2

Views: 368

Answers (2)

secelite
secelite

Reputation: 1373

Load your image with imagecreatefromstring. Then resize it with imagecopyresized.

Also I would suggest you to only save the paths to your image in the database.

Upvotes: 2

ydoow
ydoow

Reputation: 3006

Get Imagick ready and call following function

bool Imagick::setImageExtent ( int $columns , int $rows )

Reference: Imagick::setImageExtent

Upvotes: 1

Related Questions