Advertisement
Guest User

Untitled

a guest
Jan 7th, 2013
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.38 KB | None | 0 0
  1. Index: gui.py
  2. ===================================================================
  3. --- gui.py  (revision 533)
  4. +++ gui.py  (working copy)
  5. @@ -41,6 +41,19 @@
  6.               "('effect=slide start=1280,-720 end=-1280,720 time=%i condition=true', 'conditional'), ('effect=zoom start=%i end=%i center=auto time=%i condition=true', 'conditional')",
  7.               "('effect=slide start=-1280,-720 end=1280,720 time=%i condition=true', 'conditional'), ('effect=zoom start=%i end=%i center=auto time=%i condition=true', 'conditional')"]
  8.  
  9. +# EXIF support is mostly to compensate for Apple's lazy jpg saving.
  10. +# The iPhone only even supports 1, 3, 6, and 8 so that's all
  11. +# we're putting in here for now.
  12. +# Since 1 is the default "horizontal," there's nothing to do
  13. +# for that one.
  14. +# Used this for documentation:
  15. +# http://www.gotow.net/creative/wordpress/?p=64
  16. +ROTATION = {
  17. +    3: "('effect=rotate start=0 end=180 time=0 center=auto condition=true', 'conditional')",
  18. +    6: "('effect=rotate start=0 end=270 time=0 center=auto condition=true', 'conditional')",
  19. +    8: "('effect=rotate start=0 end=90 time=0 center=auto condition=true', 'conditional')"
  20. +}
  21. +
  22.  def log(txt):
  23.      if isinstance (txt,str):
  24.          txt = txt.decode("utf-8")
  25. @@ -114,9 +127,12 @@
  26.              # iterate through all the images
  27.              for img in items:
  28.                  imgfile = xbmcvfs.File(img)
  29. -                tags = EXIF.process_file(imgfile)
  30. +                # stop at Orientation so we don't waste time loading
  31. +                # thumbnails, etc.
  32. +                tags = EXIF.process_file(imgfile, stop_tag='Orientation')
  33.                  # add image to gui
  34.                  cur_img.setImage(img)
  35. +                cur_animations = [ ]
  36.                  # give xbmc some time to load the image
  37.                  if not self.startup:
  38.                      xbmc.sleep(1000)
  39. @@ -138,10 +154,13 @@
  40.                      # add random slide/zoom anim
  41.                      if self.slideshow_effect == "2":
  42.                          # add random slide/zoom anim
  43. -                        self._anim(cur_img)
  44. +                        cur_animations = self._anim(cur_img)
  45.                      # add fade anim, used for both fade and slide/zoom anim
  46.                      self._set_prop('Fade%d' % order[0], '0')
  47.                      self._set_prop('Fade%d' % order[1], '1')
  48. +                # rotate based on exif tags, if they exist
  49. +                if tags:
  50. +                    self._exif_rotate(cur_img, cur_animations, tags)
  51.                  # define next image
  52.                  if cur_img == self.image1:
  53.                      cur_img = self.image2
  54. @@ -210,21 +229,6 @@
  55.                      images += self._walk(os.path.join(folder,item))
  56.          return images
  57.  
  58. -    def _get_exif(self, img):
  59. -        # extract exif data from image file and find the orientation tag value
  60. -        angle = '1'
  61. -        try:
  62. -            data = Image.open(img, 'r')
  63. -            info = data._getexif()
  64. -            if info:
  65. -                for tag, value in info.items():
  66. -                    key = TAGS.get(tag, tag)
  67. -                    if key == 'Orientation':
  68. -                        angle = str(value)
  69. -        except:
  70. -            pass
  71. -        return angle
  72. -
  73.      def _anim(self, cur_img):
  74.          # reset position the current image
  75.          cur_img.setPosition(0, 0)
  76. @@ -247,11 +251,21 @@
  77.          # position the current image
  78.          cur_img.setPosition(posx, posy)
  79.          # add the animation to the current image
  80. +        animations = [ ]
  81.          if number == 0:
  82. -            cur_img.setAnimations(eval(EFFECTLIST[number] % (self.adj_time)))
  83. +            animations = eval(EFFECTLIST[number] % (self.adj_time))
  84.          else:
  85. -            cur_img.setAnimations(eval(EFFECTLIST[number] % (self.adj_time, zoom, zoom, self.adj_time)))
  86. +            animations = eval(EFFECTLIST[number] % (self.adj_time, zoom, zoom, self.adj_time))
  87. +        cur_img.setAnimations(animations)
  88. +        return list(animations)
  89.  
  90. +    def _exif_rotate(self, cur_img, cur_animations=[ ], tags=False):
  91. +        if tags:
  92. +            rotate = ROTATION.get(tags.get('Orientation', 1), False)
  93. +            if rotate:
  94. +                new_animations = cur_animations + [ rotate ]
  95. +                cur_img.setAnimations(new_animations)
  96. +
  97.      def _get_animspeed(self):
  98.          # find the skindir
  99.          if xbmcvfs.exists( __skinxbmc__ ):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement