Skip to content

Commit

Permalink
Fixed install_imagemagick.bat script to detect latest version url fro…
Browse files Browse the repository at this point in the history
…m official download page.
  • Loading branch information
end2endzone committed Sep 2, 2024
1 parent b3f65dc commit db33b17
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions ci/windows/install_imagemagick.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@
:: https://imagemagick.org/script/download.php#windows

echo Installing ImageMagick...
set IKMAGEMAGICK_URL=https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-37-portable-Q16-x64.zip
set IKMAGEMAGICK_FILE=%TEMP%\imagemagick.zip
set IKMAGEMAGICK_INSTALL_DIR=%TEMP%\imagemagick
set IMAGEMAGICK_URL=https://imagemagick.org/script/download.php
set IMAGEMAGICK_FILE=%TEMP%\imagemagick.zip
set IMAGEMAGICK_INSTALL_DIR=%TEMP%\imagemagick
set IMAGEMAGICK_TEMP_FILE=%TEMP%\imagemagick.temp.txt

echo Searching for a ImageMagick download link from %IMAGEMAGICK_URL%.
powershell -command "(Invoke-WebRequest -Uri $Env:IMAGEMAGICK_URL).links.href | where {$_ -match '-portable-Q16-x64.zip'}">"%IMAGEMAGICK_TEMP_FILE%"
if errorlevel 1 (
echo Command failed. Unable to check for ImageMagick latest portable version binaries.
exit /B %errorlevel%
)
set /p IMAGEMAGICK_URL=<"%IMAGEMAGICK_TEMP_FILE%"
echo Found download url: %IMAGEMAGICK_URL%
if [%IMAGEMAGICK_URL%] == [] exit /B 1
echo.

:: Check that 7zip is installed
echo Searching for 7zip executable...
Expand All @@ -21,14 +33,14 @@ echo 7zip found.
echo.

:: Download installer
echo Downloading %IKMAGEMAGICK_URL%...
python -c "import urllib.request; import os; urllib.request.urlretrieve(os.getenv('IKMAGEMAGICK_URL'),os.getenv('IKMAGEMAGICK_FILE'));"
echo Downloading %IMAGEMAGICK_URL%...
python -c "import urllib.request; import os; urllib.request.urlretrieve(os.getenv('IMAGEMAGICK_URL'),os.getenv('IMAGEMAGICK_FILE'));"
if errorlevel 1 (
echo Command failed. Unable to download ImageMagick binaries.
exit /B %errorlevel%
)
if NOT EXIST "%IKMAGEMAGICK_FILE%" (
echo Download failed. The file '%IKMAGEMAGICK_FILE%' is not found.
if NOT EXIST "%IMAGEMAGICK_FILE%" (
echo Download failed. The file '%IMAGEMAGICK_FILE%' is not found.
exit /B %errorlevel%
)
echo done.
Expand All @@ -38,7 +50,7 @@ echo.
mkdir %TEMP%\imagemagick 1>NUL 2>NUL
echo Extracting content to installation directory...
REM WARNING. THE FOLLOWING COMMAND EXACT ALL FILES IN THE ARCHIVE TO THE SAME LOCATION DISREGARDING INTERNAL DIRECTORY STRUCTURE!!
7z e %IKMAGEMAGICK_FILE% -o%IKMAGEMAGICK_INSTALL_DIR% -aoa
7z e %IMAGEMAGICK_FILE% -o%IMAGEMAGICK_INSTALL_DIR% -aoa
if errorlevel 1 (
echo Failed to decompress ImageMagick binary installer.
exit /B %errorlevel%
Expand All @@ -48,7 +60,7 @@ echo.

:: Searching for imagemagick executable
echo Searching for imagemagick executable...
set PATH=%IKMAGEMAGICK_INSTALL_DIR%;%PATH%
set PATH=%IMAGEMAGICK_INSTALL_DIR%;%PATH%
where magick.exe 1>NUL 2>NUL
if errorlevel 1 (
echo Error: ImageMagick not installed on system.
Expand Down

0 comments on commit db33b17

Please sign in to comment.