summaryrefslogtreecommitdiffstats
path: root/functions.inc
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2019-04-16 09:12:38 +0200
committerRemi Collet <remi@remirepo.net>2019-04-16 09:12:38 +0200
commita43a6790d5063ce8cca96c93f6a1aaa661cb8ab6 (patch)
tree1d7da0a83f0096dfd672e031aca5cabdfb983e08 /functions.inc
parentcf233ae1ee473dfdb6d5239078b03df983b6a878 (diff)
- update to 3.4.4RC1
- open https://github.com/mkoppanen/imagick/pull/274 missing file - open https://github.com/mkoppanen/imagick/issues/275 bad stabililty - open https://github.com/mkoppanen/imagick/issues/276 failed test on 32-bit
Diffstat (limited to 'functions.inc')
-rw-r--r--functions.inc65
1 files changed, 65 insertions, 0 deletions
diff --git a/functions.inc b/functions.inc
new file mode 100644
index 0000000..f5c1ef1
--- /dev/null
+++ b/functions.inc
@@ -0,0 +1,65 @@
+<?php
+
+/**
+ *
+ * Gets the installed version of ImageMagick and compares the
+ * appropriate version to the installed version. *
+ *
+ * @param $testIm6Version
+ * @param $im7Version
+ * @return int
+ */
+function version_compare_imagemagick($testIm6Version, $im7Version)
+{
+ $versionInfo = \Imagick::getVersion();
+
+ if (array_key_exists("versionString", $versionInfo) == false) {
+ die("skip unable to determine ImageMagick version.");
+ }
+
+ $versionInstalledStringComplete = $versionInfo["versionString"];
+
+ $firstSpace = strpos($versionInstalledStringComplete, ' ');
+ if ($firstSpace === false) {
+ die("Failed to understand version string [$versionInstalledStringComplete] - finding first space");
+ }
+
+ $secondSpace = strpos($versionInstalledStringComplete, ' ', $firstSpace + 1);
+ if ($secondSpace === false) {
+ die("Failed to understand version string [$versionInstalledStringComplete] - finding second space");
+ }
+
+ $versionInstalledString = substr($versionInstalledStringComplete, $firstSpace + 1, $secondSpace - $firstSpace - 1);
+ // echo "versionInstalledString is $versionInstalledString \n";
+
+ $versionToCompare = $im7Version;
+ if (substr($versionInstalledString, 0, 1) === '6') {
+ $versionToCompare = $testIm6Version;
+ }
+
+ return version_compare($versionInstalledString, $versionToCompare);
+}
+
+/**
+ *
+ * Compares the installed version of ImageMagick and returns true if the appropriate
+ * version is greater
+ *
+ * @param $testIm6Version
+ * @param $im7Version
+ * @return bool
+ */
+function isVersionGreaterEqual($testIm6Version, $im7Version)
+{
+ $versionCompare = version_compare_imagemagick($testIm6Version, $im7Version);
+ // echo "version compare for $testIm6Version, $im7Version is $versionCompare \n";
+
+ if ($versionCompare >= 0) {
+ return true;
+ }
+
+ return false;
+}
+
+
+