PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Jul 08, 2020 12:08 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: BLOB 2 THUMBNAIL
PostPosted: Tue Jul 05, 2005 3:20 am 
Offline
Forum Contributor
User avatar

Joined: Sat Apr 27, 2002 11:39 am
Posts: 370
Location: Istanbul
If you stored images to db in BLOB format. Then you can use the following code to read them from db and to create thumbnails of images...

Of course you need proper GD library ;)

Syntax: [ Download ] [ Hide ]
<?php

        $connection = mysql_connect("localhost","root","root") or die ("$error");

        $select= mysql_select_db("mydb",$connection) or die ("$error");

       

        $sql = "select bigpicture from gallery where id='$someid'";

        $res = mysql_query($sql);

        $info = mysql_fetch_array($res);

       

        $data = base64_decode($info["bigpicture"]);

        $img = imagecreatefromstring($data);

       

        $x = ImageSX($img);

    $y = ImageSY($img);



        $newwidth = 200;

        $newheight = $newwidth * $y / $x;

       

        $thumb = imagecreatetruecolor($newwidth, $newheight);

        imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $x, $y);

        imagejpeg($thumb);

?>



If you have further questions sent a private message and post your question here 8)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 10:14 am 
Offline
Site Admin
User avatar

Joined: Tue Dec 23, 2003 3:10 am
Posts: 11470
Location: Toronto
Remember guys, avoid storing images in a database.. can really extend your page load times.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 2:16 pm 
Offline
Forum Contributor
User avatar

Joined: Sat Apr 27, 2002 11:39 am
Posts: 370
Location: Istanbul


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 14, 2005 2:39 pm 
Offline
Forum Commoner

Joined: Tue Jul 27, 2004 5:13 am
Posts: 32
Location: Oviedo,FL.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 14, 2005 7:14 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group