Serverless Image Handler extraction for cropping an image

0

Hey, I am using AWS Serverless Image Handler for resizing the image along with extracting a certain cropped area. However the extraction is not working properly. I believe AWS uses Sharp Pixel for performing the image processing operations and sharp has an operation called extract however I do not see any implementation of it in the code.

I am passing the following request

const request = {
        bucket: // S3 bucket name
        key, // path to your file on the S3 bucket (ex. public/larger-photo.jpg)
        edits: {
            webp: true, // if android, android loves webp
            jpeg: true, // if iOS, iOS doesnt display webp so lets convert it
            resize: { //see https://sharp.pixelplumbing.com/api-resize for docs/settings
                width: 1000,
                height: 750,
                fit: "cover",
            },
        },
        extract: {
            left: area.x,
            top: area.y,
            width: area.width,
            height: area.height
        }
    }

Out here area is the cropped area that I need. I am not sure if I am following the right syntax as there is no documentation around it. Kindly let me know if AWS does any sort of extraction or cropping of a specific region for an image.

1 Answer
0

Hi, Did you check out the solution: https://docs.aws.amazon.com/solutions/latest/serverless-image-handler/overview.html It has code for cropping image. Could you please deploy the cloudformation stack for this solution and check if it satisfies your use-case.

answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions