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개 답변
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.

답변함 8달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠