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

Fix Image::fromString to support PNG and WebP files #31

Merged

Conversation

klaari
Copy link
Contributor

@klaari klaari commented Nov 12, 2024

  • Add missing fromString methods to PNG and WebP classes
  • Update Image::fromString to read image size and MIME type with getimagesizefromstring
  • Update and refactor related tests

Fixes #30

- Add missing fromString methods to PNG and WebP classes
- Update Image::fromString to read image size and MIME type with getimagesizefromstring
- Update and refactor related tests
@ilu ilu requested a review from lourot November 12, 2024 11:42
@ilu
Copy link
Member

ilu commented Nov 12, 2024

Thanks @klaari ! @lourot do you have time to review this or should I give it a go?

@lourot
Copy link
Member

lourot commented Nov 12, 2024

@ilu I have time to review on Thursday but if @klaari needs this to be published already, feel free to merge/publish now and I can still review afterwards :)

For publishing, all you need to do is push a git tag with the new version number after you have merged. See https://docs.frameright.io/php/contributing#releasing

@lourot
Copy link
Member

lourot commented Nov 12, 2024

(and thanks for the contribution @klaari !)

@klaari
Copy link
Contributor Author

klaari commented Nov 13, 2024

@ilu I have time to review on Thursday but if @klaari needs this to be published already, feel free to merge/publish now and I can still review afterwards :)

Thanks for the quick reply @ilu & @lourot! This isn't super urgent, publishing this week would be great.

@ilu
Copy link
Member

ilu commented Nov 13, 2024

@lourot I think it's better you review & publish, but let me know if something comes up and I can take over so we get it out this week 🙌

Expected to fail because in the current implementation,
Image::fromString() calculates the image size but
methods like PNG::fromString() and JPEG::fromFile()
don't.
Copy link
Member

@lourot lourot left a comment

Choose a reason for hiding this comment

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

@klaari this looks great and I could have merged as is but I spotted an additional issue and maybe we could go the extra-mile and fix it as well. What do you think?
Right now Image::fromString() calculates the image size but PNG::fromString() and JPEG::fromFile() for example don't. I think all these methods should behave the same and calculate the image size. I have added now-failing test assertions to illustrate that. If you agree but have no time, that's perfectly fine, I can also do it. Just let me know.

And thanks a lot for having refactored the tests. It looks way better now!

@klaari
Copy link
Contributor Author

klaari commented Nov 15, 2024

Hi @lourot! Good point, I agree.
I pushed an update

@lourot
Copy link
Member

lourot commented Nov 15, 2024

@klaari Thanks a lot! I refactored a bit and will merge and release in a few hours. Please shout if you think I may have missed something.

@lourot lourot merged commit 2c9b9c0 into Frameright:master Nov 15, 2024
5 checks passed
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.

Failing to create a PNG object from string
3 participants