Category : image

I’d like to know if I did something wrong in my code or if I have to update something cause every single time I try to resize an image I have this: Attribute Error ‘PhotoImage’ object has no attribute ‘resize’. import tkinter as tk from PIL import Image, ImageTk image1 = Image.open("enseigne.JPEG") image1= ImageTk.PhotoImage(image1) imageresize ..

Read more

I am using the following python code from GitHub for edge detection in real time: import cv2 import numpy as np cap = cv2.VideoCapture(1) while 1: ret, frame = cap.read() hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) lower_red = np.array([5,50,50]) upper_red = np.array([15,255,255]) mask = cv2.inRange(hsv, lower_red, upper_red) res = cv2.bitwise_and(frame,frame, mask= mask) cv2.imshow(‘Original’,frame) edges = cv2.Canny(frame,100,200) cv2.imshow(‘Edges’,edges) ..

Read more

so basically i am trying to convert PIL Image object to File object so django can process it, this is what i have tried so far in views.py: if request.method == ‘POST’: title = request.POST.get(‘title’,”) fil = request.FILES.get(‘fil’) img=Image.open(fil) img = img.resize((500,500)) img_bytes=io.BytesIO() img.save(img_bytes, format=’PNG’) img = io.TextIOWrapper(img_bytes) pt = Pt.objects.create(title=title,fil=img) basically this will return ..

Read more

I have base64 string and I try to encode it and then save it in a folder. So far I have been doing this data = {"status":"Trial"} if request.method == ‘POST’: decoded = request.body.decode("UTF-8") userdata = json.loads(decoded) image = base64.b64decode(str(userdata)) print(type(image)) save_path = "Dummy/test" if not os.path.exists(save_path): pathlib.Path(save_path).mkdir(parents=True, exist_ok=True) img_save_path = "%s/%s%s" % (save_path, str(uuid.uuid4()), ..

Read more