a script i want... - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: a script i want... (/thread-25800.html) |
a script i want... - Skaperen - Apr-12-2020 a script i want to make real quick because i want to use it. what want is something that will display a picture, given a file that has a (huge ... 8000+) list of image files, and prompt me for input and record that input with the file path to another file. as soon as it gets the input it takes down the image it is for. then it records the info. then it moves on to the next picture in the next file path in the list, displaying that picture and prompting for its input. i have thousands of old family pictures to go through. i expect this will take many hours. but, i am at home all the time so this is feasible. RE: a script i want... - michael1789 - Apr-12-2020 Because it's what I know, I'd use pygame to handle the images, and this module lets you type input. for image_file in list_of_images: image = pg.image.load(image_file).convert() while typing: display_screen.blit(image, (x_position, y_position)) txt_input_module.update() #set typing to "False" when finished typing input. RE: a script i want... - Skaperen - Apr-13-2020 pip search didn't find "display_screen". where does that come from? what is the "typing" variable? just a pseudo-object in abstraction code? my original idea was to launch a command as a background process, tracking its process ID, then signal it to quit when the terminal input comes in. how would your way do this? i haven't written any code, yet. i'm hoping to do this next weekend. RE: a script i want... - michael1789 - Apr-13-2020 The code there was just an example. display_screen would be whatever you name your window. eg display_screen = pg.display.set_mode((800, 600)) would open a 800 pixel by 600 pixel window.For images you'll have to have a pygame window. I don't know what you mean background process or process id. I was just thinking you wanted to have python show an image, you type in some information and then it goes to the next. RE: a script i want... - snippsat - Apr-13-2020 (Apr-12-2020, 05:38 AM)Skaperen Wrote: a script i want to make real quick because i want to use it. what want is something that will display a pictureThen why not try to put something together yourself Pillow is a natural first tough when want to display images in Python. (Apr-12-2020, 05:38 AM)Skaperen Wrote: prompt me for input and record that input with the file path to another file. as soon as it gets the input it takes down the image it is for. then it records the info. then it moves on to the next picture in the next file path in the listDo you want to also move file(with eg new filename from input) after it has show eg im.show() Pillow,or just write some info about image with also file path info concatenate to it?
RE: a script i want... - snippsat - Apr-13-2020 Did write some code to test this,so can post that code. Use Thread to no block input() when image show and psutil to close the image process.im.show() will open with default image program that image format is associated when open image in OS. I do this in Windows,so i need close irfanview process. Let Pillow decide image format then just pass out if not a image format.from PIL import Image, UnidentifiedImageError import os from threading import Thread import psutil import subprocess img_path = 'G:/div_code/images' new_path = 'G:/div_code/images_new/' for img in os.scandir(img_path): #print(img.name) try: im = Image.open(img.name) t1 = Thread(target=im.show,) t1.start() with open('image_info.txt', 'a') as f: image_input = input('Info about image: ') f.write(f'{image_input}: {img_path}{img.name}\n') for pid in psutil.process_iter(): if pid.name() == 'i_view32.exe': subprocess.call(f"TASKKILL /F /IM {pid.name()}") except UnidentifiedImageError: pass
RE: a script i want... - Skaperen - Apr-14-2020 (Apr-13-2020, 02:37 PM)snippsat Wrote:for some things, i like to survey other ideas, first(Apr-12-2020, 05:38 AM)Skaperen Wrote: a script i want to make real quick because i want to use it. what want is something that will display a pictureThen why not try to put something together yourself (Apr-13-2020, 02:37 PM)snippsat Wrote:(Apr-12-2020, 05:38 AM)Skaperen Wrote: prompt me for input and record that input with the file path to another file. as soon as it gets the input it takes down the image it is for. then it records the info. then it moves on to the next picture in the next file path in the listDo you want to also move file(with eg new filename from input) after it has show eg i might move the file. but i think it would be better to make some hard links or soft links, instead. i might just append it all |