I've knocked together a very rough script to generate these 'background-1.xml' files. Just put the script in a directory with some jpg images and run it - simple.
The script could be a lot better and tidier, I don't write python. Feel free to post cleaner versions in the comments.
#Generate XML file based on local jpg files
#User Variables - change these if you're feeling brave
transition_time = 5
display_time = 300
random_order = True
#------End of User Variables-------#
import os
import random
file_name = "background-1.xml"
cwd = os.getcwd()
try:
os.remove(file_name)
except:
pass
f = open(file_name, 'w')
f.write('<background>\n')
dirList = os.listdir(".")
imgList = []
staticList = []
if random_order:
random.shuffle(dirList)
for fname in dirList:
if fname[-4:] == ".jpg":
ffname = "%s/%s" % (cwd,fname)
imgList.append(ffname)
staticList.append("<static>\n\t<duration>%.1f</duration>\n\t<file>%s</file>\n</static>\n" %
(display_time, ffname))
endIdx = imgList.__len__()-1
for idx in range(0, endIdx+1):
#If we're at the end of the list, transition back to the first.
transIdx = idx+1 if idx!= endIdx else 0
f.write(staticList[idx])
f.write("<transition>\n\t<duration>%.1f</duration>\n\t<from>%s</from>\n\t<to>%s</to>\n</transition>\n" %
(transition_time, imgList[idx], imgList[transIdx]))
f.write('</background>')
No comments:
Post a Comment