To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/gG0hWn6BmLYJ.--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/gG0hWn6BmLYJ.
For more options, visit https://groups.google.com/groups/opt_out.
-- Jonathan Peirce Nottingham Visual Neuroscience http://www.peirce.org.uk/
imageSize = 10 # scale the image's maximum dimension to this and the other proportionally
image = visual.ImageStim(win, 'someImage.png') # image.size is e.g. [17.0245, 9.3434]
image.size *= imageSize / max(image.size) # change max to min if you want this to apply to the minimum length.
When an image is imported I think its original size will be tracked with an origSize attribute. So you can avoid loading the image twwice from disk, which you're doing right now by doing
imgStim = visual.ImageStim( mywin, imgFile, pos=(0.0,0.5 ))
imgStim.setSize( [imgStim.origSize[0]*0.4, imgStim.origSize[1]*0.4] )
And actually, as I wrote that I realised you could also use the fact that nearly all set____ methods in psychopy also support an operator that allows you to add/subtr/multiply... the current value. So you could also do
imgStim = visual.ImageStim( mywin, imgFile, pos=(0.0,0.5 ))
imgStim.setSize(0.4, '*') #multiply the current size by 0.4
Jon
On 08/03/2013 17:11, John Allen wrote:
Actually, this seems to have the desired affect:
tmp=Image.open(imgFile)
imgStim = visual.ImageStim( mywin, imgFile, pos=(0.0,0.5 ), size=(0.4 * tmp.size[0]/tmp.size[1],0.4))
where 0.4 produces the desired scaling factor for my fixed height images with varying widths.
there's probably a neater solution though.
On Friday, March 8, 2013 4:41:47 PM UTC, John Allen wrote:Hi,--
I'm using the coder view and looking at using ImageStim to display a variety of images (whatever it finds in a folder)
These images can vary in aspect ratio though they all have a fixed height.
I'd like to display these but I need to rescale them to fit.
How can I just specify just one dimension (height) and let the width vary whilst maintaining the original aspect ratio so that I don't get any abnormal stretching?
Thanks,
John
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-users+unsubscribe@googlegroups.com.
To post to this group, send email to psychopy-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/psychopy-users/-/gG0hWn6BmLYJ.
For more options, visit https://groups.google.com/groups/opt_out.