is it possible to write a script that renders an image in blender
The simplest way to do this would be to have a project whose textures point to a files with a known location. Replacing those files with new ones with the same name would take care of the textures.

Then just render using the command line.

blender -b file.blend -a


would render the animation with no GUI.

To set the output path use:

blender -b file.blend -a -o &lt;path&gt;


Read:
https://docs.blender.org/manual/en/latest/render/workflows/command_line.html

and 

https://docs.blender.org/manual/en/latest/advanced/command_line/arguments.html