v8.77.0

Can the editor limit the size of the output image?

We can set the maximum size of the output image using the targetSize property on the createDefaultImageWriter method. This will limit the size of the output image to the targetSize width and height properties.

To upscale the image to fit the defined output size, set upscale to true.

import { openDefaultEditor } from './pintura.js';

openDefaultEditor({
    imageWriter: {
        targetSize: {
            width: 512,
            height: 512,
            upscale: true,
        },
    },
});

By default Pintura Image Editor will 'contain' the image to the supplied width and height. If the image is in a different aspect ratio it will be scaled down (or up) to fit inside the defined size.

To force the image to the defined size, and ignore the image aspect ratio, set the fit property to 'force'.

To cover the target size with the image, set the fit property to 'cover'.

openDefaultEditor({
    imageWriter: {
        targetSize: {
            width: 512,
            height: 512,
            fit: 'cover',
        },
    }),
});

It's currently not possible to set a limit in Kilobytes.