Python Forum
PIL Image im.show() no show!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PIL Image im.show() no show!
#2
You don't call you function in code you show and error message make no sense.
The code dos work,could be nicer i clean it up a bit,i would have spilt it in two function.
I did answer about virtual environment in your other post

from PIL import Image, ImageOps

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()
    width, height = im.size
    print('This image is: ', width, ' wide and ', height, ' high')
    accept = ['yes']
    answer = 'X'
    while not answer in accept:
        corners = input('Enter your 4 numbers, separated by a space ... ')
        left, top, right, bottom  = [int(i) for i in corners.split()]
        im1 = im.crop((left, top, right, bottom))
        # 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 (left, top, right, bottom)

if __name__ == '__main__':
    image = 'forest.png'
    crop_tup = cropImage(image)
    print(crop_tup)
Test,it show image have to close image to continue to user input.
G:\div_code\image_env
λ python cro1.py

 running cropImage() ...


 you need crop coordinates for each column

This image is:  800  wide and  292  high
Enter your 4 numbers, separated by a space ... 50 100 200 250
Do you accept this image
Enter yes to accept, anything else to try again yes
image crop coordinates saved to tup ...
(50, 100, 200, 250)
Reply


Messages In This Thread
PIL Image im.show() no show! - by Pedroski55 - Sep-12-2022, 09:17 AM
RE: PIL Image im.show() no show! - by snippsat - Sep-12-2022, 07:32 PM
RE: PIL Image im.show() no show! - by Pedroski55 - Sep-12-2022, 10:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Can't get no email to show Raysz 0 458 Dec-11-2024, 03:44 PM
Last Post: Raysz
  Show powershell errors in flask-wtf web form robertkwild 14 2,502 Jun-30-2024, 03:15 PM
Last Post: robertkwild
  encode/decode to show correct country letters in a CTk combobox janeik 2 1,824 Sep-02-2023, 09:46 AM
Last Post: janeik
  PDF properties doesn't show created or modified date Pedroski55 4 2,498 Jun-19-2023, 08:09 AM
Last Post: Pedroski55
  Multiple.ui windows showing at the same time when I only want to show at a time eyavuz21 4 1,920 Dec-20-2022, 05:14 AM
Last Post: deanhystad
  How to get cell(x,y).value = "\'=name(p)" to show correctly ?? ozlevia 9 7,048 Oct-31-2022, 06:47 PM
Last Post: deanhystad
  Why doesn't it show me anything in print? Melcu54 2 1,527 Oct-01-2022, 12:07 AM
Last Post: snippsat
Question Trouble installing modules/libraries and getting Notepad++ to show cyrillic letters Dragiev 6 3,797 Jul-24-2022, 12:55 PM
Last Post: Dragiev
  python basemap, cant show the right coordinates dbsr 0 1,384 Jun-08-2022, 01:55 PM
Last Post: dbsr
  Make console show after script was built with Pyinstaller --NOCONSOLE? H84Gabor 0 1,792 May-05-2022, 12:32 PM
Last Post: H84Gabor

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020