Skip to content

How to use autojpg() filter on a cloudfront request ? #479

Answered by dougtoppin
aligajani asked this question in Q&A
Discussion options

You must be logged in to vote

@aligajani

Can you try using toFormat in your request to see if that does what you need?

const imageRequest = JSON.stringify({
    bucket: process.env.NEXT_PUBLIC_BUCKET_NAME,
    key: uuid,
    edits: {
        resize: {
            width : 400,
            height: 200,
            fit: 'cover',
        },
        toFormat: 'jpeg'
    }
});

I also should include that many of the sharp library functions can be used in edits.

These are not individually documented in the Implementation Guide so some experimentation may be necessary to confirm the expected behavior.

For example, the toFormat usage can be found at https://sharp.pixelplumbing.com/api-output#toformat

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by dougtoppin
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #478 on May 09, 2023 11:44.