-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_imagemagick.php
More file actions
83 lines (72 loc) · 2.5 KB
/
debug_imagemagick.php
File metadata and controls
83 lines (72 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
// Debug script to test ImageMagick functionality
$logFile = __DIR__ . '/logs/imagemagick_debug.log';
function logMsg($msg) {
global $logFile;
$timestamp = date('Y-m-d H:i:s');
file_put_contents($logFile, "[$timestamp] $msg\n", FILE_APPEND);
}
logMsg("=== ImageMagick Debug Test Started ===");
// Test 1: Extension loaded
logMsg("Test 1: Checking extension_loaded('imagick')...");
if (extension_loaded('imagick')) {
logMsg("PASS: Imagick extension is loaded");
} else {
logMsg("FAIL: Imagick extension NOT loaded");
die;
}
// Test 2: Class exists
logMsg("Test 2: Checking class_exists('Imagick')...");
if (class_exists('Imagick')) {
logMsg("PASS: Imagick class exists");
} else {
logMsg("FAIL: Imagick class does NOT exist");
die;
}
// Test 3: Create Imagick object
logMsg("Test 3: Creating Imagick object...");
try {
$imagick = new Imagick();
logMsg("PASS: Imagick object created successfully");
$imagick->clear();
$imagick->destroy();
} catch (Exception $e) {
logMsg("FAIL: " . $e->getMessage());
die;
}
// Test 4: Check if renderWithImageMagick function exists
logMsg("Test 4: Checking function_exists('renderWithImageMagick')...");
if (function_exists('renderWithImageMagick')) {
logMsg("PASS: renderWithImageMagick function exists");
} else {
logMsg("INFO: Function not defined yet (need to include convert.php)");
}
// Test 5: Try to include convert.php
logMsg("Test 5: Including convert.php...");
try {
include_once __DIR__ . '/convert.php';
logMsg("PASS: convert.php included successfully");
} catch (Exception $e) {
logMsg("FAIL: " . $e->getMessage());
die;
}
// Test 6: Check function again after include
logMsg("Test 6: Checking function after include...");
if (function_exists('renderWithImageMagick')) {
logMsg("PASS: renderWithImageMagick function exists after include");
} else {
logMsg("FAIL: Function still does not exist");
die;
}
// Test 7: Test library detection
logMsg("Test 7: Testing detectAvailableLibraries()...");
$detection = detectAvailableLibraries();
$imAvailable = $detection['detected_libraries']['imagemagick']['available'] ?? false;
logMsg("ImageMagick available: " . ($imAvailable ? 'YES' : 'NO'));
if ($imAvailable) {
logMsg("Version: " . ($detection['detected_libraries']['imagemagick']['version'] ?? 'N/A'));
} else {
logMsg("Reason: " . ($detection['detected_libraries']['imagemagick']['reason'] ?? 'Unknown'));
}
logMsg("=== All Tests Completed ===");
echo "Debug completed. Check logs at: $logFile\n";