Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: gui.py
- ===================================================================
- --- gui.py (revision 533)
- +++ gui.py (working copy)
- @@ -41,6 +41,19 @@
- "('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')",
- "('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')"]
- +# EXIF support is mostly to compensate for Apple's lazy jpg saving.
- +# The iPhone only even supports 1, 3, 6, and 8 so that's all
- +# we're putting in here for now.
- +# Since 1 is the default "horizontal," there's nothing to do
- +# for that one.
- +# Used this for documentation:
- +# http://www.gotow.net/creative/wordpress/?p=64
- +ROTATION = {
- + 3: "('effect=rotate start=0 end=180 time=0 center=auto condition=true', 'conditional')",
- + 6: "('effect=rotate start=0 end=270 time=0 center=auto condition=true', 'conditional')",
- + 8: "('effect=rotate start=0 end=90 time=0 center=auto condition=true', 'conditional')"
- +}
- +
- def log(txt):
- if isinstance (txt,str):
- txt = txt.decode("utf-8")
- @@ -114,9 +127,12 @@
- # iterate through all the images
- for img in items:
- imgfile = xbmcvfs.File(img)
- - tags = EXIF.process_file(imgfile)
- + # stop at Orientation so we don't waste time loading
- + # thumbnails, etc.
- + tags = EXIF.process_file(imgfile, stop_tag='Orientation')
- # add image to gui
- cur_img.setImage(img)
- + cur_animations = [ ]
- # give xbmc some time to load the image
- if not self.startup:
- xbmc.sleep(1000)
- @@ -138,10 +154,13 @@
- # add random slide/zoom anim
- if self.slideshow_effect == "2":
- # add random slide/zoom anim
- - self._anim(cur_img)
- + cur_animations = self._anim(cur_img)
- # add fade anim, used for both fade and slide/zoom anim
- self._set_prop('Fade%d' % order[0], '0')
- self._set_prop('Fade%d' % order[1], '1')
- + # rotate based on exif tags, if they exist
- + if tags:
- + self._exif_rotate(cur_img, cur_animations, tags)
- # define next image
- if cur_img == self.image1:
- cur_img = self.image2
- @@ -210,21 +229,6 @@
- images += self._walk(os.path.join(folder,item))
- return images
- - def _get_exif(self, img):
- - # extract exif data from image file and find the orientation tag value
- - angle = '1'
- - try:
- - data = Image.open(img, 'r')
- - info = data._getexif()
- - if info:
- - for tag, value in info.items():
- - key = TAGS.get(tag, tag)
- - if key == 'Orientation':
- - angle = str(value)
- - except:
- - pass
- - return angle
- -
- def _anim(self, cur_img):
- # reset position the current image
- cur_img.setPosition(0, 0)
- @@ -247,11 +251,21 @@
- # position the current image
- cur_img.setPosition(posx, posy)
- # add the animation to the current image
- + animations = [ ]
- if number == 0:
- - cur_img.setAnimations(eval(EFFECTLIST[number] % (self.adj_time)))
- + animations = eval(EFFECTLIST[number] % (self.adj_time))
- else:
- - cur_img.setAnimations(eval(EFFECTLIST[number] % (self.adj_time, zoom, zoom, self.adj_time)))
- + animations = eval(EFFECTLIST[number] % (self.adj_time, zoom, zoom, self.adj_time))
- + cur_img.setAnimations(animations)
- + return list(animations)
- + def _exif_rotate(self, cur_img, cur_animations=[ ], tags=False):
- + if tags:
- + rotate = ROTATION.get(tags.get('Orientation', 1), False)
- + if rotate:
- + new_animations = cur_animations + [ rotate ]
- + cur_img.setAnimations(new_animations)
- +
- def _get_animspeed(self):
- # find the skindir
- if xbmcvfs.exists( __skinxbmc__ ):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement