Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,071
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Any file-size limits on Image Functions?

    I know this is a bit vague, but are there any *obvious* file-size limitations that would break any functions I am using to check and sanitize uploaded photos?

    It seems to me that either 2MB or 2GB will break some Image Functions and GD Functions, but I'm not sure. (And I'm trying to avoid having to go research every function I use in my script which is over 1,000 lines long!)

    I ask this, because I was going to restict users from uploading files larger than 150 Kb, but now someone is saying that is a bad idea.

    I don't mind upping the limit, but I don't want to break my code in the process, and I also don't want people (read "hackers") trying to upload 10 GB photos in an attempt to break my website!!

    Thanks,


    Debbie

  • #2
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    you are limited by memory assigned to php and server itself.

    but limiting upload size is a good idea (you prolly don't want your hosting company to force u to pay for dedicated server)
    i would suggest say.... 5 megs. this way even 12MP photo will pass. do size test when u are hashing files

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,627
    Thanks
    0
    Thanked 648 Times in 638 Posts
    It depends on what use the image is for. If it is just to display in a web page then 150k is HUGE. If it is to be able to be downloaded and printed then a bigger size might be appropriate. I doubt any static images need to be bigger than 2Mb. Anything bigger than that is more likely to be video.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,071
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    It depends on what use the image is for. If it is just to display in a web page then 150k is HUGE. If it is to be able to be downloaded and printed then a bigger size might be appropriate. I doubt any static images need to be bigger than 2Mb. Anything bigger than that is more likely to be video.
    The purpose of the uploaded photo is to ultimately transform it into a 100 px by whatever (resized) avatar.

    The debate is how accommodating I have to be for people uploading photos...

    If someone took a photo of themselves with a pro digital SLR at 30 MP, I suppose they might have an enormous self portrait. (However, I'd like to think most people creating profiles online are smart enough to know how to take that 1GB self-portrait and downsize it to 150Kb themselves, right?!)

    I could up my upper-limit to whatever, but why put extra stress on my server and get possibly stuck paying for more bandwidth when people can shrink down whatever they want to upload BEFORE they upload?

    I feel that is reasonable, as is 150Kb Max Photo Filesize, but I wanted to see what others think here.

    Thanks,


    Debbie

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,627
    Thanks
    0
    Thanked 648 Times in 638 Posts
    Quote Originally Posted by doubledee View Post
    The purpose of the uploaded photo is to ultimately transform it into a 100 px by whatever (resized) avatar.

    I feel that is reasonable, as is 150Kb Max Photo Filesize, but I wanted to see what others think here.
    Perhaps 10k would be more appropriate maximum if it is to be an avatar but 150k allows them to upload a proper photo that you can then compress down to under 5k when you create the avatar. Having the limit around that figure ensures that they don't stupidly try to upload an image that is tens of thousands of pixels across. It will remind them that such huge photos are not suitable for the web.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    in my personal opinion you could limit that upload size even to 10k but only in a perfect world where most peple actually know how to resize pictures and have the will to do so.

    but since we don't live in that land of unicorns... i happen to work with real people from time to time and vast majority of them wouldn't bother to take extra effort to resize pics just to upload them.
    most of them would take a pic from memory card, try to upload it, get frustrated because they can't get it to the server, and call it a bug.
    so if you want average person to upload pics, u should prolly set your limit to fit file size from average camra (and ppl don't buy 10MP caneras to make 10k pics)

  • #7
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,071
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    Perhaps 10k would be more appropriate maximum if it is to be an avatar but 150k allows them to upload a proper photo that you can then compress down to under 5k when you create the avatar. Having the limit around that figure ensures that they don't stupidly try to upload an image that is tens of thousands of pixels across. It will remind them that such huge photos are not suitable for the web.
    Yep, that is exactly what I was thinking.

    Thanks!!


    Debbie

  • #8
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,071
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by patryk View Post
    in my personal opinion you could limit that upload size even to 10k but only in a perfect world where most peple actually know how to resize pictures and have the will to do so.

    but since we don't live in that land of unicorns... i happen to work with real people from time to time and vast majority of them wouldn't bother to take extra effort to resize pics just to upload them.
    most of them would take a pic from memory card, try to upload it, get frustrated because they can't get it to the server, and call it a bug.
    so if you want average person to upload pics, u should prolly set your limit to fit file size from average camra (and ppl don't buy 10MP caneras to make 10k pics)
    So what "magic number" are you referring to, then??


    Debbie

  • #9
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    normal quality/medium-size jpeg file from my nikon is between 1.3 and 2 megs
    it's 2896 x 1944 px
    i would imagine that's what peple shoot on average (300dpi for small printout - default setting in most cameras)

  • #10
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    and by the way if you'll decide to force people to shrink photos for upload, then you could as well skip that hashing pics thing.
    one person will shrink image by 50%, second by 60%, third by 55%, and you end up with 3 different hashes for one pic

  • #11
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,071
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by patryk View Post
    and by the way if you'll decide to force people to shrink photos for upload, then you could as well skip that hashing pics thing.
    one person will shrink image by 50%, second by 60%, third by 55%, and you end up with 3 different hashes for one pic
    Ah, but the reason for the hash_file is for people who are uploading other people's photos from online - and likely getting the same photo, at the same dimensions, from the same source.

    But if that doesn't solve most of the problem, then maybe in the feature you can help me with my blockErinAndrews() function...


    Debbie

  • #12
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    that could be doable actually. openCV is getting smarter and smarter

  • #13
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,071
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by patryk View Post
    that could be doable actually. openCV is getting smarter and smarter
    Pretty cool!


    Debbie


  •  

    Posting Permissions

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