Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Failed to save the screenshot and the Image damage

Open SLL0711 opened this issue 3 years ago • 5 comments

What did you do?

I want to save my desktop screenshot for the image comparison

What did you expect to happen?

I wonder if there's something I should do

What actually happened?

the Image damage!

Uploading screen 3.png…

  • OS: macOS mojave 10.14.5
  • Python: 3.9.2
  • Pillow: 9.0.0
def matchImg():
    imgSource = '/Users/shenlilin/Desktop/graphicRecognize/picture/screen.png'
    # imgSource = '/Users/panchen/Desktop/git/auto_testing_wireless/graphicRecognize/picture/screen.png'
    img = ImageGrab.grab()
    # print('img',imgSource,img)
    # img.show()
    img.save(imgSource)
    # 基础图像
    imsrc = ac.imread(imgSource)

    for x in range(len(sys.argv)):
        if x == 0:
            continue
        imgObj = sys.argv[x]
        conf = findTemplate(imsrc, imgObj)
        print(conf, end=' ')

Uploading 1511663641533_.pic.jpg…

SLL0711 avatar Sep 20 '22 02:09 SLL0711

screen 3.png.zip

SLL0711 avatar Sep 20 '22 02:09 SLL0711

Here is the unzipped image. So it is cut off partway through. screen 3

If you just run the very simple

from PIL import ImageGrab
ImageGrab.grab().show()

does the image appear correct?

radarhere avatar Sep 20 '22 02:09 radarhere

Here is the unzipped image. So it is cut off partway through. screen 3

If you just run the very simple

from PIL import ImageGrab
ImageGrab.grab().show()

does the image appear correct?

This is an occasional problem , So i can't let this problem happen every time. But once that happens I can't go on with the next steps.

SLL0711 avatar Sep 20 '22 02:09 SLL0711

1531663642374_.pic.jpg.zip the Pillow version.

9.0.0

1531663642374_ pic

SLL0711 avatar Sep 20 '22 02:09 SLL0711

This is an occasional problem , So i can't let this problem happen every time. But once that happens I can't go on with the next steps.

How frequently does it seem to occur? Every second time? One in five times? One in ten?

It probably won't help, but could you upload a screenshot from your machine taken with Pillow that is correct, for comparison?

radarhere avatar Sep 21 '22 06:09 radarhere

If you just run the very simple

from PIL import ImageGrab
ImageGrab.grab().show()

does the image appear correct?

This is an occasional problem , So i can't let this problem happen every time. But once that happens I can't go on with the next steps.

At the end of your original post, you have some code that is unrelated to Pillow. It would be nice to confirm that the problem is still there without that extra code.


Running pngcheck over the image you've supplied, I get EOF while reading CRC value.

That makes me think that the problem is not taking the screenshot, but saving it as a PNG. Does your Python code actually finish running, or does it exit?

If you successfully save a screenshot as a PNG, and then in a second script, open up that PNG, try to save it again, does the second script ever fail to save the PNG correctly?

radarhere avatar Sep 24 '22 12:09 radarhere

Closing this issue as no feedback has been received.

github-actions[bot] avatar Oct 09 '22 00:10 github-actions[bot]