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为最新版 #10386

Closed
wants to merge 7 commits into from
Closed

替换Pillow为最新版 #10386

wants to merge 7 commits into from

Conversation

livingbody
Copy link
Contributor

#10344

替换Pillow为最新版

主要是更新FreeTypeFont.getsize 为 getbbox

解决多次识别pdf,受第一次页面最大数量影响的bug
## 替换Pillow为最新版
主要是更新FreeTypeFont.getsize 为 getbbox
## 替换Pillow为最新版
主要是更新FreeTypeFont.getsize 为 getbbox
## 替换Pillow为最新版
主要是更新FreeTypeFont.getsize 为 getbbox
## 替换Pillow为最新版
主要是更新FreeTypeFont.getsize 为 getbbox
@paddle-bot
Copy link

paddle-bot bot commented Jul 13, 2023

Thanks for your contribution!

This was referenced Jul 13, 2023
@shiyutang shiyutang self-assigned this Jul 14, 2023
Copy link
Collaborator

@shiyutang shiyutang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. getsize替换逻辑不太正确。
  2. 需要去除ppocr 的requirements中对于pillow版本的依赖。
  3. 同步提交PR到dygraph分支。
  4. 另外下面的两行也可以替换一下:
    ppocr/data/imaug/rec_img_aug.py L403: Image.ANTIALIAS-> Image.LANCZOS
    tools/infer/predict_rec.py L403: Image.ANTIALIAS-> Image.LANCZOS
    refer: https://pillow.readthedocs.io/en/stable/releasenotes/2.7.0.html#antialias-renamed-to-lanczos

@@ -23,7 +23,7 @@ def load_fonts(self, fonts_config):

def get_valid_height(self, font_path):
font = ImageFont.truetype(font_path, self.height - 4)
_, font_height = font.getsize(self.char_list)
_ , _ , _ , font_height = font.getbbox(self.char_list)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous:
width, height = font.getsize("Hello world")

Now:
left, top, right, bottom = font.getbbox("Hello world")
width, height = right - left, bottom - top

refer:
https://pillow.readthedocs.io/en/stable/releasenotes/9.2.0.html#font-size-and-offset-methods

@livingbody livingbody closed this by deleting the head repository Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants