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

[3.x] Backport Image.save_jpg and Image.save_jpg_to_buffer from Godot 4 #63844

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from

Conversation

skadge
Copy link

@skadge skadge commented Aug 2, 2022

@skadge skadge force-pushed the backport-jpg-save branch from 7115a4c to 11bf7ac Compare August 2, 2022 20:54
@Calinou Calinou added this to the 3.x milestone Aug 2, 2022
@skadge skadge force-pushed the backport-jpg-save branch from 11bf7ac to face30f Compare August 3, 2022 07:41
@skadge
Copy link
Author

skadge commented Aug 3, 2022

Integration complete, but jpg encoding is ~grabbled. For instance, capturing a viewport's texture and saving it as a jpg:

get_node("Viewport").get_texture().get_data().save_jpg("/tmp/test.jpg", 0.9)

generates the following image:

image

If anyone knows what it might be (texture compression?), I'd love to hear. Otherwise I'll give it another go when I come back from holidays.

skadge added 2 commits August 21, 2022 17:18

Verified

This commit was created on github.com and signed with GitHub’s verified signature.
Backported from godotengine@5786516d4d6b51
@skadge skadge force-pushed the backport-jpg-save branch from 9eb6d3a to f409251 Compare August 21, 2022 15:18
@skadge skadge marked this pull request as ready for review August 21, 2022 15:18
@skadge skadge requested review from a team as code owners August 21, 2022 15:18
@skadge
Copy link
Author

skadge commented Aug 21, 2022

The code is now working as expected and ready for review.

@YuriSizov
Copy link
Contributor

CI fails because you have formatting issues. Extra empty lines in the highlighted methods in cpp and wrong indentation in documentation XML.

@skadge
Copy link
Author

skadge commented Aug 24, 2022

@YuriSizov thanks, fixed. Let see if the CI is happy now.

@severin-lemaignan
Copy link

Any chance for that PR to be merged anytime soon?

severin-lemaignan added a commit to severin-lemaignan/officebots that referenced this pull request Oct 11, 2022
Reaches ~10fps with a 320x240 viewport image, compressed as
jpg -> communication over websockets is slow!

NOTE: requires recompiling Godot 3.x with this patch:
godotengine/godot#63844

(which adds support for jpg compression)
@akien-mga
Copy link
Member

Could you squash the commits? See PR workflow for instructions.

As a side note, it doesn't seem to be only a backport of #62122 as you seem to have also implemented the missing _jpeg_save_func. It would be good to point this out especially when it means that the master version was still broken. Thankfully it got reported as a bug and someone else has a PR implementing it: #66929.

@BlooRabbit
Copy link

BlooRabbit commented Mar 11, 2023

Hello, is this going to be merged into 3.5 at some point ?

It is extremely useful to use jpg rather than png for saving in-game made images and optimizing save space (I have 1000nds of frog images to save 😁).

EDIT: Just tried it out myself, the commit works perfectly and the results are amazing in terms of space saving.
image

@akien-mga akien-mga changed the title Backport Image.save_jpg and Image.save_jpg_to_buffer from 4.x to 3.x [3.x] Backport Image.save_jpg and Image.save_jpg_to_buffer from Godot 4 Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants