Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pillow Version #315

Open
rtaylo45 opened this issue Aug 15, 2023 · 3 comments
Open

Pillow Version #315

rtaylo45 opened this issue Aug 15, 2023 · 3 comments

Comments

@rtaylo45
Copy link

Hello,

So i recently install trdg and was running into this issue when using the text generators:

File ~/Projects/TextRecognitionDataGenerator/trdg/utils.py:148, in get_text_height(image_font, text)
    144 def get_text_height(image_font: ImageFont, text: str) -> int:
    145     """
    146     Get the width of a string when rendered with a given font
    147     """
--> 148     return image_font.getsize(text)[1]

AttributeError: 'FreeTypeFont' object has no attribute 'getsize'

Turns out that Pillow 10 got rid of this method as noted by this tensorflow post. Updating the requirements file to pillow<=9.5.0 fixes the issue.

Thanks,
Zack

@gigabitamin
Copy link

gigabitamin commented Nov 28, 2023

I had the same issue, and I also resolved it by downgrading the version. I used the following command to install the libraries specified in the requirements.txt file:

pip install -r requirements.txt

The contents of the requirements.txt file were:

pillow>=7.0.0
requests>=2.20.0
opencv-python>=4.2.0.32
tqdm>=4.23.0
diffimg==0.2.3
arabic-reshaper==2.1.3
python-bidi==0.4.2
wikipedia>=1.4.0

When I checked my installed Python libraries, the version of pillow was 10.1.0. To resolve the issue, I downgraded it using the command:

pip install pillow==9.5.0

After this, I confirmed that everything was working correctly.
During the installation, I received the following message related to the pillow library:

Requirement already satisfied: pillow>=7.0.0 in c:\anaconda3\envs\gigabitamin\lib\site-packages (from -r requirements.txt (line 1)) (10.1.0)

In my case, attempting to install via requirements.txt while pillow was already installed didn't automatically trigger the downgrade. It seems to have caused an issue because the installed version was the problematic latest version.

For situations like this, it would be helpful to have a warning in the installation message, suggesting a downgrade.

@rtaylo45
Copy link
Author

@gigabitamin It looks like they fixed the issue with this PR but its yet to be merged. I assume that this will be merged for future releases and having a warning message might not be necessary.

@stweil
Copy link
Contributor

stweil commented Feb 15, 2024

This issue is fixed in git master, so it can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants