4

When I try to execute the program below:

import image
img = image.Image("LutherBellPic.jpg")

print(img.getWidth())
print(img.getHeight())

p = img.getPixel(45, 55)
print(p.getRed(), p.getGreen(), p.getBlue())

I keep receiving the following error:

AttributeError: module 'image' has no attribute 'Image'
Andreas Violaris
  • 2,465
  • 5
  • 13
  • 26
  • What `image` module are you using? – martineau Jun 04 '22 at 17:54
  • Nested Iteration: Image Processing The RGB Color Model – Avishek Chatterjee Jun 04 '22 at 18:13
  • Never heard of it. Regardless, check the its documentation for find examples of using it — because from the information provided, it looks like you're merely not using it correctly. – martineau Jun 04 '22 at 18:16
  • https://fopp.umsi.education/books/published/fopp/Iteration/NestedIterationImageProcessing.html – Avishek Chatterjee Jun 04 '22 at 18:20
  • You could `print(image.__file__)` to see if its the right module. And `help(image)` to see what functions / classes are available. – tdelaney Jun 04 '22 at 18:59
  • 1
    @tdelaney coincidentally, the image package has an "Image" class as well. So, that was probably why he got confused. Avishek Chatterjee welcome to stackoverflow, if the answer you received solved your issue, you can mark it as "correct" by clicking on the check mark beside the answer, to toggle it from greyed out to filled in. – Andreas Violaris Jun 04 '22 at 20:34

1 Answers1

13

Instead of the cImage package, you installed the image package.

Hence, you have to uninstall the wrong package, using this command:

pip uninstall image

and install the correct one, using this command:

pip install cImage

Details on each package may be found in the Python Package Index repository.

Ιn brief:

image package: image processing library for the Python-based web framework Django.

cImage package: image processing library for Python.

Andreas Violaris
  • 2,465
  • 5
  • 13
  • 26