Subversion Repositories SmartDukaan

Rev

Rev 19740 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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