Jump to content

thumbnails


corillo181

Recommended Posts

<?php
// The file name you wish to get
$filename = 'images/pic.jpg';

// Content type
header('Content-type: image/jpeg');

//takes the with and height of file
list($width, $height) = getimagesize($filename);

$newWidth=120;

$newHeight=intval($height*$newWidth/$width);

$oldImage=ImageCreateFromJPEG("$filename");

$newImage=ImageCreateTrueColor($newWidth,$newHeight);

imagecopyresampled($newImage,$oldImage,0,0,0,0,$newWidth,$newHeight,$width,$height);

ImageJPEG($newImage,"TN"."jhon.jpg");
?>


i got this code, but i would like to know how can i make this so i can put it on mysql..


becuase the imageJPEG() function saves the picture and makes the picture show on the page i just want to keep the picture in a variable so i can insert it in the sql table i got set up..

if you need a better explanation please let me know..
Link to comment
https://forums.phpfreaks.com/topic/28556-thumbnails/
Share on other sites

[code]
$cn=@mysql_connect("host","username","password") or die(mysql_error());
@mysql_select_db("name",$cn) or die(mysql_error());

$file=@fopen("test.jpg","r");
$text=@fread($file,filesize("test.jpg"));
@fclose($file);

@mysql_query("INSERT INTO `table` (picture) VALUES('$text')",$cn) or die(mysql_error());
[/code]
in the table picture must be a BLOB
Link to comment
https://forums.phpfreaks.com/topic/28556-thumbnails/#findComment-130693
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.