victordomingos / optimize-images

A command-line interface (CLI) utility written in pure Python to help you reduce the file size of images.
https://no-title.victordomingos.com/projects/optimize-images
MIT License
272 stars 49 forks source link

Claims Pillow isn't installed while it is? #31

Closed RemBrandNL closed 3 years ago

RemBrandNL commented 3 years ago

Describe the bug Installed this on an updated RaspiOS install on RPI Zero. Running the app tells me to install Pillow even though it's installed?

To Reproduce Steps to reproduce the behavior:

  1. install on rpi zero with raspiOS lite
  2. run command
  3. get error

Expected behavior I expect to optimize the JPEGs in the given directory.

Screenshots

pi@camerapi:~/images/ledsON $ optimize-images -nr ./

    This application requires Pillow to be installed. Please, install it first.

pi@camerapi:~/images/ledsON $ pip3 install pillow
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pillow in /home/pi/.local/lib/python3.7/site-packages (8.1.0)

pi@camerapi:~/images/ledsON $ optimize-images -nr ./

    This application requires Pillow to be installed. Please, install it first.

Desktop (please complete the following information):

Additional context Add any other context about the problem here. If issue happens with a specific image file, if possible please attach a sample file (please make sure you don't upload any confidential image or information).

victordomingos commented 3 years ago

Hi. It seems that Optimize Images was not able to import Pillow. Are you sure Optimize Images was installed using the same Python version (or virtual environment if it's the case) as Pillow? Please check with the command:

python3.7 -m pip list

Also, please specify it you installed Optimize Images 1.4.0 from PyPI (using pip) or if you have downloaded and installed the current development snapshot from this Github repo.

RemBrandNL commented 3 years ago

Hi Victor, Thank you for the quick reply. I installed it using pip3 install pillow as in above snapshot. As you requested, I ran pip list with python3.7 -m pip list which returned:

pi@camerapi:~ $ python3.7 -m pip list
Package              Version  
-------------------- ---------
Adafruit-DHT         1.4.0    
asn1crypto           0.24.0   
bcrypt               3.2.0    
certifi              2018.8.24
cffi                 1.14.5   
chardet              3.0.4    
click                7.1.2    
cryptography         2.6.1    
entrypoints          0.3      
idna                 2.6      
keyring              17.1.1   
keyrings.alt         3.1.1    
optimize-images      1.4.0    
paramiko             2.7.2    
picamera             1.13     
piexif               1.1.3    
Pillow               8.1.0    
pip                  18.1     
pycparser            2.20     
pycrypto             2.6.1    
PyGObject            3.30.4   
PyNaCl               1.4.0    
pysftp               0.2.9    
python-apt           1.8.4.3  
pyxdg                0.25     
requests             2.21.0   
RPi.GPIO             0.7.0    
SecretStorage        2.3.1    
sensirion-i2c-driver 1.0.0    
sensirion-i2c-sht    0.2.1    
setuptools           40.8.0   
six                  1.12.0   
speedtest-cli        2.1.2    
ssh-import-id        5.7      
urllib3              1.24.1   
wheel                0.32.3   

Looks like indeed version 1.4.0 is installed and Pillow v8.1.0. Kind regards, Remco

RemBrandNL commented 3 years ago

I found an alternate solution to my issue with below function:

from PIL import Image

def compress_image(file=False):
    if file:
        img = Image.open(file)
        img.save(file, optimize=True, quality=60)

This gives me the simple compression I was looking for. Thanks for your time, but not need to chase this. All the best, Remco

victordomingos commented 3 years ago

Thanks for you report. I will try to review the error message and the usage of Pillow, thought, since the same issue could be happening to other users.

victordomingos commented 3 years ago

Sorry for getting back to a closed issue. Just a quick notice to let you know that I have found a similar behaviour on my Mac, right after pip installing Optimize Images. It would not find Pillow. However, after exiting the shell and opening it again, it worked as expected.