problem with image downloading

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sejal17
    New Member
    • Dec 2007
    • 56

    problem with image downloading

    Hello,
    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.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Sejal.

    Have a look at PHP's GD functions (http://php.net/gd).

    Comment

    • sejal17
      New Member
      • Dec 2007
      • 56

      #3
      Originally posted by pbmods
      Heya, Sejal.

      Have a look at PHP's GD functions (http://php.net/gd).
      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.

      Comment

      • adamalton
        New Member
        • Feb 2007
        • 93

        #4
        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&wid th=400">400 x 200</a>
        <a href="image.php ?height=300&wid th=600">600 x 700</a>
        <a href="image.php ?height=400&wid th=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 = imagecreatefrom jpeg('place where the original image is saved');
        $new_image = imagecreatetrue color($_GET['width'], $_GET['height']);
        //possibly imagecoloralloc ate(); stuff here
        //now copy $orig_image into $new_image but at reduced size:
        imagecopyresamp led();//that will need various parameters

        header('Content-Type: image/jpeg');
        imagejpeg($img) ;
        imagedestroy($i mg);[/PHP]

        Comment

        • adamalton
          New Member
          • Feb 2007
          • 93

          #5
          Oops, last 2 lines should have been:[PHP]imagejpeg($new_ image);
          imagedestroy($n ew_image);[/PHP]

          Comment

          Working...