Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
macOS: build ImageMagick for macOS 13 and check every library's minimum macOS (#600)
cre8ive-marketing4adee616d3f4
diff --git a/.github/workflows/magick-native-macos.yml b/.github/workflows/magick-native-macos.ymlnew file mode 100644index 00000000..33448cc1--- /dev/null+++ b/.github/workflows/magick-native-macos.yml@@ -0,0 +1,99 @@+name: ImageMagick for macOS 13++# Magick.NET's macOS libraries are built without a deployment target, so they need the macOS of the runner that built+# them: 14.0 on Apple silicon and 15.0 on Intel for Magick.NET 14.17.2 (#600). Filee supports macOS 13, so this job+# builds the same Magick.Native release from its pinned source with MACOSX_DEPLOYMENT_TARGET=13.0: ImageMagick's+# dependencies (ImageMagick/Dependencies, every library at the commit its release pins), ImageMagick at the commit+# Magick.Native pins, then Magick.Native itself. The steps are upstream's own (Magick.Native and Dependencies+# .github/workflows/main.yml), without the prebuilt dependency download.+#+# Run it once per Magick.NET version. The two dylibs are then hosted on dl.filee.sh and pinned by SHA-256 in+# build/build-portable.ps1, which puts them into the macOS packages. build/check-macho-minos.py fails the package+# build if a Magick.NET update brings back a library that needs a newer macOS.+#+# Pins for Magick.NET 14.17.2 (Directory.Packages.props): its nuspec commit aa58615 reads Magick.Native 2026.927.1314,+# which pins ImageMagick and downloads Dependencies 2026.09.26.1516.++on:+ workflow_dispatch:++permissions:+ contents: read++env:+ MACOSX_DEPLOYMENT_TARGET: '13.0'+ MAGICK_NATIVE_COMMIT: 999720f7ebe03d5a0029536f1586a2cb82b500ae # tag 2026.927.1314+ DEPENDENCIES_COMMIT: 1c21ff03809da9cc544427fcd04e965d1558d06f # tag 2026.09.26.1516+ QUANTUM: Q8++jobs:+ build:+ name: Magick.Native Q8 ${{ matrix.arch }} (macOS 13.0)+ strategy:+ fail-fast: false+ matrix:+ include:+ - runner: macos-14+ arch: arm64+ - runner: macos-15-intel+ arch: x64+ runs-on: ${{ matrix.runner }}+ timeout-minutes: 180+ defaults:+ run:+ shell: bash+ steps:+ - uses: actions/checkout@v7+ with:+ path: filee+ persist-credentials: false++ - name: Get pinned sources+ run: |+ fetch() {+ git init -q "$2"+ git -C "$2" fetch -q --depth 1 "https://github.com/$1.git" "$3"+ git -C "$2" checkout -q FETCH_HEAD+ }+ fetch dlemstra/Magick.Native native "$MAGICK_NATIVE_COMMIT"+ fetch ImageMagick/Dependencies dependencies "$DEPENDENCIES_COMMIT"+ fetch ImageMagick/ImageMagick native/src/ImageMagick/ImageMagick "$(< native/src/ImageMagick/ImageMagick.commit)"++ # Dependencies' install script covers Magick.Native's build tools too; running both fails, as both uninstall+ # the same Homebrew packages.+ - name: Install build tools+ working-directory: dependencies+ run: ./.github/build/macos-${{ matrix.arch }}/install.sh++ - name: Clone dependencies+ working-directory: dependencies+ run: ./clone-dependencies.sh macos++ - name: Build dependencies+ working-directory: dependencies+ run: ./.github/build/macos-${{ matrix.arch }}/build.sh++ - name: Build ImageMagick+ working-directory: native/src/ImageMagick/ImageMagick+ run: ../../../build/shared/build.imagemagick.sh macos ${{ matrix.arch }} "$QUANTUM"++ - name: Build Native+ working-directory: native/src/Magick.Native+ run: ../../build/shared/build.native.sh macos ${{ matrix.arch }} "$QUANTUM"++ - name: Copy Native+ working-directory: native/src/Magick.Native+ run: ../../build/shared/copy.native.sh "$GITHUB_WORKSPACE/out" macos ${{ matrix.arch }} "$QUANTUM"++ - name: Check minimum macOS+ run: python3 filee/build/check-macho-minos.py --max "$MACOSX_DEPLOYMENT_TARGET" out++ - name: Checksum+ working-directory: out+ run: shasum -a 256 * | tee SHA256SUMS.txt++ - uses: actions/upload-artifact@v7+ with:+ name: magick-native-${{ env.QUANTUM }}-osx-${{ matrix.arch }}+ path: out/+ if-no-files-found: errordiff --git a/build/build-portable.ps1 b/build/build-portable.ps1index b4cc7193..2f60ba24 100644--- a/build/build-portable.ps1+++ b/build/build-portable.ps1@@ -6,6 +6,11 @@# -RhwpOverride <dir> a folder with the rhwp program (rhwp's release archive layout) used instead of the rhwp# download pinned in engines.json# Without it (local builds) the package uses the download, which needs a newer glibc.+#+# macOS packages must run on macOS 13 (LSMinimumSystemVersion). Magick.NET's own macOS ImageMagick library needs macOS+# 14 (Apple silicon) or 15 (Intel), so it is replaced by the same Magick.Native release built for macOS 13+# (.github/workflows/magick-native-macos.yml), pinned below. Every Mach-O file is then checked against+# LSMinimumSystemVersion (build/check-macho-minos.py) before signing.[CmdletBinding()]param([ValidateSet('linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64')][string]$Runtime,@@ -53,6 +58,11 @@ $sums = Join-Path $OutputDir "$packageName-SHA256SUMS.txt"if ((Test-Path -LiteralPath $archive) -or (Test-Path -LiteralPath $sums) -or (Test-Path -LiteralPath $diskImage)) {throw "Package $packageName already exists. Use another output folder or version."}+# Magick.Native for Magick.NET 14.17.2 built for macOS 13 (#600). A Magick.NET update needs a new build and new pins.+$magickNative = @{+ 'osx-arm64' = @{ url = ''; sha256 = '' }+ 'osx-x64' = @{ url = ''; sha256 = '' }+}$stage = Join-Path $root ('build/.cache/portable/' + [Guid]::NewGuid().ToString('N'))$package = Join-Path $stage $packageName$appBundle = Join-Path $package 'Filee.app'@@ -93,6 +103,29 @@ foreach ($notice in @('LICENSE', 'THIRD-PARTY-NOTICES.md')) {}if ($Runtime.StartsWith('osx-')) {+ $pin = $magickNative[$Runtime]+ $library = Join-Path $publish "Magick.Native-Q8-$($Runtime.Substring(4)).dll.dylib"+ if (-not (Test-Path -LiteralPath $library -PathType Leaf)) { throw "Publish did not produce $(Split-Path $library -Leaf)" }+ if ($pin.sha256 -notmatch '^[0-9a-fA-F]{64}$') { throw "A pinned Magick.Native download is missing for $Runtime." }+ $cache = Join-Path $root 'build/.cache/portable-downloads'+ $cached = Join-Path $cache "$($pin.sha256).dylib"+ if (-not (Test-Path -LiteralPath $cached)) {+ New-Item -ItemType Directory -Force -Path $cache | Out-Null+ $download = "$cached.$([Guid]::NewGuid().ToString('N')).partial"+ Invoke-WebRequest -Uri $pin.url -OutFile $download+ if ((Get-FileHash -LiteralPath $download -Algorithm SHA256).Hash -ne $pin.sha256) {+ Remove-Item -LiteralPath $download+ throw "Checksum mismatch for Magick.Native ($Runtime)."+ }+ Move-Item -LiteralPath $download -Destination $cached+ }+ if ((Get-FileHash -LiteralPath $cached -Algorithm SHA256).Hash -ne $pin.sha256) {+ throw "Cached Magick.Native checksum mismatch: $cached"+ }+ Copy-Item -LiteralPath $cached -Destination $library -Force+ Write-Host "Magick.Native for macOS 13 from $($pin.url)"+ Invoke-Checked 'Check minimum macOS' { python3 (Join-Path $PSScriptRoot 'check-macho-minos.py') $publish }+$contents = Join-Path $appBundle 'Contents'$resources = Join-Path $contents 'Resources'New-Item -ItemType Directory -Path $resources | Out-Nulldiff --git a/build/check-macho-minos.py b/build/check-macho-minos.pynew file mode 100644index 00000000..2920c244--- /dev/null+++ b/build/check-macho-minos.py@@ -0,0 +1,176 @@+#!/usr/bin/env python3+"""Lists the minimum macOS every Mach-O file under the given paths was built for, and fails when one needs a newer+macOS than the app says it supports.++dyld refuses to load a library built for a newer macOS than the one running (LC_BUILD_VERSION minos, or the older+LC_VERSION_MIN_MACOSX). The app still starts, but the first conversion that needs the library fails (#600: the+ImageMagick library in Magick.NET 14.17.2 needs macOS 14 on Apple silicon and 15 on Intel). The limit is+LSMinimumSystemVersion in installer/macos/Info.plist unless --max is given. Universal (fat) files are checked per+architecture. Standard library only, so it runs on any CI image.++Usage: check-macho-minos.py [--max 13.0] PATH [PATH ...]+Exit codes: 0 every file is within the limit, 1 a file needs a newer macOS, 2 no Mach-O files or a file can't be read.+"""++import argparse+import os+import plistlib+import struct+import sys++ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))+INFO_PLIST = os.path.join(ROOT, "installer", "macos", "Info.plist")++MH_MAGIC = 0xFEEDFACE+MH_MAGIC_64 = 0xFEEDFACF+FAT_MAGIC = 0xCAFEBABE+FAT_MAGIC_64 = 0xCAFEBABF+LC_VERSION_MIN_MACOSX = 0x24+LC_BUILD_VERSION = 0x32+PLATFORM_MACOS = 1+CPU_NAMES = {7: "i386", 0x01000007: "x86_64", 12: "arm", 0x0100000C: "arm64"}+++class MachOError(Exception):+ pass+++def decode_version(packed):+ """xxxx.yy.zz nibbles, as in LC_BUILD_VERSION and LC_VERSION_MIN_MACOSX."""+ return (packed >> 16, (packed >> 8) & 0xFF, packed & 0xFF)+++def thin_minos(data, offset):+ """Returns (architecture, minimum macOS) of the thin Mach-O image at offset."""+ magic_le = struct.unpack_from("<I", data, offset)[0]+ if magic_le not in (MH_MAGIC, MH_MAGIC_64):+ raise MachOError("not a little-endian Mach-O image")+ is64 = magic_le == MH_MAGIC_64+ cputype, _, _, ncmds, sizeofcmds = struct.unpack_from("<iiIII", data, offset + 4)+ position = offset + (32 if is64 else 28)+ end = position + sizeofcmds+ found = None+ for _ in range(ncmds):+ if position + 8 > end:+ raise MachOError("load commands run past their size")+ command, size = struct.unpack_from("<II", data, position)+ if size < 8:+ raise MachOError("load command too small")+ if command == LC_BUILD_VERSION:+ platform, minos = struct.unpack_from("<II", data, position + 8)+ if platform == PLATFORM_MACOS:+ found = decode_version(minos)+ elif command == LC_VERSION_MIN_MACOSX and found is None:+ found = decode_version(struct.unpack_from("<I", data, position + 8)[0])+ position += size+ return CPU_NAMES.get(cputype & 0xFFFFFFFF, hex(cputype & 0xFFFFFFFF)), found+++def macho_minos(data):+ """Returns [(architecture, minimum macOS or None)] for a thin or universal Mach-O file."""+ if len(data) < 8:+ raise MachOError("file too small")+ magic_be = struct.unpack_from(">I", data, 0)[0]+ if magic_be in (FAT_MAGIC, FAT_MAGIC_64):+ count = struct.unpack_from(">I", data, 4)[0]+ entry, layout = (32, ">iiQQI") if magic_be == FAT_MAGIC_64 else (20, ">iiIII")+ offsets = [struct.unpack_from(layout, data, 8 + i * entry)[2] for i in range(count)]+ return [thin_minos(data, offset) for offset in offsets]+ return [thin_minos(data, 0)]+++def is_macho(path):+ try:+ with open(path, "rb") as stream:+ head = stream.read(8)+ except OSError:+ return False+ if len(head) < 8:+ return False+ if struct.unpack_from("<I", head)[0] in (MH_MAGIC, MH_MAGIC_64):+ return True+ # 0xCAFEBABE is also a Java class file; those have a major version >= 45 where a fat header has a small count.+ return struct.unpack_from(">I", head)[0] in (FAT_MAGIC, FAT_MAGIC_64) and struct.unpack_from(">I", head, 4)[0] < 20+++def macho_files(paths):+ for path in paths:+ if os.path.isdir(path):+ for directory, _, names in os.walk(path):+ for name in sorted(names):+ full = os.path.join(directory, name)+ if not os.path.islink(full) and is_macho(full):+ yield path, full+ elif is_macho(path):+ yield os.path.dirname(path), path+++def parse_version(text):+ parts = [int(part) for part in text.split(".")]+ return tuple((parts + [0, 0])[:3])+++def format_version(version):+ if version is None:+ return "none"+ return ".".join(str(part) for part in (version if version[2] else version[:2]))+++def default_limit():+ with open(INFO_PLIST, "rb") as stream:+ return plistlib.load(stream)["LSMinimumSystemVersion"]+++def main(argv=None):+ parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])+ parser.add_argument("--max", help="newest minimum macOS allowed (default: LSMinimumSystemVersion in Info.plist)")+ parser.add_argument("paths", nargs="+")+ options = parser.parse_args(argv)+ limit_text = options.max or default_limit()+ limit = parse_version(limit_text)++ rows = []+ unreadable = []+ for base, path in macho_files(options.paths):+ shown = os.path.relpath(path, base) if base else path+ try:+ with open(path, "rb") as stream:+ images = macho_minos(stream.read())+ except (MachOError, OSError, struct.error) as error:+ unreadable.append((shown, str(error)))+ continue+ for architecture, minos in images:+ rows.append((f"{shown} ({architecture})", minos))++ if not rows and not unreadable:+ print("No Mach-O files found in: " + ", ".join(options.paths), file=sys.stderr)+ return 2++ width = max([len(shown) for shown, _ in rows] + [len(shown) for shown, _ in unreadable] + [4])+ print(f"{'File':<{width}} {'Needs':<8} Result")+ print(f"{'-' * width} {'-' * 8} ------")+ failed = 0+ for shown, minos in rows:+ too_new = minos is not None and minos > limit+ failed += too_new+ result = f"needs a newer macOS than {limit_text}" if too_new else "ok"+ print(f"{shown:<{width}} {format_version(minos):<8} {result}")+ for shown, error in unreadable:+ print(f"{shown:<{width}} {'?':<8} cannot read: {error}")++ newest = max((minos for _, minos in rows if minos), default=None)+ print()+ print(f"{len(rows)} Mach-O images, newest requirement macOS {format_version(newest)}, limit macOS {limit_text}.")+ sys.stdout.flush()+ if failed:+ print(f"{failed} image(s) need a macOS newer than {limit_text}: they would not load on the oldest supported "+ "macOS. Rebuild them for it or raise LSMinimumSystemVersion.", file=sys.stderr)+ return 1+ if unreadable:+ print(f"{len(unreadable)} Mach-O file(s) could not be read.", file=sys.stderr)+ return 2+ return 0+++if __name__ == "__main__":+ sys.exit(main())