Change Texture size but keep aspect ratio the same!

I have a texture that is 512x348. In photoshop i can expand the canvas size to 512x512 which maintains the images aspect ration by adding borders of a chosen color to the edges.

Is there anyway to script this in unity. Ie layer 2 textures together one at 512x380 and the other at 512x512 and save the resulting image texture?

I have a resize script but nothing that will change the canvas size like in photoshop?

Click on the texture, then look at the inspector where the import settings are. You’ll see ‘Texture Type’, change it to Advanced, then set the non-power of 2 to whichever makes you happy. This will import the texture and add that bit of canvas you need.