Is it possible to resize an image/texture not by scaling, but by adding transparent border?

I’m interested in this neat technique that allows you to create an outline around an image:

However, if the image does not have enough space for the outline, the outline will be cropped. Is there a way to “add extra border space” around an image texture?

Pixel art apps usually call this changing the “canvas size” of an image, rather than “scaling” the image.

Presumably you could just add some extra transparent pixels are the edges of the image, or shrink down the artwork a bit?

Yes, that’s certainly possible when I control the artwork. But in the game we’re building ( users can upload content. I could potentially process it on the server, but I was wondering if there’s a way to do it in JS on the client side.

Img_border.html (1011 Bytes)

1 Like

Thanks! That will do the trick.