File: scanborder.py

package info (click to toggle)
libpillowfight 0.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 88,872 kB
  • sloc: ansic: 3,542; python: 802; makefile: 114; sh: 16
file content (47 lines) | stat: -rwxr-xr-x 1,042 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3

import sys

import PIL.Image
import PIL.ImageDraw

import pillowfight


def find_scan_borders(img_in, img_out):
    img_in = PIL.Image.open(img_in)

    img = img_in.copy()
    # img = pillowfight.unpaper_blackfilter(img)
    # img = pillowfight.unpaper_noisefilter(img)
    # img = pillowfight.unpaper_blurfilter(img)
    # img = pillowfight.unpaper_masks(img)

    frame = pillowfight.find_scan_borders(img)

    draw = PIL.ImageDraw.Draw(img_in)
    draw.rectangle(
        ((0, 0), (frame[0], img_in.size[1])),
        fill=(0xc4, 0x00, 0xff)
    )
    draw.rectangle(
        ((0, 0), (img_in.size[0], frame[1])),
        fill=(0xc4, 0x00, 0xff)
    )
    draw.rectangle(
        ((frame[2], 0), (img_in.size[0], img_in.size[1])),
        fill=(0xc4, 0x00, 0xff)
    )
    draw.rectangle(
        ((0, frame[3]), (img_in.size[0], img_in.size[1])),
        fill=(0xc4, 0x00, 0xff)
    )
    img_in.save(img_out)


def main():
    find_scan_borders(sys.argv[1], sys.argv[2])


if __name__ == "__main__":
    main()