#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Location
    Stockholm, Sweden
    Posts
    0
    Rep Power
    0
    Hello there,

    I am currently in the process of building a smaller internet community, where people can register a user, and interact with each other in different ways.

    I will let the users upload a user picture, which will be displayed on their personal page. Now, the problem I see is that some people have the habit of uploading huge pics, both pixel- and sizewise.

    So my question is: is there a way I can automate the process of resizing a picture at the same time the user uploads it? I want it to have a width of X, but the height doesn't matter, but it should be proportional with the width when it is resized, so it doesn't become distorted.

    Is there any way I can do this using PHP?

    Regards,
    Kyraal
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    5
    Rep Power
    0
    there is a function named
    [link="http://www.php.net/manual/function.imagecopyresized.php"]ImageCopyResized()[/link]

    read the manual of PHP, and you shd find something useful
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Location
    Stockholm, Sweden
    Posts
    0
    Rep Power
    0
    Thanks for the URL. It would have been most helpful if the PHP build my webhotel has installed, supported the resizing of JPEGs. Which it at this point does not, only GIFs...

    Regards,
    Kyraal
  6. #4
  7. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    There is alternative solution, not exactly the "greatest" method.. but a possiblity.

    You could use the "getImageSize()" function, to obtain the physical size (HxW) of the uploaded image.

    At the point where the user uploads, you could check the image specs, to determine if it meets you site requirements.

    The getImageSize() function works on GIF, JPG, PNG, and SWF imagery.

    it returns an array, which includes:
    Type: 1 = GIF, 2 = JPG, 3 = PNG and 4 = SWF
    Height: X
    Width: X
    and height=x width=x

    Used in conjunction with the MAX_FILE_SIZE
    field, you can restrict image uploads.

    In short, you wouldn't need to re-size a users uploaded image, you just simply restrict what can be uploaded.

    Additionally you can ensure that users only upload images of a specific MIME type...

    the enctype="multipart/form-data" attribute of the form field returns some very useful information about the file being uploaded.

IMN logo majestic logo threadwatch logo seochat tools logo