pillow

Flask—04-文件上传与邮件发送(自带优化)

北城以北 提交于 2021-02-13 13:57:54
文件上传与邮件发送 可以按照标题分别直接粘贴对应的文件夹,运行直接用: 原生上传 模板文件 < form method = "post" enctype = "multipart/form-data" > < input type = "file" name = "photo" /> < br /> < input type = "submit" value = "上传" /> </ form > 视图函数 @app.route('/upload/', methods=['GET', 'POST']) def upload () : if request.method == 'POST' : # 获取上传对象 photo = request.files.get( 'photo' ) if photo: # 保存上传文件,参数是文件保存的路径名 photo.save(photo.filename) return '文件上传成功' return '文件上传失败' return render_template( 'upload.html' ) 优化完善 import os from flask import send_from_directory # 上传文件保存位置 app.config[ 'UPLOADED_FOLDER' ] = os.path.join(os.getcwd(),

Hue Tint Color error converting tiff to jpg in python3 with pillow

冷暖自知 提交于 2021-02-11 12:36:38
问题 While saving jpg thumbnails from tiff (CMYK) file I'm encountering the following problem: Thumbnail created with color mode conversion from CMYK to RGB gets blue hue: Thumbnail created from the same tiff in photoshop (no ICC profile, not converted to sRGB, RGB only) get the colors the right way: Thumbnails created without color mode conversion (jpeg with CMYK) gets similar results to the photoshopped ones but are not usable for the web (still blue). Code snippet: img = Image.open(img_tiff)

Pyautogui Screenshot Functions return AttributeError 'module' object has no attribute

北城余情 提交于 2021-02-10 05:44:05
问题 I have installed Python 3.4 and Pillow. All the other functions are working related to pyautogui only the screenshots and other image recognition things are not working. >>> import pyautogui >>> pyautogui.locateOnScreen('chrome.PNG') Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'locateOnScreen' same results show to screen capture function also. In windows 7 OS I have read the below link but non of the results worked

Taking screenshots with PIL

若如初见. 提交于 2021-02-08 09:29:28
问题 I'm working on script that take screenshot every 1 min but there is one problem that when I save it gives me invalid argument and I don't know why that is. Code: from PIL import ImageGrab from PIL import Image import time import datetime import os def screenShot(): while True: try: date = str(datetime.date.today()) hour=str(datetime.datetime.now().strftime("%H")) os.makedirs("D:/mine/" + date + "/" + hour) except OSError,e: if e.errno != 17: raise time.sleep(1) pass while True: date = str

Rotating a square in PIL

梦想与她 提交于 2021-02-07 08:32:30
问题 With PIL, I want to draw a rotated square on an image, by specifying the square side length, and the rotation angle. The square should be white, and the background grey. For example, the following image has a rotation of 45 degrees: The only way I know how to do rotations in PIL is by rotating the entire image. But if I start with the following image: And then rotate it by 45 degrees, I get this: That method just introduces black parts to fill in the "undefined" region of the image. How can I

Rotating a square in PIL

ⅰ亾dé卋堺 提交于 2021-02-07 08:31:14
问题 With PIL, I want to draw a rotated square on an image, by specifying the square side length, and the rotation angle. The square should be white, and the background grey. For example, the following image has a rotation of 45 degrees: The only way I know how to do rotations in PIL is by rotating the entire image. But if I start with the following image: And then rotate it by 45 degrees, I get this: That method just introduces black parts to fill in the "undefined" region of the image. How can I

Rotating a square in PIL

僤鯓⒐⒋嵵緔 提交于 2021-02-07 08:30:03
问题 With PIL, I want to draw a rotated square on an image, by specifying the square side length, and the rotation angle. The square should be white, and the background grey. For example, the following image has a rotation of 45 degrees: The only way I know how to do rotations in PIL is by rotating the entire image. But if I start with the following image: And then rotate it by 45 degrees, I get this: That method just introduces black parts to fill in the "undefined" region of the image. How can I

Pillow resize pixelating images - Django/Pillow

亡梦爱人 提交于 2021-02-07 07:16:24
问题 I am developing an image uploader in Django. After the image has been uploaded and saved on disk, I'm trying to resize the saved image while maintaing its aspect ratio. I am using Pillow for image processing/resizing. The problem arises when I try to resize the image, it's getting pixelated even though the resized image's aspect ratio is same as that of the original image. Original Saved Image : https://www.dropbox.com/s/80yk6tnwt3xnoun/babu_980604.jpeg Resized Pixelated Image: https://www

Extract tiles from tiled TIFF and store in numpy array

无人久伴 提交于 2021-01-29 02:09:16
问题 My overall goal is to crop several regions from an input mirax (.mrxs) slide image to JPEG output files. Here is what one of these images looks like: Note that the darker grey area is part of the image, and the regions I ultimately wish to extract in JPEG format are the 3 black square regions. Now, for the specifics: I'm able to extract the color channels from the mirax image into 3 separate TIFF files using vips on the command line: vips extract_band INPUT.mrxs OUTPUT.tiff[tile,compression

Extract tiles from tiled TIFF and store in numpy array

走远了吗. 提交于 2021-01-29 02:05:40
问题 My overall goal is to crop several regions from an input mirax (.mrxs) slide image to JPEG output files. Here is what one of these images looks like: Note that the darker grey area is part of the image, and the regions I ultimately wish to extract in JPEG format are the 3 black square regions. Now, for the specifics: I'm able to extract the color channels from the mirax image into 3 separate TIFF files using vips on the command line: vips extract_band INPUT.mrxs OUTPUT.tiff[tile,compression