I am setting up my experiment using PsychoPy and have images of two different sizes, largely due to portrait and landscape formats. Using the standard size attribute, PsychoPy depicts them in square format, which distorts the proportions of the images. I am therefore looking for a way to maintain the original aspect ratio of the images so that they are still presented in their respective portrait and landscape formats without image distortion. Additionally, the original size of the images is too large, taking up more than the entire screen (i.e., only part of the image is displayed), if I do not set the size attribute. So, I'd like to rescale the images such that they are displayed in their entirety, but only take up part of the screen, thus allowing, for instance, a slider scale to also be displayed at the bottom. I have already tried various solutions discussed online, but they haven't done the trick for me (see: link1, link2, link3). I am currently trying to fix this in coder view, but would also be open for solutions from builder view - whichever does the trick, really. Below is my current code snippet, I have left some of the other avenues I have tried thus far in comments, in case that's helpful:
#scale = 0.07
image = visual.ImageStim(
win=win,
name='image',
image='sin', mask=None, anchor='center',
ori=0.0, pos=(0, 0.1), #size=(1, 1),
color=[1,1,1], colorSpace='rgb', opacity=None,
flipHoriz=False, flipVert=False,
texRes=128.0, interpolate=True, depth=-1.0)
image.setSize(0.04, '*') #multiply the current size by 0.4
#image.setSize( [image.origSize[0]*0.4, image.origSize[1]*0.4] )
#image.size *= scale # scale the image relative to initial size
#image.setSize( image.aspectRatio[0]*0.4, image.aspectRatio[1]*0.4 )
#image.size *=[0.4, 0.4]
I know that an aspectRatio property exists for ImageStim (link4). Being new to PsychoPy, I am not sure how to utilise this (yet). I would be most grateful for any pointers and potential solutions.