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 Antwort
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.

beantwortet vor 8 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen