-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 built with libraqm insists it has no libraqm #4859
Comments
Hi. Would you mind trying this? from PIL import ImageFont
font = ImageFont.truetype(r'C:\Windows\Fonts\Arial.ttf', 120, layout_engine=ImageFont.LAYOUT_RAQM)
size = font.getsize("hello world", 'rtl') |
"Pillow built with Raqm" doesn't actually mean anything in the current version; Raqm is only linked at runtime. Raqm support can be loaded if Pillow is compiled with FreeType and In other words, to load Raqm you need to have |
@nulano Placing it in Thanks :) Is there a way to statically link libraqm to avoid the dll issue? |
Not currently, but it shouldn't be too difficult to make a patch. First you have to add p_raqm.version_string = (t_raqm_version_string)GetProcAddress(p_raqm.raqm, "raqm_version_string"); with p_raqm.version_string = raqm_version_string; and finally add raqm to features = [
"zlib",
"jpeg",
"tiff",
"freetype",
"lcms",
"webp",
"webpmux",
"jpeg2000",
"imagequant",
"xcb",
+ "raqm",
]
# -----
if feature.want("xcb"):
_dbg("Looking for xcb")
if _find_include_file(self, "xcb/xcb.h"):
if _find_library_file(self, "xcb"):
feature.xcb = "xcb"
+ if feature.want("raqm"):
+ _dbg("Looking for raqm")
+ if _find_include_file(self, "raqm.h"):
+ if _find_library_file(self, "libraqm"):
+ feature.raqm = "libraqm"
# -----
if feature.xcb:
libs.append(feature.xcb)
defs.append(("HAVE_XCB", None))
+ if feature.raqm:
+ libs.append(feature.raqm)
+ defs.append(("HAVE_RAQM", None))
if sys.platform == "win32": The reason this is not currently supported is that Raqm depends on FriBiDi which has an LGPL license. The current runtime linking mechanism allows Pillow to avoid any licensing issues, while linking statically could add LGPL requirements to using Pillow. |
Is there anything left to do for this issue @newfeatureengineer ? It looks like it's been resolved to me. |
Where can I find the _imagingft.c please ? edit: typo |
The changes from my comment above are now the default for source builds on Linux since Pillow 8.2.0. To enable Raqm for binary wheels, it is sufficient to install FriBiDi on Linux (Raqm is linked statically but runtime loading is used for its dependency FriBiDi in wheels). For Windows wheels (source builds are not recommended) you should be able to enable Raqm by installing |
I have used it on Linux without any problems. Sadly the problem still exists on Windows and I'm not the only one. |
@radarhere Should I make a new Issue or this one can be changed from Closed to Open ? |
Actually, that's a typo. When trying to load Raqm's dependency FriBiDi, Pillow will attempt to open |
I went out and tried this on Manjaro Linux with Wine set as Windows 10 and Windows 8.1. Still no luck getting it to work. |
The Python 3.7 Pillow 8.3.0 release wheel doesn't detect Raqm/FriBiDi for me either, but the CI test run wheel does (from https://github.com/python-pillow/Pillow/actions/runs/988696864). |
@h4xw4r here is one of the wheels linked to from the previous comment. Installing this might solve your immediate problem - Pillow-8.3.0-cp37-cp37m-win_amd64.whl.zip @nulano does the 8.2.0 release wheel work? Is this possibly just the same problem as #5573? |
Same issue with 8.2.0 also. I've tried a week ago and had to use WSL after trying every other option. The wheel from @nulano's link worked finally. |
8.2.0 had the same issue when I tested it right after the release. The problem and fix is #5413 (comment) |
It doesn't seem to work for me |
That wheel is for Python 3.7 64-bit, you are probably running a different version of Python. I have checked the 8.3.1 wheel from cgohlke's website also works with Raqm/FriBiDi properly (the official release should be uploaded to PyPI later today I think, you can subscribe to #5578 to be notified). |
Thanks I just noticed the
Neat I will be waiting for it 👍 |
Pillow 8.3.1 has now been released and uploaded to PyPI. |
I installed Pillow 8.3.1 on my work computer and placed the DLL files at the folder of Python.exe it didn't work. |
This works for me. The installation docs link to this Microsoft Docs page in the paragraph for Raqm, which lists the application directory as the first checked option (i.e. next to Python.exe). Did you perhaps install a 32-bit fribidi.dll for a 64-bit Python or vice-versa? |
I don't think I did that wrong. However, just to be sure, I made a virtual environment with python and put the DLL files next Python.exe and it still didn't work. |
I haven't tried it, but I'm pretty sure you can't put the DLL next to python.exe in a virtual environment as the python.exe is just a link to the system directory of the Python install. See |
Hello, I have this problem too on Mac. Can someone help me, please? I'm using Pillow version 9.5.0 because the newest version doesn't support some specific functions I need to use. |
How did you install Pillow? What is the output of Have you tried installing fribidi? https://pillow.readthedocs.io/en/stable/installation/basic-installation.html
|
This is what was displayed when I ran python3 -m PIL
and this is what I fused and installed
|
This means raqm is working for you. |
Ohh, but when I tried to run template.py in Synthtiger library, I still got |
Now, I think the problem is that I can't use the function getsize after Pillow version 9.2.0. Do you know if there is any way I can fix this or do I have to manually change to getbbox? |
My PIL library features contain raqm, but the |
Technically, it's only deprecated after 9.2.0. It was removed in 10.0.0.
You will have to change your code to use |
Considering that >>> from PIL import _imagingft
>>> _imagingft.HAVE_RAQM
True to check for raqm, what you're describing sounds unusual. Could you use code to depict what you're seeing? |
I tried it. I got False |
You previously reported the output of |
Wait. Sorry, I actually got true |
How do you know this? |
I edited in PIL/ImageFont.py file in my Python environment by adding: if (core.HAVE_RAQM):
print(True)
else:
print(False) , and it gave me False when I ran it |
Line 52 in 3c2d36e
So you're reporting that from PIL import _imagingft
print(_imagingft.HAVE_RAQM) is true, but from PIL import _imagingft as core
print(core.HAVE_RAQM) is false. This doesn't make sense? |
Since I used this command to run |
Ok, so it does sound like you're using a different version of Python for synthtiger. Since you're open to modifying Pillow code, could you edit ImageFont.py, insert That should print something like '/Applications/Xcode.app/Contents/Developer/usr/bin/python3' Then, using the path that was printed, run |
I got this |
Yes, nothing in that path says 'venv', so it wouldn't be inside your virtual environment. It's not clear to me why synthtiger was complaining about raqm, and not about Pillow not being installed in the first place. When you've been modifying ImageFont.py, and then running synthtiger, where is ImageFont.py located? I don't know if your goal is to run synthtiger inside your virtual environment though. If so, there's no point to continuing to debug this other installation. |
IIRC |
Now, I installed Pillow, and when I ran /opt/anaconda3/bin/python, I got
Is there any way that I can install raqm in conda env? |
I also got /opt/anaconda3 |
Which version of the Pillow package did you install (default, conda-forge, something else)? I think |
I got this after running
|
This makes no sense, you can't have both 10.3.0 and 9.5.0 installed at the same time. |
If I run from base env, I got this
I'm not sure if they are in a different environment. |
I just switched to the environment in which Pillow 10.3.0 is installed. When I run the synthtiger command, I got the getsize error instead of raqm
Does this mean I have to replace getsize by getbbox in every function in the synthtiger library? |
If synthtiger is where that line of code resides, then yes. clovaai/synthtiger#66 is the open issue in synthtiger for fixing this properly. |
I got it. Thank you so much for your help!!!!!! |
What did you do?
Built pillow from source with all dependencies and installed it using
python setup.py install
.Running selftest.py works, and seems to corroborate that raqm is indeed installed.
What did you expect to happen?
I expected to be able to set text direction
What actually happened?
I got the following exception:
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: