Hello,

I have been setting up a photo upload feature for a website which allows members to upload photos.

I am also after some advice on how large a file should be? I thought about allowing members to upload a photo up to 100,000 in size and allowing a maximum of 10 photos each but if I could expand this then it would be great. I just cant seem to find out how! obviously if I had a 1000 members for example each having 10 x 100,000 then thats a huge amount of space.

Is there anyway to compres the files that members upload. For example ...I see facebook which is well known for their photo uploads somehow compress the file and allow massive amounts of files on their servers.

Any advice would be great.

Thanks
:)

Dani AI

Generated

For : treat uploads as a pipeline, not just a file-drop. Store whatever you need (original or not), but always create and serve appropriately sized, compressed variants and push heavy work off the web request. That approach reduces per-user storage needs, cuts bandwidth, and keeps the site responsive as user numbers grow.

Practical pipeline (in order): validate the file type and image headers; extract and persist any needed EXIF/metadata to your database; create a small set of derived images (thumbnail, content-size, maybe a full-size constrained to a sane maximum); strip EXIF from the served files; and save hashes to detect exact-duplicate uploads. For most sites a long-edge limit of 1,200–2,000px and JPEG/web-optimized quality around 70–85 gives a big size cut with acceptable visual quality. Background workers (queue tasks) should handle the conversions so uploads return quickly and CPU spikes don’t block users — this addresses ’s concern about CPU load.

On tools and delivery: use a high-performance image library for bulk work (libvips is ideal for throughput; Imagick/ImageMagick works well too). Store images in object storage and serve via a CDN to offload disk and bandwidth. For storage savings, keep only the originals you truly need — otherwise keep just the variants. Implement per-user quotas or soft limits and consider on-demand generation of sizes with caching if storage is the primary constraint. This expands on points raised by and about re-encoding and metadata.

Small PHP example (Imagick) — resize, strip metadata, set quality:

$img = new Imagick($uploadedPath);
$img->stripImage();
$img->resizeImage(1200, 0, Imagick::FILTER_LANCZOS, 1);
$img->setImageCompressionQuality(75);
$img->setImageFormat('jpeg');
$img->writeImage($destPath);

Also consider deduplication via content hashes, enforce MIME/type checks, and offer users clear storage quotas. That combination will let a site scale far beyond naive per-file limits while keeping image quality acceptable — a pragmatic complement to the suggestions from and others.

Recommended Answers

All 5 Replies

Hello,

I have been setting up a photo upload feature for a website which allows members to upload photos.

I am also after some advice on how large a file should be? I thought about allowing members to upload a photo up to 100,000 in size and allowing a maximum of 10 photos each but if I could expand this then it would be great. I just cant seem to find out how! obviously if I had a 1000 members for example each having 10 x 100,000 then thats a huge amount of space.

Is there anyway to compres the files that members upload. For example ...I see facebook which is well known for their photo uploads somehow compress the file and allow massive amounts of files on their servers.

Any advice would be great.

Thanks
:)

I just cant seem to find out how! obviously if I had a 1000 members for example each having 10 x 100,000 then thats a huge amount of space.

You'd never get 1000x10x100,000. You'd get a much lower number realistically.

What you'd have to ask is weather each member is worth that much space... yes.

Is there anyway to compres the files that members upload.

You could first convert the uploaded images to a compressed format. This usually means JPG - I would guess. You can also optimize the JPG server side, make sure you save lower quality if the image is very high quality.

Then you could also gzip it, and save the Gzipped version. Not sure how Gzip would play with the existing image compression, but I think it should reduce the size. (you have to test that, since compressing twice can increase the size).

Member Avatar for Member #117553

Then you could also gzip it, and save the Gzipped version. Not sure how Gzip would play with the existing image compression, but I think it should reduce the size. (you have to test that, since compressing twice can increase the size).

Indeed, a JPG compressed file does not compress good in gzip, even if strong or strongest compression is used.
It is important what kind of information is needed for a jpg stored online. For example, you can read the EXIF if it is important, and store it in a database, and then resample the image with stronger JPG compression and without EXIF, which will result to something like 130-160 KB for a 1600 x 1200 image with 60 - 70% jpg compression ratio. So when requested, you can show both the exif and still have the image in relatively good quality in relatively big size.

If you must in all cases store the original, then, you may limit your users to a monthly or total upload limit, that when exhausted (either by 10 or by 1000 images),does not allow furhter uploads, and you can leave the images intact.

Facebook and another community sites achieves this optimal capacities performing an image scale reduction and using lossless formats like JPEG for every photo uploaded. Data storage can be a concern on higher web sites, I think CPU usage should be another factor to be considered. You can make a heavy amount of CPU load killing the server resources trying to recompress files that already uses a compression on their data. Also, Lempel-Ziv (.gz .zip) compression will give bigger files as a result (if you're using JPEG images).

The GD library would give the essential functions to do image processing like format conversion and reducing images to the maximum visible dimensions into the website template.

commented: great answer +6

thank you NIGDE IN TURKEY

Another thing you can do to reduce the space used is to use bicubic resize the make the images half the height and half the width but for large images this technique can use a lot of cpu when resizing them back with a bicubic resize unless you just use html to pixel resize to the original size.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.