Understanding Images

Discussion in 'Technical Support' started by Lhotch, Dec 18, 2008.

Thread Status:
Not open for further replies.
  1. Lhotch curmudgeon

    Understanding Images

    Next to E-mail, images are one of the most misunderstood aspects that impacts users of 68C. So what I would like to do is convey some basic info about images to help you better understand how 68C deals with them and why there are limitations on their size and why its important to have your administration settings for your site set properly.

    Image Size
    When it comes to images the word "size" can have many different meanings.

    File Size
    Images, like eveything else computer related, are stored in containers called files. These files have a "size" which indicates how much space they take up on a computers hard disk.

    Memory Size
    What most people dont realize however is that most files used on the internet today are compressed. In other words special standards and algorithms are used to try and retain the data within the file but increase the space the file uses on a computers hard disk.

    In order for the data within the file to be accessed however a compressed file needs to be uncompressed. This is done in a computers memory. A file that takes up 1 megabyte on the hard disk may actually take up 20 megabytes in memory depending on its contents and what type of compression is used.

    Physical pixel dimension size
    Images are made up of pixels which are tiny segments of information which contain color data. These pixels are arranged in a manner that is typically grid like and expressed in width x height.

    68 Classifieds and images
    68Clasifieds uses a high quality image upload class for handling the resizing of images. When you as a site admin or an ad poster places an ad and uploads an image many things need to take place.

    1) the web server works together with the back end scripts and the clients browser to send the image to the web server where it is temporarily stored in its original format. There are certain PHP settings that are out of the control of most users on shared hosting plans which limit the size of the file that can be sent to the server. Additionally there are time limits placed on how long a script can run. If a user has a very slow connection to the internet and is uploading a very large file this execution time limit may be reached and the upload can fail.

    It may also happen that your host has a very small temporary space allocated to you and if you and the other server users all are uploading images this temp spae may fill up and in turn the upload may fail.

    2) Once the file is on the server in its temporary location 68C uncompresses the images and creates a small duplicate of it for a thumbnail using the settings you provided in admin. It also creates another image to use for the new full size image for the site based on admin settings as well. When done the original image is deleted from the temporary space.

    When a file is uncompressed it resides in memory and the amount of memory your scripts are allowed to use is set by the php configuration file. This is totally outside the scope of 68C and is set by your web host. If your admin settings allow your users to upload images that are larger than your server can handle the script will fail. Once again this is NOT a problem with 68C but a limitation you host has imposed.

    68 Classifieds Admin settings
    68Classifieds allows you to set the image sizes for your thumbnails and your large images (those that get displayed in ads).

    In addition you can also specify a max file size for an image as well as max height and width of an uploaded image.

    As the pixel dimensions for an image increase the data contained in the file increase exponentially. Also depending on the quality setting for an image when it is saved, the same exact image saved at 2 different quality settings will have very different file sizes and also occupy different amounts of memory when uncompressed.

    Most image editing software will show you the size (in kilobytes or megabytes) that an image is using in memory when it is opened. You can simply create empty images of varying pixel dimensions to get a feel for what pixel size images use in terms of system memory.

    To view your servers current memory limit you can create a new file, call it what ever you would like as long as it end in .php and place it somewhere on your site. In the file have the following code......

    PHP:

    <?php
    phpinfo
    ();
    ?>
    The point a browser to it and look for a line called "memory_limit" and that will tell you how much memory your scripts have to work with.

    If you open a bunch of files in an image editing application and see that are consuming 20mg etc and your memory_limit on your site is 16mg then trying to upload one of those images will likely fail.

    What you are going to have to do is find out your hosts memory limit and then experiment with images that have different dimensions and see how large they are in memory and when saved to disk and use these numbers for your admin settings.

    Then lastly, take a minute to alter your sites templates or FAQ to let people know what you file size and dimensional limitations are to save them the hassle of trying to upload images that are too large.

    Most modern cameras create images that are much larger than can be processed by most shared hosting plans. Once again this is a limitation with your host and not the 68C software, 68C will handle the images just fine if it is allowed to use enough memory to process the image.
  2. ryanreed71 Customer

    New to placing codes

    Do I understand you correctly?

    Are you saying to get 68C to accept larger pictures we need to place the code in our files?

    If so, what specific file?

    If so, you can not say place it anywhere, because some one like me will very likely place it somewhere that makes no sense or you would not think was possible. So exactly where? I need to see what to place it directly after or directly before.

    You show the code like this:

    <?php

    phpinfo();

    ?>

    Are we suppose to stick a figure in somewhere to change the acceptable size of pictures?

    If the answer is no, then what can I do to get mine to accept pictures better? I am hosted with Rackspace through you.

    The first two days I could load pictures onto my homepage without a problem and with seemingly no size restrictions or none that presented themselves. After 2 days I could not get any pictures to load for 2 or 3 days including the same ones that loaded with no propblem days earlier. Then the pictures did begin to load, but relucantly. The same warning would pop up saying, "Upload Image to Big! Max 100 x". About 1 out of 10 tries the picture would go through despite the warning.

    There should be no limit on loading pictures on the homepage and certainly not 100 x.

    Is there a code I can place or remove that will fix the problem? If so give me exact details. This stuff is new to me.

    Thanks
  3. Lhotch curmudgeon

    No, not at all, what I am saying is the above PHP function will show you the servers current PHP configuration settings and in that list you will see a value called "memory_limit"

    This is how much memory your host allows your script to use and you will not be able to process images larger than that. This has nothing to do with 68C but is a limit imposed by your host.
  4. ryanreed71 Customer

    It is not rackspace, it is your software

    My brother-in-law placed the code as you said and it shows a 32mb limit with rackspace. He then loaded a large picture onto the server directly and it went through in about 2 seconds. He then tried loading the same picture on through my site and it would not load. Here is the picture he loaded directly on to the server http://dog2go.com/photos/group.JPG


    In the process I found out that the email verification does not work. If you check the verification box requiring the email to be verified, it will never send verification.

    Also after you load a picture the button at the bottom always says skip. It would be better if it said continue. It can confuse someone that has loaded a picture and not skipped that part for the button to continue to say skip.

    Can you fix my software?
  5. Mike-N-Tosh Developer & Moderator

    Please do not post completely separate issues in one thread as this will only add confusion as well as make it that much harder for other members searching for answers to their issues.

    Regarding the "direct" uploading of a picture. If you mean that he ftp'd the file to your server, then this is something that is completely different than when you use the script. FTP protocols are not limited to php memory size limits, script timeout limits, etc.

    I agree that during the checkout when uploading images for the ad, that the button which states, "Skip" is very misleading. You can change this in your language file. The define in your language file is LANG_ADD_LISTING_SKIP

    -Mike
  6. ryanreed71 Customer

    32MB is more than sufficient correct?

    32MB is more than sufficient for a less than 2000 kbyte picture correct?
  7. Lhotch curmudgeon

    "memory_limit" is how much memory the server will allow one of your php scripts to use (ie 68C is one of your php scripts).

    When you say your brother "loaded a large picture onto the server directly", exactly what does that mean? He copied the file to the server using FTP?

    Saving an image file to the server and uploading the image to an ad are 2 totally different things and is what this thread is all about.

    When you simply FTP an image to a server for starters its not using a php script so the memory limit does not apply. Secondly the image is not being PROCESSSED by a php script. Specifically what I mean by processed is that 68C needs to UNCOMPRESS the image IN MEMORY so that a thumbnail can be created AND a large image based on your admin settings can be created for display within your site.

    It is this act of UNCOMPRESSING by a php script that consumes a lot of memory. An image produced from an 8 megapixel camera may only take up 1000kb on the disk but when the file is uncompressed it can use ofer 25 megabytes of memory thereby exhausting the "memory_limit" imposed by your host.
  8. Lhotch curmudgeon

    As I stated above the file size is not what determines how much memory is used when the images is uncompressed.

    Also as I have already stated, if you open the image in a decent image editing application it should show you how much memory it consumes.

    Tell me what the pixel dimensions are of your image and I can give you a ball park figure of how much memory it will use.
  9. Lhotch curmudgeon

    To further illustrate what I am talking about I found a few images from 3 cameras. Here are the cameras and basic image specs.


    nikon D80
    10.2 million effective pixels
    3872 x 2592 (10.0 MP)
    image file size on disk 3436kb
    image size when uncompressed in memory 90.8 megabytes

    Canon PowerShot SD850
    8.0 million effective pixels
    3264 x 2448
    image file size on disk 3446 KB
    image size when uncompressed in memory 72.1 megabytes

    nikon D70
    6.1 million effective pixel
    3008 x 2000 (6.0 MP)
    image file size on disk 2900kb
    image size when uncompressed in memory 52.7 megabytes


    To further illustrate lets take the already small image from the Nikon D70 and reduce its size and see what happens. Below is a list of the image size as its reduced, the amount of space it uses in mem.....



    2500 x 1667 : 37.4 megabytes
    2000 x 1334 : 23.6 megabytes
    1500 x 1001 : 11.8 megabytes
Thread Status:
Not open for further replies.

Share This Page