How To Set Image Upload Requirements On Your Website

Let’s say you collect photos for use in a community member page. You want every member profile picture to be a square, the photo should be large enough to look good, but not so large that it takes too long to upload.

We could list those requirements next to the upload field. But that leaves each member to work out how to crop, resize, and save their photo. We can remove that hurdle and automatically handle those requirements as part of the upload step instead.

Decide What The Form Needs

For our directory, we’ll ask for:

How to decide on these numbers? Start with where the image will be used. A small profile picture and a large print order need different minimum sizes. If another system receives the upload, check which formats and file sizes it accepts and work from there.

What Happens When A Member Chooses A Photo?

When using CropGuide a photo editor is automatically added to the file upload field you already have. When a member selects a photo, the editor opens and they see a square crop and can move or zoom it to keep their face in frame.

If the photo or chosen crop is too small, CropGuide lets them know while they’re still on the page. A larger photo can be cropped and resized to the dimensions we expect. The resulting image goes back to your existing form, which uploads it to the same destination as before.

The member doesn’t have to know what an aspect ratio is, how to compress large files, or open a third-party app to resize a file. It’s all handled on the page.

Set The Image Shape And Minimum Size

How to set this up? First we need to add CropGuide to the webpage.

When we log in we can open the CropGuide dashboard and set Crop aspect ratio to 1 for a square crop.

We set the Minimum image size to 512 × 512 pixels to match our example. This prevents users from uploading a tiny photo, or making a crop of a larger photo that’s too small.

Note that the minimum size checks pixel dimensions. It can’t tell whether a photo is blurry.

For more on this check, see how to prevent low-resolution image uploads.

Choose The Resulting Size, Format, And Compression

Next set Output size to 512 × 512 pixels. Minimum size and output size do different jobs. The minimum stops the field from accepting a crop with too few pixels. The output size controls the dimensions of the image that’s passed back to the form. If we don’t provide an output size the resulting image could still be lots larger than than what our member directory needs.

We can choose JPEG as the output format. The file a member selects doesn’t always have to be in the same format as the file your form receives. Check your form’s accepted formats, especially if members may choose iOS HEIC photos.

Finally, set the output quality to compress the photo. Lowering the quality setting reduces the file size, but pushing it too far can make the image look worse. It’s best to try a few settings.

Note that compression doesn’t guarantee that every upload will fall below a particular file-size limit; if your form has a hard limit, make sure that compressed photos fall below the threshold.

Add The Requirements To Your Existing Upload Field

There’s no new form or upload destination to set up. After adding the script tag CropGuide works and will catch images added to file input fields. After editing the image your form receives the resulting file and sends it where it already sends uploads. Photos or photo metadata is never uploaded to CropGuide’s servers.

Follow the installation guide for setup, or check the integration guides for your website platform.

We’ve set a square shape, minimum size, output size, format, and compression for the directory photo. Members that upload photos now don’t have to think about it, their uploaded files will automatically meet those requirements, resulting in better photos and less frustration.

Try the live demo to see the editing step.