Image Crop for Web and Mobile
10 Minutes to Integrate

Cropping images is a common task and an everyday routine for producing content. We believe image crop should happen right in your browser and be intuitive and simple. Firing a dedicated image editor to do the cropping is an overkill.

This tutorial is about enabling your users to crop images in any browser with Uploadcare, no matter the device or browser they use.

You can get this up and running in 10 minutes with our file uploader. The uploader is a widget written in JavaScript; you can customize it to fit your app look and user experience.

Image Crop Preview

There are three simple steps to take:

Step 1. Set Up Your Uploadcare Account and Project

In case you don’t have an Uploadcare account, Sign Up for one. Once you get it, navigate to your dashboard to create a new project or discover API keys for an existing one.

You will only need the Public API Key that points to a target project where the images will go to.

Step 2. Pick Where You Want the Crop

Pick a form in your web app where you want users to crop images. It could be a profile editing form, image upload form, etc.

Note, our widget enables your users to upload images from their camera, social media, cloud storage, and more. We call those “Upload Sources,” and you can learn more about them in our docs.

Step 3. Integrate the Widget

You install the widget by adding a couple of <script> elements to your page <head>. It comes in a variety of bundles and is usually served from our CDN.

Here’s how it goes. First, add this to your page <head>:

<script>UPLOADCARE_PUBLIC_KEY = 'your_public_key';</script>
<script src="https://ucarecdn.com/libs/widget/3.6.2/uploadcare.full.min.js" charset="utf-8"></script>

Next, place this <input> where you want our widget to appear on your page:


The widget looks for inputs with role="uploadcare-uploader" and places its button there.

Note, the value attribute may either be empty or contain a CDN URL or UUID of an image on Uploadcare. The non-empty value will preload a file into your widget dialog. Otherwise, your users will be prompted to load a file from one of the enabled Upload Sources. You can learn more about default files in the widget dialog in our docs.

That’s what you should get by now:

Once you’re done cropping, your image CDN URL gets updated with the crop Image Transformation. The widget then passes the updated CDN URL to the input value, and from there you can use it for other routines.

That’s how the updated CDN URL may look like:


You can define the widget crop presets by specifying the data-crop attribute. This is useful when you want specific aspect ratios, image dimensions, etc.

Yoohoo, That’s it 🚀

You’ve just enabled image crop in your app via Uploadcare without breaking a sweat. Great job!

If you’d like to customize the widget to your app’s look, check out the docs section on widget styling.

Our widget is open source, here's its GitHub repo. Issues and PRs are welcome.

We’re always happy to help with code, integration, and other stuff. Search our site for more info or post your question in our Community Area.