Finally getting back to this 🙂
I found some instructions regarding blit here and tried it out: https://ask.godotengine.org/83298/how-create-new-image-inside-godot-from-fragments-other-images
My code
func _ready():
var img = Image.new()
img.create(1200, 1200, false, Image.FORMAT_RGB8)
var blitImage = Image.new()
blitImage.load("res://avatar.jpg")
img.blit_rect(blitImage, blitImage.get_used_rect(), Vector2(40, 40))
img.save_jpg("res://avatar_blit.jpg")
but when I run it, it returns
E 0:00:00:0578 Node.gd:10 @ _ready(): Condition "dsize == 0" is true.
<C++ Source> core/io/image.cpp:2786 @ blit_rect()
<Stack Trace> Node.gd:10 @ _ready()
E 0:00:00:0578 Node.gd:11 @ _ready(): Condition "p_img.is_null() || p_img->is_empty()" is true. Returning: ERR_INVALID_PARAMETER
<C++ Source> modules/jpg/image_loader_jpegd.cpp:158 @ _jpgd_save_to_output_stream()
<Stack Trace> Node.gd:11 @ _ready()
I have already checked, according to the Godot inspector the avatar.jpg is of format RGB8 so that can be ruled out as issue.
What am I missing here?
You can find the complete project here for reference:
https://www.dropbox.com/scl/fi/iglu4lu96gq8uksy2mljq/blit.zip?rlkey=yj95vki9xelmkqrldevkh3kl4&dl=0