Why is Django-Simple-Captcha image distorted? - python

Please see the related question I posted earlier: While upgrading python imaging library (PIL), it tells me "JPEG support not available"
I have installed Pillow instead of PIL to get the Django-Simple-Captcha to work. The image now displays.
But as you can see at the bottom of this page, it is so badly distorted that it is basically unreadable and useless: http://predictstat.com/accounts/register/
I have no clue why this is happening now, nor how to fix it. Can someone please advise?

The cutoff happens because I'm using Pillow 2.2.2.
Django-simple-captcha seems to not play with that version of Pillow. So I installted Pillow 2.0 and the cut-off problem was solved! See: http://github.com/mbi/django-simple-captcha/pull/50

Related

OpenCV: cv2.videoCapture successful, but isOpen fails right after

I have found some other threads but they didn't help my problem.
The lines that I'm confused about are:
print("videopath",os.path.isfile(video_path),video_path)
self.cap = cv2.VideoCapture(video_path)
print("is open?",self.cap.isOpened())
It says my file exists (the first line returns true, and prints the direct path to my .mp4), and when I put cv2.VideoCapture in a try/catch, it succeeded without an issue. However it says the video is not open and I can't pull any frames from it. I'm on Ubuntu 16.04, using OpenCV 3.3 and Python 3.5.
Any suggestions would be much appreciated, thank you.
In the end it was because I had the wheel version of OpenCV installed on top of my manual installation. DON'T use pip install opencv-python as it is not official and errors like this will occur. This was an incredible guide that made it very easy: https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/
To be clear though, I had gone through this whole process once, and then tried pip just because, and it broke it, so once you install it manually, don't touch the wheel packages!

Alternative for PIL?

I want to use one of the newest versions of Python, (3.5+), and I need to import Image. I use:
from PIL import Image
except this returns an error. I don't have the error on my right now but the important part is there is a problem with PIL (I have already determined that from my Python Discord server)
Can I use pillow? I think I have that installed. I would try it but I want to know how (and if) it's applicable. Thanks
Can I use pillow?
Sure. pillow is a successor project of PIL, as development on the latter was last continued in 2011.
The first thing mentioned in the official pillow documentation is how to import the Image class.

All cv2 functions are not found

I have pip installed opencv-python on my Ubuntu guest OS hosted in a virtual box. Both my python and Ubuntu are 64-bit. But when I import cv2 I couldn't find all the functions to manipulate images. The following is an image of the ini file I get when I do ctrl+B.
I uninstalled the opencv and followed many tutorials to install opencv using apt-get including from the official opencv website and none of them worked for me. Can someone give me a hint what I can do to get opencv to work?
Following this tutorial, I was able to finally install opencv properly. I am posting my answer to help someone in a similar situation. Ubuntu version is the most important thing you have to check before you follow any of the tutorials. Just like my case, if you happen to follow one of the old tutorials but your Ubuntu version is 16, you need to remove the opencv altogether then follow the tutorial.
After the fix, my ini looks like this. It consists all the functions to manipulate image. The screenshot shows the partial shot in my ide.

how to convert a gif image to webp in python?

how to convert a gif image to webp in python, keeping it's animation.
from PIL import Image
im = Image.open('test.gif')
im.save('test.webp', 'webp', save_all=True)
get KeyError, is there any python solution?
I just skimmed through the documentation for PIL, which says clearly that webp format is supported. It however comes with a condition. The page states Only supported if the system webp library was built with webpmux support.
In order to continue, you will have to install the latest libwebp library for your corresponding OS. It is recommended to work with it provided you have Debian/Ubuntu OS. There are plenty of resources available on the net to help you.
You may have to reinstall PIL as well
Here is a related thread I came across GITHUB thread

Python extension scikit-image error

I am trying to use scikit-image to do some research. The system is Windows 7 64bit, and the python version is 2.7, 64bit.
The first program I run is from: http://scikit-image.org/
The code is
from skimage import data, io, filter
image = data.coins() # or any NumPy array!
edges = filter.sobel(image)
io.imshow(edges)
io.show()
However, the problem happens, and the error message is:
C:\Python27\lib\site-packages\skimage\io_plugins\null_plugin.py:14:
RuntimeWarning: No plugin has been loaded. Please refer to
skimage.io.plugins()
for a list of available plugins.
warnings.warn(RuntimeWarning(message))
I believe that both Python and scikit-image are correctly installed. So, may I know what is wrong with it?
Any suggestion is appreciated. Many thanks.
Just had precisely the same issue on amazon linux. The issue is that skimage requires PIL, and PIL is not installed. In the latest skimage they added the dependency, but the version that I got installed with pip didn't have it yet.
The solution is
pip install Pillow
EDIT: and after that you will probably immediately face another issue, with skimage loading image, but not being able to read it (in particular, shape being empty tuple). Here's the solution
Why does scipy.ndimage.io.imread return PngImageFile, not an array of values

Categories

Resources