The easiest way to do this is to use sprite scale like so:
var image = (‘res://assets/images.png’)
var scale = Vector2((percent of width), (percent of height))
var this_sprite = get_node(“sprite_node”)
this_sprite.set_texture(image)
this_sprite.set_scale(scale)
If anyone wanted to set size in pixels, then there is how you do it:
var is = get_node("sprite").get_texture().get_size() #image size
var th = 50 #target height
var tw = 100 #target width
var scale = Vector2((is.x/(is.x/tw))/50, (is.y/(is.y/th))/50)
Somehow while those /50, should be logically /100, they shouldn’t. For me, it made the sprites twice as small, so when setting /50 it was perfect. Might be different for you.
Soaku | 2017-05-10 18:39
Just in case someone else is also looking for it in 3.x, its changed to:
var s = Vector2()
s.x = x_scale
s.y = y_scale
$sprite.set_texture(your_texture)
$sprite.scale = s