Some digging led me to this previously asked question:
And it seems it indeed does have something to do with display scaling. I use a three display setup with two of the displays at 100% scaling (one of which is my designated main display) - but on the third display (the laptop display) I have 125% scaling. I changed the scaling on the laptop display to 100%, and now the example script gives the correct pixel size output. Changing it back, however, the output still stay the same (150 x 100 px). I have tried playing around with the scaling afterwards, but I have not gotten the incorrect scaling to return.