Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Displaying Images with Transparency

I am trying to create an experiment where two images are superimposed on top of each other and the participant needs to indicate which one they can see more clearly. Does OpenSesame have the capability to display two images on one sketchpad with 50% transparency and have both of them visible? This would save a lot of time creating every combination pre-superimposed.


Thanks for any help!

Comments

  • Hi @joelsolo99 ,

    Yes, that's possible. If the transparency is already in the images (i.e. there's an alpha layer), than it's just a matter of showing the images on a sketchpad .

    If you want to vary the transparency programmatically, then you can do that too, at least in Python (for the desktop). Let's say that you have an image file called einstein.png in the file pool. You can then set the transparency to 50% and save the resulting image as einstein-with-transparency.png like so:

    import os
    from PIL import Image
    
    src = pool['einstein.png']
    dst = os.path.join(pool.folder(), 'einstein-with-transparency.png')
    transparency = .5  # 0 = fully transparent
    
    im = Image.open(src)
    im.putalpha(int(255 * transparency))
    im.save(dst)
    

    Once you've done that, you can simply show einstein-with-transparency.png using a sketchpad . Do make sure that the image is created before the sketchpad is prepared!

    I'm not sure how to do this in JavaScript right now. It's probably possible, but will involve a bit of hacking.

    — Sebastiaan

Sign In or Register to comment.