Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
peripherad
/
app
/
scripts
:
convert_image.py
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
import cv2 import pathlib import random import string import time import base64 import io import sys import os def upload_file(): # Read the image from a file im_gray = cv2.imread(sys.argv[1], cv2.IMREAD_GRAYSCALE) (thresh, im_bw) = cv2.threshold( im_gray, 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU ) thresh = 127 im_bw = cv2.threshold(im_gray, thresh, 255, cv2.THRESH_BINARY)[1] file_name = generate_random_name(12) # cv2.imwrite("/home/clickysoft/public_html/jm-trophies.clickysoft.net/public/images/converted/" + file_name, im_bw) path = "/var/www/jmt.clickysoft.app/assets/customization/converted" is_exists = os.path.exists(path) if not is_exists: os.makedirs(path) cv2.imwrite(path + "/" + file_name, im_bw) # cv2.waitKey(0) return print(file_name, end = "") def generate_random_name(length): random_str = "".join((random.choice(string.ascii_lowercase) for x in range(length))) return random_str + str(time.time()).replace(".", "") + ".jpg" upload_file()