Getting image proportions
#1
i'm writing a script to grab an image from a website and there is no guarantee of the image's size. it can fluctuate.

at the moment i have it all done excpet for the display.

does anyone know any code which will get the image's size and scale it in proprtion on screen. ideally i need it to be 80% or so of the screen width and the image is always in landscape.

much appreciated.
Reply
#2
if you use a guiimage object to display it, then just setting it's width to what you want, then setting it to keep the aspect ratio will do the trick. i'm not sure how much of the underlying control is exposed via python.

perhaps some python gurus can fill us in?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
never tried but have a look in the pil (python imaging library) maybe some functions will do the tricks !
keep in touch
Reply
#4
ok, this is where i have got to so far. i've gone and grabbed the images i want and i have found that they are actually teh same size in gif and a differnet size in jpg. these sizes actually stay the same which helps me a lot.

here is my displaying function.

Quote:def showimage( self, localcopy ):
if localcopy[-4:] == ".jpg":
picsize = (725, 525)
if localcopy[-4:] == ".gif":
picsize = (600, 214)
if emulating:
picture= xbmcgui.controlimage(0, 0, picsize[0],picsize[1], localcopy)
self.addcontrol(picture)

however, what i'm finding is that if i try to change this to scale it:

Quote:picture= xbmcgui.controlimage(0, 0, picsize[0],picsize[1], localcopy)

the image stays the same size and is actually bigger than my screen. so far i've only tried this on the emulator but an earlier attempt had the start position 0,0 totally off screen and useless. this is on a pal system by the way.

does the image have to be its original size or can it be shrunk?
Reply
#5
pil is working out nicely on the emulator, going to do a bit of testing on the xb asap and will post results when i have them.
Reply
#6
nice Wink
Reply

Logout Mark Read Team Forum Stats Members Help
Getting image proportions0