Can you change the Texture Import Settings via C# Script?

Can I change ‘Non Power of 2’ in texture settings via script? Like if I make it none or ToNearest?

From an editor script you can access the TextureImporter class, which will give you access to the import settings of a Texture2D