| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -724,42 +724,30 @@ def output_args(self): | |||
| 724 | 724 | return [self.outfile] | |
| 725 | 725 | ||
| 726 | 726 | @classmethod | |
| 727 | - def _init_from_registry(cls): | ||
| 728 | - if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert': | ||
| 729 | - return | ||
| 730 | - import winreg | ||
| 731 | - for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY): | ||
| 732 | - try: | ||
| 733 | - hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, | ||
| 734 | - r'Software\Imagemagick\Current', | ||
| 735 | - 0, winreg.KEY_QUERY_VALUE | flag) | ||
| 736 | - binpath = winreg.QueryValueEx(hkey, 'BinPath')[0] | ||
| 737 | - winreg.CloseKey(hkey) | ||
| 738 | - break | ||
| 739 | - except Exception: | ||
| 740 | - binpath = '' | ||
| 741 | - if binpath: | ||
| 742 | - for exe in ('convert.exe', 'magick.exe'): | ||
| 743 | - path = os.path.join(binpath, exe) | ||
| 744 | - if os.path.exists(path): | ||
| 745 | - binpath = path | ||
| 746 | - break | ||
| 747 | - else: | ||
| 748 | - binpath = '' | ||
| 749 | - rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath | ||
| 750 | - | ||
| 751 | - @classmethod | ||
| 752 | - def isAvailable(cls): | ||
| 753 | - ''' | ||
| 754 | - Check to see if a ImageMagickWriter is actually available. | ||
| 755 | - | ||
| 756 | - Done by first checking the windows registry (if applicable) and then | ||
| 757 | - running the commandline tool. | ||
| 758 | - ''' | ||
| 759 | - bin_path = cls.bin_path() | ||
| 760 | - if bin_path == "convert": | ||
| 761 | - cls._init_from_registry() | ||
| 762 | - return super().isAvailable() | ||
| 727 | + def bin_path(cls): | ||
| 728 | + binpath = super().bin_path() | ||
| 729 | + if sys.platform == 'win32' and binpath == 'convert': | ||
| 730 | + # Check the registry to avoid confusing ImageMagick's convert with | ||
| 731 | + # Windows's builtin convert.exe. | ||
| 732 | + import winreg | ||
| 733 | + binpath = '' | ||
| 734 | + for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY): | ||
| 735 | + try: | ||
| 736 | + with winreg.OpenKeyEx( | ||
| 737 | + winreg.HKEY_LOCAL_MACHINE, | ||
| 738 | + r'Software\Imagemagick\Current', | ||
| 739 | + 0, winreg.KEY_QUERY_VALUE | flag) as hkey: | ||
| 740 | + parent = winreg.QueryValueEx(hkey, 'BinPath')[0] | ||
| 741 | + except OSError: | ||
| 742 | + pass | ||
| 743 | + if binpath: | ||
| 744 | + for exe in ('convert.exe', 'magick.exe'): | ||
| 745 | + candidate = os.path.join(parent, exe) | ||
| 746 | + if os.path.exists(candidate): | ||
| 747 | + binpath = candidate | ||
| 748 | + break | ||
| 749 | + rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath | ||
| 750 | + return binpath | ||
| 763 | 751 | ||
| 764 | 752 | ||
| 765 | 753 | # Note: the base classes need to be in that order to get | |
| Back | FazBrowse Home | New Git URL |
0 commit comments