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

Respect MAGICK_HOME on Windows #663

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions wand/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,17 @@ def library_paths():
magick_home = os.environ.get('MAGICK_HOME')
magick_suffix = os.environ.get('WAND_MAGICK_LIBRARY_SUFFIX')

if system == 'Windows':
# ImageMagick installers normally install coder and filter DLLs in
# subfolders, we need to add those folders to PATH, otherwise loading
# the DLL later will fail.
if system == 'Windows' and magick_home is None:
try:
# Try to read ImageMagick location from registry.
# This is necessary if the user did not add the ImageMagick directory
# to PATH.
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
r"SOFTWARE\ImageMagick\Current") as reg_key:
libPath = winreg.QueryValueEx(reg_key, "LibPath")
coderPath = winreg.QueryValueEx(reg_key, "CoderModulesPath")
filterPath = winreg.QueryValueEx(reg_key, "FilterModulesPath")
magick_home = libPath[0]
os.environ['PATH'] += str((';' + libPath[0] + ";" +
coderPath[0] + ";" + filterPath[0]))
os.environ['PATH'] += ';' + str(magick_home)
except OSError:
# otherwise use MAGICK_HOME, and we assume the coder and
# filter DLLs are in the same directory
pass

def magick_path(path):
Expand Down