0 votes

Hello, I want to save the sprite node to an image file and i've tried this code: $Sprite.get_texture().get_data().save_png()
but it only save the texture not sprite completely like modulate, scale, rotation etc.

so, how to save sprite node into image files? or, how to convert sprite node to texture and save the texture into image?

*i don't want a screenshoot

Godot version 3.5
in Engine by (15 points)

2 Answers

0 votes
Best answer

I'm not super sure if this would work, but try this:

  1. Copy sprite node and instance it as a child of a viewport.

  2. Get viewport texture (make sure viewport background is set to transparent)

by (146 points)
selected by

If it works, this would be like taking a screenshot but ignoring every other node.

Thank you, the problem when i use screenshoot is the backround and now the backround is transparent

+1 vote

Try putting the Sprite in a Viewport, which keeps what it renders as a dynamic texture. Then you can callviewport.get_texture().get_data().save_png()

by (185 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.