pillow

Pillow - Resizing a GIF

▼魔方 西西 提交于 2019-12-09 05:45:10
问题 I have a gif that I would like to resize with pillow so that its size decreases. The current size of the gif is 2MB. I am trying to resize it so its height / width is smaller decrease its quality. With JPEG, the following piece of code is usually enough so that large image drastically decrease in size. from PIL import Image im = Image.open("my_picture.jpg") im = im.resize((im.size[0] // 2, im.size[1] // 2), Image.ANTIALIAS) # decreases width and height of the image im.save("out.jpg", optimize

Align x-ray images: find rotation, rotate and crop

左心房为你撑大大i 提交于 2019-12-08 19:22:37
I want in the x-ray image below to (by using Python): identify the rotation of the (imperfect) rectangle block rotate the image so that it is in vertical (portrait form) remove by cropping the remaining white space I guess this partly the reverse of this question where the tools are most likely identical with the addition of a corner detector . I'm not entirely sure of how to best approach this and it seems like a problem that someone has solved. Martin Evans This can be done using the Python bindings to the OpenCV library. The following code has been adapted from something I had already, so

OS X Pillow installation error

╄→尐↘猪︶ㄣ 提交于 2019-12-08 07:52:36
问题 I followed this instructions: http://pillow.readthedocs.org/en/latest/installation.html#mac-os-x-installation $ sudo pip install Pillow returned error: clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future] clang: note: this will be a hard error (cannot be downgraded to a warning) in the future error: command 'cc' failed with exit status 1 ---------------------------------------- Cleaning up... Command /usr/bin/python -c "import setuptools,

Pillow Image can't release memory when it closes

眉间皱痕 提交于 2019-12-08 07:51:09
问题 I'm using Pillow==4.2.0 like following by Python3. I just want to release the memory after used Image. from PIL import Image f = open('http://test.com/test.jpg', 'rb') image = Image.open(f) image.load() # use a lot of memories f.close() image.close() # this doesn't release memory f = None image = None Also I tried to use gc.collect() . But it wasn't efficient. Do you have any solutions? 来源: https://stackoverflow.com/questions/44882598/pillow-image-cant-release-memory-when-it-closes

Changing colour of an image

我的未来我决定 提交于 2019-12-08 03:41:46
问题 What is the easiest way to change the colour of the whole image with a RGB value? I have tried wand , however the documentation didn't make much sense to me, and I can only find changing the intensity of the colours in the Pillow documentation. I tried multiple solutions online, however either they didn't do what I wanted, or were out of date and didn't work. I want it so that the whole image gets tinted and I can control the tint by changing the RGB colour, bit like this: http://cdn

Memory leaks when image discarded in Python

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 02:53:41
问题 I'm currently writing a simple board game in Python and I just realized that garbage collection doesn't purge the discarded bitmap data from memory when images are reloaded. It happens only when game is started or loaded or the resolution changes but it multiples the memory consumed so I can't let this problem unsolved. When images are reloaded all references are transferred to the new image data since it is binded to the same variable as the original image data was binded to. I tried to

Installing Pillow error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

浪尽此生 提交于 2019-12-07 18:53:26
问题 While i try to install Pillow 2.5.3 I am getting an error : command 'x86_64-linux-gnu-gcc' failed with exit status 1 Here is the complete log of what happened I need this library as a part of another python project. I have gone through many solutions but none helped me 回答1: You are missing Python headers. Install python-dev from your distribution's package manager. Equally for python 3. Install python3-dev , example: sudo apt-get install python3-dev 回答2: I have tried python-dev package but

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

拜拜、爱过 提交于 2019-12-07 03:26:51
问题 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

Changing colour of an image

我怕爱的太早我们不能终老 提交于 2019-12-06 16:29:24
What is the easiest way to change the colour of the whole image with a RGB value? I have tried wand , however the documentation didn't make much sense to me, and I can only find changing the intensity of the colours in the Pillow documentation. I tried multiple solutions online, however either they didn't do what I wanted, or were out of date and didn't work. I want it so that the whole image gets tinted and I can control the tint by changing the RGB colour, bit like this: http://cdn.makeuseof.com/wp-content/uploads/2012/11/Folder-Colorizer-Color-Manager.jpg?69fac7 I can implement the wheel

Memory leaks when image discarded in Python

北城余情 提交于 2019-12-06 11:04:02
I'm currently writing a simple board game in Python and I just realized that garbage collection doesn't purge the discarded bitmap data from memory when images are reloaded. It happens only when game is started or loaded or the resolution changes but it multiples the memory consumed so I can't let this problem unsolved. When images are reloaded all references are transferred to the new image data since it is binded to the same variable as the original image data was binded to. I tried to force the garbage collection by using collect() but it didn't help. I wrote a small sample to demonstrate