Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No composite images #1

Open
TheKarlo95 opened this issue Oct 3, 2018 · 3 comments
Open

No composite images #1

TheKarlo95 opened this issue Oct 3, 2018 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@TheKarlo95
Copy link

There is no feature for adding images to compose with the screenshot. Also lacks other features from original i3lock-fancy.

@yvbbrjdr
Copy link
Owner

yvbbrjdr commented Oct 3, 2018

Yes. This project has just been launched so there might be lack of features. I'm considering adding these features. Now just consider it a proof of concept of fast blur and PNG encoding. I'll elaborate other things soon.

@yvbbrjdr yvbbrjdr added the enhancement New feature or request label Oct 3, 2018
@yvbbrjdr yvbbrjdr self-assigned this Oct 3, 2018
@Alveel
Copy link

Alveel commented Nov 14, 2018

I like it so far, significantly faster than using mogrify -blur.

Good work 👍

@madnight
Copy link

madnight commented Aug 21, 2019

Well you don't need C in this case because there are very fast python image processing librarys (with C extensions).

import subprocess
import os
import mss
import sys

from PIL import Image
from screeninfo import get_monitors

monitors = get_monitors()

with mss.mss() as sct:

    root_w = sum(map(lambda x: x.width, monitors))
    root_h = max(map(lambda x: x.height, monitors))

    # take screenshot
    monitor = {"top": 0, "left": 0, "width": root_w, "height": root_h}
    sct_img = sct.grab(monitor)
    img = Image.frombytes("RGB", sct_img.size, sct_img.bgra, "raw", "BGRX")

    # pixelate
    imgSmall = img.resize(
        (int(img.size[0] / 10), int(img.size[1] / 10)), resample=Image.BILINEAR
    )
    result = imgSmall.resize(img.size, Image.NEAREST)

    icon = Image.open(sys.argv[1])

    # calc lock icon position on primary display
    primary = monitors[0]
    area = (
        int(((primary.width / 2) + primary.x) - icon.size[0] / 2),
        int(((primary.height / 2) + primary.y) - icon.size[1] / 2),
    )

    # add lock icon to bg image
    result.paste(icon, area, icon)

    subprocess.run(
        [
            "i3lock",
            "--raw",
            str(result.width) + "x" + str(result.height) + ":rgb",
            "-i",
            "/dev/stdin",
        ],
        stdout=subprocess.PIPE,
        input=result.tobytes(),
    )

python lock.py "$HOME/lock.png"

This scripts executes in 0.238 sec on my T480s notebook with 3 external monitors. (prior to the i3lock call)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants