Exemplo n.º 1
0
def api_send_file():
    path = request.args.get("path")
    if not fs.exists(path):
        return send_file(ALARMICON)
    filename = fs.getFileName(path)
    return send_file(path, as_attachment=True, attachment_filename=filename)
Exemplo n.º 2
0
else:
    folder = Common.args(0)
    if Common.count_args() >= 2:
        SIZE = int(Common.args(1))
    if Common.count_args() >= 3:
        SAVEPATH = Common.args(2)

# 指定されたフォルダ内の画像ファイル一覧を得る。
files = fs.listFiles(folder)

a = Common.readline(
    f"{len(files)} 個のファイルを {SIZE} x {SIZE} 以内に縮小して {SAVEPATH} に保存します。(y/n)")
if a != 'y':
    Common.stop(9, "処理を中断しました。")

if not fs.exists(SAVEPATH):
    fs.mkdir(SAVEPATH)

i = 0
for f in files:
    #fn = f.decode()
    fn = f
    ext = fs.getExtension(fn)
    if (ext == ".jpg" or ext == ".png"):
        #print(fn)
        im = Image.open(fn)
        #print(im.format, im.size, im.mode)
        im = im.convert('RGB')
        newsize = getImageSize(im)
        if im.size[0] > newsize[0] or im.size[1] > newsize[1]:
            newim = im.resize(newsize, Image.LANCZOS)
Exemplo n.º 3
0
    print("1: HTML5 のシンプルなページ")
    print("2: HTML5 のシンプルなページ + jQuery + Highlight.js")
    print("3: Bootstrap4 のページ")
    print("4: Bootstrap4 のページ + Highlight.js ")
    print("5: Vue.js のページ")
    pagen = int(Common.readline("番号入力 > "))
else:
    pagen = int(Common.args(1))

if pagen < 1 or pagen > 4:
    Common.stop(9, "番号が不正です。")

# "~" をホームディレクトリに変換する。
filePath = fs.tilder(filePath)

if fs.exists(filePath):
    Common.stop(1, filePath + " はすでに存在します。")

with open(filePath, "w", encoding="utf-8") as f:
    if pagen == 1:
        f.write(HTML_Simple)
    elif pagen == 2:
        f.write(HTML_Highlight)
    elif pagen == 3:
        f.write(HTML_Bootstrap4)
    elif pagen == 4:
        f.write(HTML_Bootstrap4H)
    else:
        f.write(HTML_Vue)

print("HTML ファイルが作成されました。")
Exemplo n.º 4
0
if Common.count_args() == 2:
    tableName = "Pictures"
else:
    if Common.args(2) == "V":
        tableName = "Videos"
    elif Common.args(2) == 'P':
        tableName = "Pictures"
    elif Common.args(2) == 'A':
        tableName = "Album"
    elif Common.args(2) == 'M':
        tableName = "Music"
    else:
        tableName = "Pictures"

print("> InsBINDATA3.py " + filePath + ", " + pid + ", " + tableName)
if not fs.exists(filePath):
    Common.stop(9, "画像ファイルが見つかりません。")

# MySQL クライアントを構築
mysql_client = MySQL.MySQL()

# サムネール画像を作成する。
newPath = saveThumb(filePath)

# サムネール画像を BINDATA テーブルに挿入する。
bid = insertBinaries(newPath, filePath)

# Pictures テーブルを更新する。
updateTable(tableName, bid, pid)

# 終わり
Exemplo n.º 5
0
def get_image_info(path):
    if not fs.exists(path):
        return path + " does not exists."
    im = Image.open(path)
    res = "format:{0} size:{1} mode:{2}".format(im.format, im.size, im.mode)
    return res