old_contents: # parse_shadertoy_json.py
  
  from __future__ import print_function
  import json
  import os
  import sys
  from PIL import Image
  
  def dumpReadmeFile(info):
  	readmeFileOut = 'README.txt'
  	with open(readmeFileOut,'w') as outStream:
  		print("Title: " + info['name'], file=outStream)
  		print("Author: " + info['username'], file=outStream)
  		print('',file=outStream)
  		print("Tags: " + ', '.join(info['tags']), file=outStream)
  		print('',file=outStream)
  		print("Description: " + info['description'], file=outStream)
  		print('',file=outStream)
  		print('Generated from https://www.shadertoy.com/view/{0} by kinderegg.'.format(info['id']),file=outStream)
  
  
  textureHeader = """
  /*
   * Generated by parse_shadertoy_json.py
   */
  """
  def dumpTextureHeader(renderpass):
  	readmeFileOut = 'g_textures.h'
  	texDir = os.path.join('..', 'textures')
  	with open(readmeFileOut,'w') as outStream:
  		print(textureHeader,file=outStream)
  		pass_id = 0
  		for r in renderpass:
  			# Pull out textures
  			for t in r['inputs']:
  				texfile = os.path.basename(t['src'])
  				print("    tex" + str(t['channel']) + ": " + texfile, end='')
  				img = Image.open(os.path.join(texDir,texfile))
  				px = img.load()
  				print("    size: ", img.size, end='')
  				for i in range(5):
  					print(" " + str(px[i,0]), end='')
  				print("")
  				# TODO: Save to header
  
  
  def parseJsonFile(jsonfile):
  	j = json.loads(open(jsonfile).read())
  
  	#print(json.dumps(j,indent=1))
  	info = j['Shader']['info']
  	dumpReadmeFile(info)
  
  	renderpass = j['Shader']['renderpass']
  	dumpTextureHeader(renderpass)
  
  	for r in renderpass:
  		print(r['type'])
  		print("    code: " + str(len(r['code'])) + " bytes")
  		#print(r['code'])
  		# TODO: Save to header
  
  #
  # Main: enter here
  #
  def main(argv=None):
  	#jsonfile = "4lX3RB.txt"
  	jsonfile = "ldXXDj.txt"
  	parseJsonFile(jsonfile)
  
  
  if __name__ == "__main__":
  	sys.exit(main())
  
new_contents: # parse_shadertoy_json.py
  
  from __future__ import print_function
  import json
  import os
  import sys
  from PIL import Image
  
  def dumpReadmeFile(info):
  	readmeFileOut = 'README.txt'
  	with open(readmeFileOut,'w') as outStream:
  		print("Title: " + info['name'], file=outStream)
  		print("Author: " + info['username'], file=outStream)
  		print('',file=outStream)
  		print("Tags: " + ', '.join(info['tags']), file=outStream)
  		print('',file=outStream)
  		print("Description: " + info['description'], file=outStream)
  		print('',file=outStream)
  		print('Generated from https://www.shadertoy.com/view/{0} by kinderegg.'.format(info['id']),file=outStream)
  
  
  textureHeader = """
  /*
   * Generated by parse_shadertoy_json.py
   */
  """
  def dumpTextureHeader(renderpass):
  	readmeFileOut = 'g_textures.h'
  	texDir = os.path.join('..', 'textures')
  	with open(readmeFileOut,'w') as outStream:
  		print(textureHeader, file=outStream)
  		pass_id = 0
  		for r in renderpass:
  			# Pull out textures
  			tex_id = 0
  			for t in r['inputs']:
  				texfile = os.path.basename(t['src'])
  				print("    tex" + str(t['channel']) + ": " + texfile, end='')
  				img = Image.open(os.path.join(texDir,texfile))
  				px = img.load()
  
  				arrayname = 'tex' + str(pass_id) + str(tex_id)
  				vardecl = 'int {0} = {1};'
  				print(vardecl.format(arrayname+'w', img.size[0]), file=outStream)
  				print(vardecl.format(arrayname+'h', img.size[1]), file=outStream)
  
  				print("    size: ", img.size, end='')
  				for i in range(5):
  					print(" " + str(px[i,0]), end='')
  				print("")
  
  				# TODO: Save to header
  				tex_id += 1
  			pass_id += 1
  
  
  def parseJsonFile(jsonfile):
  	j = json.loads(open(jsonfile).read())
  
  	#print(json.dumps(j,indent=1))
  	info = j['Shader']['info']
  	dumpReadmeFile(info)
  
  	renderpass = j['Shader']['renderpass']
  	dumpTextureHeader(renderpass)
  
  	for r in renderpass:
  		print(r['type'])
  		print("    code: " + str(len(r['code'])) + " bytes")
  		#print(r['code'])
  		# TODO: Save to header
  
  #
  # Main: enter here
  #
  def main(argv=None):
  	#jsonfile = "4lX3RB.txt"
  	jsonfile = "ldXXDj.txt"
  	parseJsonFile(jsonfile)
  
  
  if __name__ == "__main__":
  	sys.exit(main())
  
subject: Write texture dimensions as variables.