| Reference | Downloads | Github

Borders on some images

My entire experiment runs smoothly, but some (but not all) images are displaying with partial borders/edges on some of the sides. This is happening with both .jpeg and .png images. The borders are not visible for all images, and the problematic ones have the same format and settings as the images that display as they should. This has only been an issue on Mac desktop computers (Mac laptop, and Windows laptops are displaying images as they should), but I need to run the experiment on Mac desktops when testing. I was wondering if any one had encountered a similar issue, and would be able to help me? Please see attached images.

I have tried opening the images on photoshop and saving them on a white background, but the issue remained. I also tried looking for differences between images that were displaying with and without borders, and checked for things like whether there was an alpha channel on any of them, but these were not the issue. I’d really appreciate if someone took the time to assist, or suggest any ways to fix this.

Thank you!

Hi @saba1, which version of PsychoPy are you using ?

Hi @dvbridges, I’m using PsychoPy v3.2.4.

Thanks @saba1, this was an issue that was mostly fixed, but Jon will look into why the border is being presented. In the mean time, try setting your image component to use “nearest” (neighbour) interpolation (see image component “advanced” tab). This may make your image look slightly jagged, but may fix the border issue.

It would be very useful for bug fixing if you could provide details of your two macs that do and do not produce the issue e.g., OS versions, graphics card and drivers, screen types, and anything else you want to add.

1 Like

Hi @dvbridges,

Thanks for your response. I have set the image components to “nearest” (neighbour) interpolation, and all the images are now displaying as they should. Thank you so much for your advice.

Please see below for the details about the computers that you asked for:

MacBook Air- on which the images displayed correctly (without borders), even when image interpolation was “linear”:

Mac OS Mojave

Version 10.14.1

MacBook Air 13 inch, early 2014

Processor 1.4 GHz Intel core i5

Memory 4 GB 1600 MHz DDR3

Start up disk Macintosh HD

Graphics Intel HD Graphics 5000 1536 MB graphics

Desktop iMac - on which the images were displaying with partial borders (until I changed the image interpolation to “nearest”)

Mac OS High Sierra

Version 10.13.6

iMac 21.5 inch, late 2013

Processor 2.7 intel core i5

Memory 8 GB 1600 MHz DDR3

Graphics intel iris Pro 1536

Thank you again for your help, I really appreciate it.

Kind regards,


1 Like

Hi, I seem to be having a related problem with my .jpg images in PsychoPy v2020.1.3. All of the images have thin black borders-- including two examples. These are images I padded to be square with the default background gray (same issue when padded w/ other colors though). Just like in the suggestion, the borders disappear on most images when settings are switched from ‘linear’ to ‘nearest’ but I’m hoping to not have this loss in image quality for all stimuli.

No borders appeared for corresponding square .png images (transparent borders), but because of the large number of pictures, the online study took a long time to load and I was hoping to use the much smaller jpg set.

Any tricks or workarounds for this? Could I edit the jpg image set somehow or use a mask? Many thanks!

(Dell Windows 10 laptop / Intel UHD Graphics / Python 3.8.2)


I had missed this thread when I created a similar one in 2020, bringing up the same issue Odd black/grey lines at outlines of image components

It was suggested to me, too, to simply turn off linear interpolation. This worked for the particular experiment I was working on when I created the above thread. Now, however, I need the interpolation to avoid making image components with photos look really jagged.

I did some more searching around and I found that this kind of thing can happen with interpolation in general (java - Why do I get black outlines/edges on a texture in libGDX? - Stack Overflow). Maybe the alpha channel shenanigans mentioned there are relevant to PsychoPy as well? I don’t really know enough about interpolation as it relates to color spaces to understand much of what’s going on.

In the meantime, I’m using a hack, through code snippets. First, I create a ‘no-fill’ rectangle component that has the same outline color as the background (white in my case).

rect_outlinehider = visual.Rect(
    pos=(0, 0),
    lineColor=[1, 1, 1],

Then, when drawing my image components (kept in a list), for each one I assign this ‘outline hider’ component the same width/height as the image component, then draw the outline hider ‘on top of’ the image.

for img in img_ls:
    rect_outlinehider.width = img.size[0]
    rect_outlinehider.height = img.size[1]
    rect_outlinehider.pos = img.pos

Note that this means you can’t rely on the Builder’s automatic stimulus drawing anymore. You might also want to tweak the line width of the outline hider component, to avoid having it hide important parts of the stimuli themselves.

This is an ugly hack and I’d much rather be without it, but it seems like the issue is tricky and might not be solved any time soon, so this works for me in the mean time.