Serverless Image Handler extraction for cropping an image


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 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 réponse

Hi, Did you check out the solution: It has code for cropping image. Could you please deploy the cloudformation stack for this solution and check if it satisfies your use-case.

répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions