process_starling_atlas.py 843 B

123456789101112131415161718192021222324252627282930313233343536
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals, print_function
  3. import os
  4. try:
  5. import Image
  6. except ImportError:
  7. from PIL import Image
  8. from . import process
  9. class starling_atlas_Processor(process.Process):
  10. node_id = "starling"
  11. def __init__(self):
  12. pass
  13. def process(self, context, walker):
  14. meta = walker.root_meta
  15. xml_path = walker.getPath("file")
  16. folder = os.path.split(xml_path)[0] + "/"
  17. file_doc = context._open_xml(context.src_data + xml_path)
  18. file_root = file_doc
  19. image_name = file_root.getAttribute("imagePath")
  20. image_path = context.src_data + folder + image_name
  21. image = Image.open(image_path)
  22. image.load()
  23. meta.setAttribute("tw", str(image.size[0]))
  24. meta.setAttribute("th", str(image.size[1]))