SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jun 2001
    Location
    Bavarian Alps
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    automatically resizing an image

    I am creating a site which uses a mysql databank and php. Using the advice in an article from Kevin Yank, I have got everything to work with one exception.

    All images that are downloaded, regardless of size should be reduced to 100 pixel wide x 75 high before being saved on my server and indexed in my data bank.

    I can not find a function or a description of how to do this. Is it possible? How do I go about it?

    Thanks in advance for your help.

  2. #2
    SitePoint Addict kunal's Avatar
    Join Date
    Oct 2000
    Posts
    307
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why not just define the size when displaying the image?
    i dunno...

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because defining the image height and width when displaying the image is a very inefficient method for doing this. If your image is 400 x 400 pixels and you simply change the image dimensions in your html, then you are not saving any filesize and still are downloading a huge image, and also if the image is not scaled properly then it will become distorted. The best way is to resize the image when the image is put on the server. The only way to accomplish this is to have a GD installed on your server or to use a program like ImageMagick. I would first check with your host on whether they have either of those programs installed if they do havea look at
    http://www.php.net/manual/en/functio...opyresized.php
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    SitePoint Addict kunal's Avatar
    Join Date
    Oct 2000
    Posts
    307
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh ok.. but doesnt the image size remain the same even if the dimensions have changed? thats what i thought.. hmm.. i guess i was wrong
    i dunno...

  5. #5
    SitePoint Member
    Join Date
    Jun 2001
    Location
    Bavarian Alps
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    automatically resizing an image

    Thanks for the quick reply. That is very impressive.

    I just took a look at ImageMagick but what is GD? Where can I find details?

    Do I understand you correctly that the ImageCopyResized() function will only work with one of these two installed and not otherwise?

    Thanks again

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    GD is a graphics library, and yes you will need to have GD to use ImageCopyresized() ImageMagick uses its own API which is not compiled into PHP and needs exec() to work.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •