Jump to content

Php script to resize images


uisneach

Recommended Posts

Here:

 

<?php

 

//  Create source image and dimensions

 

$src_img =imagecreatefromgif("bulb_gif.gif");

$srcsize = getimagesize('bulb_gif.gif');

$dest_x = 50;

$dest_y = (50/ $srcsize[0]) * $srcsize[1];

$dst_img = imagecreatetruecolor($dest_x, $dest_y);

//$white = imagecolorallocate($dst_img,255,255,255);

 

 

imagefill($dst_img, 0, 0, $white);

//  Resize image

//imagecolortransparent($dst_img,$white);

 

//imagealphablending($dst_img, 0);

 

imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_x, $dest_y, $srcsize[0], $srcsize[1]);

 

//  Output image

header("content-type: image/png");

imagegif($dst_img,'',100);//imagejpeg($dst_img,"",85);

 

//  Destroy images

imagedestroy($src_img);

imagedestroy($dst_img);

 

?>

 

Check it out yourself,

Original pix: http://10-network.net/image_thumbial/bulb_gif.gif

Resized thumbnail:http://10-network.net/image_thumbial/gif.php

 

I hope it helps,

 

Angel

Hello Angel.

thx ! It's cool

Just a question

this is my viewer.php file which print on video the pic.

echo "thanks for upload pic:";

 

echo "<br />";

echo "number:";

$nesql = "SELECT id_pic, description FROM (SELECT id_pic, description FROM foto ORDER BY id_pic DESC) a LIMIT 1";

$nentry = mysql_query ($nesql);

 

$new = mysql_fetch_row ($nentry);

 

 

echo "<span style='font-size: 16px; font-weight:bold'>  ";

 

 

print_r ($new[0]);

 

 

echo "<br />";

echo "</span>";

echo "<span style='font-size: 16px;font-weight:bold'>name:  ";

print_r ($new[1]);

echo "<br />\n";

echo "<img src = 'http://www.xxxxx.com/public/foto/".$new[0].".jpg' />";

 

echo "</span>";

echo "<br />\n";

 

I am a noob, very sorry, don't know how and where linkin your script with mine.

I think they must be different script, mustn't they?

But  theproblem for me it's to u.s. which varioable to be used here, wher put the link to resize.php

 

hope i am clear

:)

Bye

p.

 

Check this out:

http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx

 

 

Replace the first line of code in the example I gave you to:

$src_img =imagecreatefromgif("http://www.example.com/download.php");

 

Good luck.

 

Angel

The upload.php is for the user to upload the file to the DB. The download.php is to retrieve the file from DB.

Once you are able to retrieve the file (pix) you can resize it with the example I first posted.

 

Read the tutorial in the link I gave you.

 

cheers

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.