Category : image

I am using this way to pic image and store it in my database using flask : @app.route(‘/gallery/create’, methods=[‘POST’]) def create_gallery(): title = request.form[‘title’] file = request.files[‘file’] data = file.read() render_file = render_picture(data) newFile = Gallery(name=file.filename, data=data, rendered_data=render_file, title=title) db.session.add(newFile) db.session.commit() db.session.close() and it is working fine but I need to reduce image size before ..

Read more

This is the code I use to send email with attachment: import smtplib, ssl from email import encoders from email.mime.base import MIMEBase from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText message = MIMEMultipart ("alternative") message["From"] = settings_config.username message["To"] = settings_config.target_email message["Subject"] = subject message.attach (MIMEText (body, "plain")) filename = "test.png" # In same directory as ..

Read more

from keras.models import load_model print("[INFO] Saving model…") pickle.dump(model,open(‘cnn_model.pkl’, ‘wb’)) [INFO] Saving model… ————————————————————————— TypeError Traceback (most recent call last) <ipython-input-95-0812efc6ef19> in <module> 2 3 print("[INFO] Saving model…") —-> 4 pickle.dump(model,open(‘cnn_model.pkl’, ‘wb’)) TypeError: cannot pickle ‘weakref’ object Source: Python..

Read more

I made an api request with the url argument, got an image of the api’s response, how can I store this image in bytes and show it from its bytes with python? My code: @wickenz.command() async def meme123(self, ctx): payload = b’url=https://i.stack.imgur.com/D3z44.png?s=256&g=1′ headers = {f’Authorization’: ‘Bearer {token}’,’Content-Type’: ‘application/x-www-form-urlencoded’} async with aiohttp.ClientSession() as session: async with ..

Read more