Skip to content

Instantly share code, notes, and snippets.

@milkersarac
Created August 20, 2013 10:34
Show Gist options
  • Save milkersarac/6279851 to your computer and use it in GitHub Desktop.
Save milkersarac/6279851 to your computer and use it in GitHub Desktop.
This script reads images and shows to the user one by one.
#1.This script reads images and shows to the user one by one.
#2.The images must be stored in a directory named "Images"
#3.User chooses the desired images by pressing "enter", if the image is not desired
# user should press "." first then hit "enter". If no action is desired simply
# press any other key then enter.
#4.The result images will be coppied under 2 directories created by the script.
#
#For the best performance the terminal should be arranged to "Always on Top" mode. By right
#clicking to the upper frame of the terminal.
#
#@milkers
#13.08.2013 v1.0
import Image
import shutil
import glob, os
import subprocess
#shutil.copy2("merkel.jpg", "im/")
#im = Image.open("merkel.jpg")
#im.show()
try:
os.mkdir("selectedImages/")
os.mkdir("ignoredImages/")
except Exception, e:
print "Please handle the files from previous session"
exit()
for infile in glob.glob("Images/*"):
#im = Image.open(infile)
#im.show()
#p = subprocess.call(['firefox', infile])
p = subprocess.Popen(["display", infile])
var = raw_input("Enter label: ")
if var == "":
shutil.copy2(infile, "selectedImages/")
p.kill()
print "image copied"
elif var == ".":
shutil.copy2(infile, "ignoredImages/")
p.kill()
print "image skipped"
else:
p.kill()
print "image skipped"
print "END"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment