示例#1
0
def make_screenshot(pedalboard, start_time, end_time, n=0):
    width=pedalboard.get('width', 1920)
    height=pedalboard.get('height', 1080)

    # FIXME
    open(join(PEDALBOARD__DIR, 'tmp'), 'w').write(json.dumps(pedalboard))
    path = 'shot.png'
    proc = subprocess.Popen([ PHANTOM_BINARY,
                              SCREENSHOT_JS,
                              'http://localhost:8888/pedalboard.html?uid=tmp',
                              path,
                              '%d' % width, '%d' % height
                              ])
    proc.wait()

    img = Image.open(path)
    resize_image(img, width, height)

    count = int((end_time - start_time ) * fps)
    template = 'frame_%d.png'
    img.save(template % n)
    for i in range(n+1, n+count):
        os.link(template % n, template % i)

    return n + count
示例#2
0
def make_screenshot(pedalboard, start_time, end_time, n=0):
    width = pedalboard.get('width', 1920)
    height = pedalboard.get('height', 1080)

    # FIXME
    open(join(PEDALBOARD__DIR, 'tmp'), 'w').write(json.dumps(pedalboard))
    path = 'shot.png'
    proc = subprocess.Popen([
        PHANTOM_BINARY, SCREENSHOT_JS,
        'http://localhost:8888/pedalboard.html?uid=tmp', path,
        '%d' % width,
        '%d' % height
    ])
    proc.wait()

    img = Image.open(path)
    resize_image(img, width, height)

    count = int((end_time - start_time) * fps)
    template = 'frame_%d.png'
    img.save(template % n)
    for i in range(n + 1, n + count):
        os.link(template % n, template % i)

    return n + count
示例#3
0
文件: webserver.py 项目: EQ4/mod-ui
    def get(self, pedalboard_id):
        img = yield gen.Task(generate_screenshot, pedalboard_id,
                             MAX_SCREENSHOT_WIDTH, MAX_SCREENSHOT_HEIGHT)
        output = StringIO.StringIO()
        img.save(output, format="PNG")
        screenshot_data = output.getvalue()

        resize_image(img, MAX_THUMB_WIDTH, MAX_THUMB_HEIGHT)
        output = StringIO.StringIO()
        img.save(output, format="PNG")
        thumbnail_data = output.getvalue()

        result = {
            'screenshot': b64encode(screenshot_data),
            'thumbnail': b64encode(thumbnail_data),
        }

        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps(result))
        self.finish()
示例#4
0
    def get(self, pedalboard_id):
        img = yield gen.Task(generate_screenshot, pedalboard_id,
                             MAX_SCREENSHOT_WIDTH, MAX_SCREENSHOT_HEIGHT)
        output = StringIO.StringIO()
        img.save(output, format="PNG")
        screenshot_data = output.getvalue()

        resize_image(img, MAX_THUMB_WIDTH, MAX_THUMB_HEIGHT)
        output = StringIO.StringIO()
        img.save(output, format="PNG")
        thumbnail_data = output.getvalue()

        result = {
            'screenshot': b64encode(screenshot_data),
            'thumbnail': b64encode(thumbnail_data),
        }

        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps(result))
        self.finish()