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

Add input to specify PNG, JPEG, or WebP output formats #80

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mattt
Copy link
Contributor

@mattt mattt commented May 9, 2023

Resolves #75

Currently, predictions generate images in PNG format. This PR adds a new format input that allows predictions to generate JPEG and WebP formats instead. If unspecified, the PNG is used by default.

@mattt mattt requested a review from zeke May 9, 2023 23:15
@zeke
Copy link
Member

zeke commented May 11, 2023

So it automatically saves as each image type based on the extension of the target filename? 🤔

@mattt
Copy link
Contributor Author

mattt commented May 11, 2023

So it automatically saves as each image type based on the extension of the target filename? 🤔

Yes. This behavior comes from Pillow:

[T]he save() method looks at the name to determine which format to use, unless the format is given explicitly.

Copy link
Member

@zeke zeke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@mattt mattt marked this pull request as draft May 14, 2023 12:55
@mattt
Copy link
Contributor Author

mattt commented May 14, 2023

PNG and JPEG work correctly, but there's a bug in Cog around MIME types and data URI encoding/decoding that prevents WebP path outputs being saved to disk (at least when running `cog predict; I haven't tested running the model on Replicate).

Converting to draft until that's resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should we have a JPG and/or WebP output option?
2 participants