Free plan

Crop photos from a scan

Cut several photos from one scan into separate pictures
POST
/v1/images/crop-photos

About this tool

Finds the photos lying on one scan (such as several prints on a scanner) and cuts each one out as its own straightened picture, in reading order. You can set the smallest size that counts as a photo, how many to cut out at most, the background colour of the scanner, and whether to straighten crooked photos.
For example, you scan eight old prints at once and get eight separate picture files.

How to use it

  1. Choose this tool.
  2. Add your scan with Upload or drag and drop.
  3. Check the options, such as the most photos to cut out and straightening.
  4. Press Generate.
  5. Download the separate photos.

What you get back

You get one new picture for each photo found, which you can download.
GOOD TO KNOW
Works on the real pixels. A scan with no photo gives an empty list and a hint. One scan counts as one image; each photo is an output.
TEST IT LIVE

Try Crop photos from a scan in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
Images
Plan
Free
Method
POST
Endpoint
/v1/images/crop-photos
Tool ID
images.crop-photos
Authentication
API key
Accepts
JPEG, PNG, WEBP, GIF, AVIF, TIFF +15 more
Background jobs
Yes
Usage group
Image
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/images/crop-photos" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'images=@photo.jpg' \
  -F 'min_area=2' \
  -F 'tolerance=28' \
  -F 'background=#f4f4f0'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.images.cropPhotos({
    "images": 'photo.jpg',
    "min_area": 2,
    "tolerance": 28,
    "background": "#f4f4f0"
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->images()->cropPhotos([
    'images' => 'photo.jpg',
    'min_area' => 2,
    'tolerance' => 28,
    'background' => '#f4f4f0',
]);
echo $result->requestId;
FAQ

Frequently asked questions

Find several photos laid on a scanner bed or a table, straighten each one and cut it out as its own picture, in reading order.

Crop photos from a scan accepts JPEG, PNG, WEBP, GIF, AVIF, TIFF, SVG, SVGZ, BMP, ICO, APNG, PNM and 9 more. You can send several files in one request.

Crop photos from a scan is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/images/crop-photos with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.