Subversion Repositories SmartDukaan

Rev

Rev 19449 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19449 Rev 19740
Line 7... Line 7...
7
    sys.exit(1)
7
    sys.exit(1)
8
 
8
 
9
default_image = "./default.jpg"
9
default_image = "./default.jpg"
10
dirs = os.listdir("./")
10
dirs = os.listdir("./")
11
for dir in dirs:
11
for dir in dirs:
-
 
12
    try:
12
    if os.path.isdir(os.path.join("./", dir)):
13
        if os.path.isdir(os.path.join("./", dir)):
13
        infile = dir + "/" + sys.argv[1]
14
            infile = dir + "/" + sys.argv[1]
14
        if not os.path.isfile(infile):
15
            if not os.path.isfile(infile):
15
            print "file is missing\n"
16
                print "file is missing\n"
16
            shutil.copy2(default_image, infile)
17
                shutil.copy2(default_image, infile)
17
        if os.stat(infile).st_size==0:
18
            if os.stat(infile).st_size==0:
18
            print "file is of 0 size\n"
19
                print "file is of 0 size\n"
19
            continue
20
                continue
20
            #shutil.copy2(default_image, infile)
21
                #shutil.copy2(default_image, infile)
21
        outfile = dir + "/" + sys.argv[2]
22
            outfile = dir + "/" + sys.argv[2]
22
        if not (os.path.isfile(outfile) and os.path.getmtime(outfile) > os.path.getmtime(infile)):
23
            if not (os.path.isfile(outfile) and os.path.getmtime(outfile) > os.path.getmtime(infile)):
23
            sys.stderr.write(infile)
24
                sys.stderr.write(infile)
24
            width = int(sys.argv[3])
25
                width = int(sys.argv[3])
25
            height = int(sys.argv[4])
26
                height = int(sys.argv[4])
26
            size = width, height
27
                size = width, height
27
            im = Image.open(infile)
28
                im = Image.open(infile)
28
            im.thumbnail(size, Image.ANTIALIAS)
29
                im.thumbnail(size, Image.ANTIALIAS)
29
            im.save(outfile, "JPEG")
30
                im.save(outfile, "JPEG")
-
 
31
    except:
-
 
32
        print "moving on"
30
33