python colab issue with wand library - python

greetings ---
hey gues , I have an a problem with google.colab when I want to run this code :
# Import Image from wand.image module
from wand.image import Image
# Read image using Image() function
with Image(filename ="/content/Hand.jpeg") as img:
# Generate noise image using spread() function
img.noise("poisson", attenuate = 0.9)
img.save(filename ="noise_hand.jpeg")
the issue is with this command :
from wand.image import Image
it keep saying :
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-c8294d82387e> in <module>()
1 # Import Image from wand.image module
----> 2 from wand.image import Image
this issue only appears in colab, I mean, for example, it works fine with Microsoft visual studio.
pls guess someone help me to fix this problem, and thanks in advance
note: I already installed and imported the wand library

Try installing ImageMagick by running these in a cell before your code.
!sudo apt install imagemagick
!pip install wand

Related

"Unused import: Image" error when trying to import a function

I downloaded Pillow using pip and am trying to import its Image package to use the rotate function that is in the Image package, but when I use
from PIL import Image
I get an
Unused import: Image
error along with a
found at PIL.Image 1
message. Does anybody know what this means or what I'm doing wrong?

Pillow can't import

I have a Problem with the Pillow module.
So basically i tried the methods on this website installing it per pip install Pillow and also importing it per from PIL import Image and import PIL none of them worked
I would really appreciate it if someone helped
and thanks for reading. This is my code:
import pyautogui
import pyscreeze
from PIL import Image
lkchat = pyautogui.locateCenterOnScreen("python.png")
print ("lkchat")
I'm getting the following error message:
from PIL import Image
ImportError: No module named PIL
Kitty Star i would like to suggest you that replace PIL with pillow and then install pillow if your code does not run let me know the next error.

Trying to plot an image in python (using scipy and numpy)

I'm trying to run this code:
http://forumbilder.se/H8CIL/skarmavbild-2018-10-08-kl-21-22-19
so I change it to this one:
and then I got this:
http://forumbilder.se/H8CIL/skarmavbild-2018-10-08-kl-21-22-47
What's wrong? I'm a newbie, and fyi, I'm only have anaconda installed to my Python 3.6.6 .
Regards,
--
and in code:
from skimage import data
photo_data = misc.imageio('./wifire/sd-3layers.jpg')
type(photo_data)
and i get this error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-9-c8186ae7b8e9> in <module>()
1 from skimage import data
2
----> 3 photo_data = misc.imageio('./wifire/sd-3layers.jpg')
4
5 type(photo_data)
AttributeError: module 'scipy.misc' has no attribute 'imageio'
So I change it to:
You have to import imageio. You might have to install the library if you don't have it yet (on your terminal):
pip install imageio
(If you don't have pip install yet, you can do on your terminal sudo easy_install pip, see here: How do I install pip on macOS or OS X?)
And then your code to use read the image with imageio:
import imageio
im = imageio.imread('./wifire/sd-3layers.jpg')
type(im)
To display your image, you can use visvis library (https://imageio.readthedocs.io/en/stable/examples.html). Then you total code would be:
import imageio
import visvis as vv
im = imageio.imread('./wifire/sd-3layers.jpg')
vv.imshow(im)

Python 3- pyautogui can't use screen shot functions

Python 3.6.4
Pillow (PIL) 5.0
OS Win 7
pyscreeze 0.1.13
I'm trying to utilize the screenshot functions with pyautogui, but encountering an issue.
import pyautogui
image = pyautogui.locateOnScreen('imagepath')
print(image)
I'm receiving the following error:
File "C:\Users\a7153\AppData\Local\Programs\Python\Python36\lib\site-packages\pyscreeze__init__.py", line 315, in _screenshot_win32
im = ImageGrab.grab()
NameError: name 'ImageGrab' is not defined
I've tried going to pyscreeze and directly importing from PIL (pillow) import ImageGrab, but with no luck. I've gone through the documentation and there doesn't seem to be anything on the issue. Does anyone have any suggestions?

Wand + ImageMagick + Anaconda: "'wand' has no attribute 'image'"

I'm having issues using these three together. I believe wand is not recognizing the ImageMagick libraries but I'm not sure.
Environment:
Python 3.5.1 :: Anaconda 4.0.0 (64-bit)
Windows 7
Set up instructions I took:
Installed ImageMagick-6.9.4-Q8 (x64) with the "C/C++ development
headers options checked. (Installed to C:\Program
Files\ImageMagick-6.9.4-Q8)
Set MAGICK_HOME envar C:\Program Files\ImageMagick-6.9.4-Q8
Installed wand from pip
My code:
import wand
...
with wand.image.Image(filename=source_file, resolution=(RESOLUTION, RESOLUTION)) as img:
...
Traceback:
Traceback (most recent call last):
File ".\pdf_convert.py", line 31, in <module>
ret = pdf2jpg(f, target_file, 2480)
File ".\pdf_convert.py", line 10, in pdf2jpg
with wand.image.Image(filename=source_file, resolution=(RESOLUTION, RESOLUTION)) as img:
AttributeError: module 'wand' has no attribute 'image'
From everything I've seen I've followed the right setup instructions. I am using the 64 bit version of ImageMagick with the 64 bit version of Anaconda. This was working with me before until I started using Anaconda (before I was using regular 32 bit Python and 32 bit ImageMagick.)
Is there something I'm missing? Why is wand not working correctly?
Try this
from wand.image import Image
with Image(filename=source_file, resolution=(RESOLUTION, RESOLUTION)) as img:
pass
Is there something I'm missing? Why is wand not working correctly?
I believe it is working as expected, and the original architect did not intend to allow top-package-level shortcuts (i.e. import wand). This kinda makes sense as wand integrates to IM with ctypes, and does not attempt to resolve libraries during setup.py.
You can modify the package to include the module shortcuts your expecting by adding the following.
# wand/__init__.py
import api
import color
import compat
import display
import drawing
import exceptions
import font
import image
import resource
import sequence
import version
But I wouldn't recommend this. The from package.module import Class is a lot more cleaner.
If you are using PIL.Image as well then use:
from wand.image import Image as wand_image_Image
import PIL

Categories

Resources