Sep-12-2022, 09:17 AM
I had this problem before, but when I moved to a virtual environment, it went away.
Now, I can't do img.show() in either of my VENVs nor outside of VENV.
Anyone know what's wrong?
I have a little home-made OMR programme, the multichoice answer forms are made as PDFs. When I mark them, I scan the answer sheets to PDF, then split the PDF to .jpgs.
Each jpg needs to be cropped to just the size of a column of multichoice answers.
To do that, when I make the answers forms, I take 1 page of the PDF and crop it to get the crop coordinates.
Of course, I need to look and check that the crop coodinates are OK for any particular page.
Now, im.show() won't work anywhere and I don't know why!
Any tips please? Previously, this worked fine, now im.show() can't display!
Now, I can't do img.show() in either of my VENVs nor outside of VENV.
Anyone know what's wrong?
I have a little home-made OMR programme, the multichoice answer forms are made as PDFs. When I mark them, I scan the answer sheets to PDF, then split the PDF to .jpgs.
Each jpg needs to be cropped to just the size of a column of multichoice answers.
To do that, when I make the answers forms, I take 1 page of the PDF and crop it to get the crop coordinates.
Of course, I need to look and check that the crop coodinates are OK for any particular page.
Now, im.show() won't work anywhere and I don't know why!
Any tips please? Previously, this worked fine, now im.show() can't display!
from PIL import Image, ImageOps image = '/home/pedro/winter2022/OMR/21BE/pdfs/21BE1_wWeek3_Answer_Forms1.jpg' def cropImage(image): print('\n running cropImage() ... \n') print('\n you need crop coordinates for each column \n') # Opens an image in RGB mode im = Image.open(image) im.show() # Size of the image in pixels (size of orginal image) # Just for information width, height = im.size print('This image is: ', width, ' wide and ', height, ' high') accept = ['yes'] answer = 'X' while not answer in accept: print('enter the crop image top left and bottom right coordinates.') print('get rid of the question numbers too, don\'t need them') print('try something like 100 290 600 2250 for the first column') print('try something like 650 290 1400 2250 for the second column') print('this is for a second column with A to I answers ... ') corners = input('Enter your 4 numbers, separated by a space ... ') # later should be able to use fixed values for the y coordinate because it won't change # work on that!! coords = corners.split() for i in range(len(coords)): coords[i] = int(coords[i]) # Cropped image of above dimension # (It will not change orginal image) im1 = im.crop((coords[0], coords[1], coords[2], coords[3])) # Shows the image in image viewer im1.show() print('Do you accept this image') answer = input('Enter yes to accept, anything else to try again ') if answer == 'yes': print('image crop coordinates saved to tup ... ') return (coords[0], coords[1], coords[2], coords[3])