Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing animation while uploading to s3 using sharp #4022

Closed
jinnymoon1124 opened this issue Mar 6, 2024 · 5 comments
Closed

removing animation while uploading to s3 using sharp #4022

jinnymoon1124 opened this issue Mar 6, 2024 · 5 comments
Labels

Comments

@jinnymoon1124
Copy link

Question about an existing feature

I was using sharp library to resizing images, and while testing,
I found out that when type of file is gif,
after resizing, animation disappears.

What are you trying to achieve?

want to know the reason why animation disappearing..

When you searched for similar issues, what did you find that might be related?

version ? -> "sharp": "^0.32.1"
option ? -> animated: true

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question

` if (contentType === "image/webp") {
await uploadFile(bucketName, filepath, originalImage, contentType);
} else {
const resizedImage = await resizeImage(originalImage, 'webp', { quality: 85 });
await uploadFile(bucketName, zippedFilePath, resizedImage, contentType);
}

...

async function resizeImage(image, format, options) {
console.log(start resizeImage);

const resizedImage = await sharp(image, {animated: true, failOn: "truncated"})
.toFormat(format, options)
.toBuffer();

console.log(finish resizeImage);

return resizedImage;
}

async function uploadFile(bucketName, key, data, contentType) {
console.log(start uploadFile: ${bucketName}/${key});

try {
await s3
.putObject({
Bucket: bucketName,
Key: key,
Body: data,
Tagging: 'writer=lambda',
ContentType: contentType
})
.promise();

console.log(`finish uploadFile: ${bucketName}/${key}`);

} catch (error) {
console.error('Error uploading file:', error);
throw error;
}
}
`

Please provide sample image(s) that help explain this question

@lovell
Copy link
Owner

lovell commented Mar 6, 2024

As long as you're using both the { animated: true } constructor option and an output format that supports animation then this should work. It looks like the code provided here might do this, but it's not complete code and no image has been provided so no one else will be able to tell for sure.

If you still need help, please provide a standalone repo with minimal code (e.g. no networking) and image(s) that allows someone else to reproduce.

@jinnymoon1124
Copy link
Author

https://github.com/jinnymoon1124/s3/blob/main/index.js
I also thought it should work with animation,,
this is the code im working on :)

@lovell
Copy link
Owner

lovell commented Mar 6, 2024

How would someone else reproduce the problem using the code you've provided?

If you still require help, please simplify the code further, for example remove all networking logic, as well as providing a sample image that can be read from the filesystem.

@lovell
Copy link
Owner

lovell commented Apr 11, 2024

@jinnymoon1124 Were you able to make any progress with this? If you still require help, please provide the requested information.

@lovell
Copy link
Owner

lovell commented Apr 29, 2024

Closing due to inactivity but please feel free to reopen with more details if further help is required.

@lovell lovell closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants