image.py 752 B

12345678910111213141516171819202122232425
  1. import os
  2. from .. import constants, logger
  3. from . import base_classes, io, api
  4. class Image(base_classes.BaseNode):
  5. def __init__(self, node, parent):
  6. logger.debug('Image().__init__(%s)', node)
  7. base_classes.BaseNode.__init__(self, node, parent, constants.IMAGE)
  8. self[constants.URL] = api.image.file_name(self.node)
  9. @property
  10. def destination(self):
  11. dirname = os.path.dirname(self.scene.filepath)
  12. return os.path.join(dirname, self[constants.URL])
  13. @property
  14. def filepath(self):
  15. return api.image.file_path(self.node)
  16. def copy_texture(self, func=io.copy):
  17. logger.debug('Image().copy_texture()')
  18. func(self.filepath, self.destination)
  19. return self.destination