By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,662 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

problem with image downloading

P: 56
Can anyone suggest me how to download image of different resolution?I have an image stored in database with 2896x2600 resolution and i want to download that image with different different resolution like 383x383,700x700 etc.In my page i have to keep 6 differnt resolution and the download link in front of it.When user download that link then image is downloaded of that resolution and i also want to set counter that keeps record how many times that image is downloaded?
Please help me in my problem.
Oct 10 '08 #1
Share this Question
Share on Google+
4 Replies

Expert 5K+
P: 5,821
Heya, Sejal.

Have a look at PHP's GD functions (
Oct 10 '08 #2

P: 56
Heya, Sejal.

Have a look at PHP's GD functions (
Thanks for your reply.......
But i don't want that gd functions.I want the script from which i can download image of variable sizes.
Oct 13 '08 #3

P: 93
I think if you want that script you're going to have to bite the bullet and write it!

You could create several links in your page:
[HTML]<a href="image.php?height=200&width=400">400 x 200</a>
<a href="image.php?height=300&width=600">600 x 700</a>
<a href="image.php?height=400&width=800">800 x 400</a>[/HTML]
And then you need a bad ass script that takes the original image out of the database and uses the height and width variables ($_GET['height'] and $_GET['width']) to create a smaller version of it using the GD functions.

Here's a start. You'll need to fill in the gaps and refer to the GD functions :
[PHP]$orig_image = imagecreatefromjpeg('place where the original image is saved');
$new_image = imagecreatetruecolor($_GET['width'], $_GET['height']);
//possibly imagecolorallocate(); stuff here
//now copy $orig_image into $new_image but at reduced size:
imagecopyresampled();//that will need various parameters

header('Content-Type: image/jpeg');
Oct 14 '08 #4

P: 93
Oops, last 2 lines should have been:[PHP]imagejpeg($new_image);
Oct 14 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.