Esempio n. 1
0
def render_code():
    form = MyForm()
    if not form.validate():
        return redirect("/")
    name = gen_name_uniq(5)
    path = os.path.join(UPLOAD_DIR, name + ".jpg")
    make_image(form.code.data,
               path,
               form.language.data,
               background=get_random_bg())
    # upload(path, name, nickname)
    return redirect("/i/" + name)
Esempio n. 2
0
def process_code(update: Update, context: CallbackContext):
    print("process_code: ", update.message.text)
    name = gen_name_uniq(5)
    path = os.path.join(UPLOAD_DIR, name + ".jpg")
    make_image(update.message.text,
               path,
               lang=None,
               background=get_random_bg())
    print("created: ", path)
    with open(path, "rb") as f:
        context.bot.send_photo(
            chat_id=update.effective_chat.id,
            photo=f,
            reply_to_message_id=update.effective_message.message_id,
            caption="http://codephoto.ru/i/" + name)
Esempio n. 3
0
def get_code(message):
	make_image(str(message.text), "upload/123123.jpg", "", background=get_random_bg())
	photo = open('upload/123123.jpg', 'rb')
	bot.send_photo(message.chat.id, photo)
	db_log(message)
Esempio n. 4
0
orig = [(0, 0), (828, 0), (828, 721), (0, 721)]

# pycharm2
# highlighter.impl.matrix = find_coeffs(
#     [(0, 0), (828, 0), (828, 721), (0, 721)],
#     [(52, 136), (708, 133), (683, 808), (46, 774)])


background: str = sys.argv[1]
translated = [
    tuple(map(int, x.split(":"))) for x in sys.argv[2:]
]

out = get_matrix_file(background)

# pycharm
matrix = find_coeffs(orig, translated)

with open(__file__) as f:
    code = f.read()
make_image(code, "3.png", background=background, matrix=matrix)

with open(out, "w") as f:
    json.dump({
        "corners_original": orig,
        "corners_translated": translated,
        "coefficients": matrix
    }, f, indent=2, ensure_ascii=False)
# translated = [(38, 140), (880, 133), (880, 915), (30, 891)]