Comments (4)
I'm going to relabel this as an enhancement as currently loading images from a URL isn't something ImageStim is supposed to be able to do - that would be a new feature rather than a fix. Would be nice though, and very possible as both requests
and PIL
are already in PsychoPy's core requirements, so I'll add the "Good first issue" tag too.
One thing to be aware of with this is that accessing a resource from a server means your IP is exposed. This is fine if it's e.g. the Pavlovia server, but when connecting to something like amazonaws we would definitely need to have some kind of warning. There was a case in 2022 where a German court ruled that accessing the Google Fonts server without warning violated GDPR, which is why PsychoPy warns you when you try to use a Google Font in TextStim/TextBox.
from psychopy.
Just to add... PsychoPy is designed for high-performance, very low-latency operation, so adding in the delay of fetching resources from the web when they are needed should be treated very carefully considering those goals. I would strongly recommend fetching local copies of images for your studies in advance when running in the lab
from psychopy.
If you definitely need to get it from online and are okay with the loss of speed from having to query a server each time, the following code should work (using url
for the image url and img
for the ImageStim):
# get raw data from server
raw = requests.get(url, stream=True).raw
# create a PIL image from raw data
data = pil.open(raw)
# create an image stim
img.setImage(data)
(you could also use requests.get
, pil.open
and pil.save
to programmatically get and save all the images just once, so you can use the local files)
from psychopy.
from psychopy.
Related Issues (20)
- [Bug]: Extremely slow rendering of colors HOT 2
- [Bug]: Editable TextBox2 line spacing contamination HOT 2
- [Bug]: Pandas version differs across operating systems HOT 1
- [Bug]: 2024.1.1 is packaged with Python 3.8.x but will not run locally with said version HOT 2
- [Bug]: Two Counterbalance routines with the same name can be added / Conditions file is not updated in Counterbalance routine
- [Bug]:
- [Bug]: System default audio device not used in versions >= 2024
- [Bug]: `Dlg` example raises an exception HOT 2
- Is the entire `pyobjc` package collection required? HOT 1
- [Bug]: Use of pythonw on macos conda/mamba environments breaks app HOT 4
- [Bug]: Space character in column name of conditions file yields `UnboundLocalError` in Builder HOT 1
- [Bug]: Mistake in documentation for FormComponent
- [Bug]: OverflowError: line number table is too long
- [Bug]: pkg_resources is deprecated
- [Bug]: crash after launch on Ubuntu 22.04
- [Bug]: Not able to connect to my Pavlovia account when running local psychopy version HOT 4
- [Feature Request]: Using serial port without access to the port HOT 9
- [Bug]: Builder: Line drawing anchoring behavior is inconsistent with other polygons
- [Bug]: Psychopy standalone won't open HOT 2
- [Bug]: pyglet keyboard input not working on MacOS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psychopy.