Script behaves differently when executed inside blender console vs python interpreter
running blender -b -P script.py will start blender in background mode, notice the -b option.
For that reason all Viewer nodes will be deactivated and set to default size 256*256.

Try removing the -b option.