pillow

Resize thumbnails django Heroku, 'backend doesn't support absolute paths'

▼魔方 西西 提交于 2019-12-05 08:16:27
I've got an app deployed on Heroku using Django, and so far it seems to be working but I'm having a problem uploading new thumbnails. I have installed Pillow to allow me to resize images when they're uploaded and save the resized thumbnail, not the original image. However, every time I upload, I get the following error: "This backend doesn't support absolute paths." When I reload the page, the new image is there, but it is not resized. I am using Amazon AWS to store the images. I'm suspecting it has something to do with my models.py. Here is my resize code: class Projects(models.Model):

PIL ImageTK not loading image in py2app application bundle

时间秒杀一切 提交于 2019-12-05 08:01:19
I'm testing out an app that I've made which, amongst other things, loads a couple of .png images when opened. The images are displayed correctly on my Mac (10.7.5) and my mother's (10.8.5); however when my sister opens it on hers (10.9.5) the images don't load. All other functionality is otherwise intact. I should note that on my Mac and my mother's, I installed Python 3.4 and many of the packages that the app uses, including the PIL package, whereas my sister has none of these. The app was build using the command: python3.4 setup.py py2app Images are imported in the code with: image = ImageTk

Getting PIL/Pillow 4.2.1 to upload properly to AWS Lambda Py3.6

故事扮演 提交于 2019-12-05 02:14:45
Background I have been struggling for the past few days to deploy a Lambda that uses Pillow, and I am deploying using Python 3.6. It may be noteworthy also that I am developing this on a Windows 10 environment. First Attempts I began by having pip install my packages strictly in my workspace by doing the following: pip3 install pillow -t "D:\Work and Projects\...\...\<projectdir>\pillow" I have other packages, and tried installing the packages in the same manor, one of them specifically was praw and I did so by: pip3 install praw -t "D:\Work and Projects\...\...\<projectdir>\praw" After

PUT request for image upload not working in django rest

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 01:55:36
I am trying to upload an image in django rest using multipart/form-data in a PUT request and Pillow: class ABC(APIView): parser_classes = (MultiPartParser,) def put(self, request): a = Image() a.image_url = request.data["image"] a.save() class Image(models.Model): image_url = models.ImageField(upload_to='static/bills', blank=True) I make a request which is a PUT request and a multipart/form-data. I end up getting a response code of 400 with the message: { "detail": "Multipart form parse error - Invalid boundary in multipart: None" } Somehow this has broken just now. It was working fine when I

saving an image to bytes and uploading to boto3 returning content-MD5 mismatch

ⅰ亾dé卋堺 提交于 2019-12-04 23:20:36
I'm trying to pull an image from s3, quantize it/manipulate it, and then store it back into s3 without saving anything to disk (entirely in-memory). I was able to do it once, but upon returning to the code and trying it again it did not work. The code is as follows: import boto3 import io from PIL import Image client = boto3.client('s3',aws_access_key_id='', aws_secret_access_key='') cur_image = client.get_object(Bucket='mybucket',Key='2016-03-19 19.15.40.jpg')['Body'].read() loaded_image = Image.open(io.BytesIO(cur_image)) quantized_image = loaded_image.quantize(colors=50) saved_quantized

Find which libjpeg is being used by PIL / PILLOW

社会主义新天地 提交于 2019-12-04 14:56:18
I am getting an error where reading the same lena.jpg file on two different computers yeilds two different checksums. Even weirder is that when I run md5sum lena.jpg I get the same md5 sum on both machines, so the files are identical. Furthermore, when I load a png instead of a jpeg the numbers seem to match up. This leads me to believe there is a disconnect between Pillow on the two different machines, or at least the library they are using to read jpeg files. Is there any way to check which version of libjpeg is being used by Pillow (from within Python preferably)? Both of the computers are

Python - Find center of object in an image

↘锁芯ラ 提交于 2019-12-04 14:01:28
问题 I have an image file that's has a white background with a non-white object. I want to find the center of the object using python (Pillow). I have found a similar question in c++ but no acceptable answer - How can I find center of object? Similar question, but with broken links in answer - What is the fastest way to find the center of an irregularly shaped polygon? (broken links in answer) I also read this page but it doesn't give me a useful recipe - https://en.wikipedia.org/wiki/Smallest

Python Pillow: Make image progressive before sending to 3rd party server

匆匆过客 提交于 2019-12-04 12:54:21
I have an image that I am uploading using Django Forms, and its available in the variable as InMemoryFile What I want to do is to make it progressive. Code to make an image a progressive img = Image.open(source) img.save(destination, "JPEG", quality=80, optimize=True, progressive=True) Forms.py my_file = pic.pic_url.file photo = uploader.upload_picture_to_album(title=title, file_obj=my_file) The issue is, I have to save the file in case I want to make it progressive, and open it again to send it to the server. (It seems a redundant actions to make it progressive) I just want to know if there

imresize in PIL/scipy.misc only works for uint8 images? any alternatives?

做~自己de王妃 提交于 2019-12-04 12:24:42
问题 It seems the imresize implemented in PIL / scipy.misc only works for uint8 images >>> import scipy.misc >>> im = np.random.rand(100,200) >>> print im.dtype float64 >>> im2 = scipy.misc.imresize(im, 0.5) >>> print im2.dtype uint8 Is there any way around this? I'd like to deal HDR images and therefore needs to deal with float64 or float32 images. Thanks. 回答1: Thanks to cgohlke's comment. Below are two alternatives I found that works for float-number images. Use scipy.ndimage.interpolation.zoom

IOError: decoder jpeg not available when using Pillow

爱⌒轻易说出口 提交于 2019-12-04 11:56:32
问题 Before someone says "sudo apt-get install libjpeg-dev" or something along those lines, I do not have sudo access. I am on a slice of a server that does NOT allow me to have sudo access. So I've gotta do this entire thing in my local directory. That's the only way I can do it. I need a python script to resize an image. It works perfectly fine for png files, but it falls apart on jpeg files with the error listed in the title. Here are the steps I've taken so far: Downloaded libjpeg-dev and