# Texture import settings script not working unity.

I have written a script that should make sure the aspect ratio of my image stays the same when i import it into unity.
This is the script:

public class PostprocessImages : AssetPostprocessor
{
void OnPostprocessTexture(Texture2D texture)
{
TextureImporter textureImporter = (TextureImporter)assetImporter;
textureImporter.npotScale = TextureImporterNPOTScale.None;
textureImporter.mipmapEnabled = false;
}
}


the script is located in the Editor folder in Assets. But when i import an image i get the following result:

this is definitly not what i am looking for.
It should look like this:

But when i just go to the inspector of the imported image and change a random setting and hit apply the texture does get the proper aspect ratio back. And the settings i modified in the code. Are correct when i inspect the image. But the image doesnt have the right aspect ration..
See image below:

how would i go about making the image have the right aspect ratio, right from the getgo (when i import it). Because i dont want to do it manual since i have to import hundereds of images.

Let me know if something is unclear so i can clarify.