summaryrefslogtreecommitdiffstats
path: root/imagick-php8.patch
blob: b18cc16b11ef209590095939cde050561dbd26c9 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
diff --git a/imagick.c b/imagick.c
index 8e58afe..1e6d174 100644
--- a/imagick.c
+++ b/imagick.c
@@ -40,7 +40,11 @@
 ZEND_DECLARE_MODULE_GLOBALS(imagick)
 
 #ifdef IMAGICK_WITH_KERNEL
-HashTable* php_imagickkernel_get_debug_info(zval *obj, int *is_temp TSRMLS_DC); /* {{{ */
+	#if PHP_VERSION_ID >= 80000
+	HashTable* php_imagickkernel_get_debug_info(zend_object *obj, int *is_temp TSRMLS_DC); /* {{{ */
+	#else
+	HashTable* php_imagickkernel_get_debug_info(zval *obj, int *is_temp TSRMLS_DC); /* {{{ */
+	#endif
 #endif
 
 zend_class_entry *php_imagick_sc_entry;
@@ -429,6 +433,14 @@ PHP_IMAGICK_API zend_class_entry *php_imagickpixel_get_class_entry()
 		ZEND_ARG_INFO(0, threshold)
 	ZEND_END_ARG_INFO()
 
+#if PHP_IMAGICK_HAVE_HOUGHLINE
+	ZEND_BEGIN_ARG_INFO_EX(imagick_houghlineimage_args, 0, 0, 3)
+		ZEND_ARG_INFO(0, width)
+		ZEND_ARG_INFO(0, height)
+	    ZEND_ARG_INFO(0, threshold)
+	ZEND_END_ARG_INFO()
+#endif
+
 	ZEND_BEGIN_ARG_INFO_EX(imagick_segmentimage_args, 0, 0, 3)
 		ZEND_ARG_INFO(0, COLORSPACE)
 		ZEND_ARG_INFO(0, cluster_threshold)
@@ -2412,6 +2424,9 @@ static zend_function_entry php_imagick_class_methods[] =
 	PHP_ME(imagick, sparsecolorimage, imagick_sparsecolorimage_args, ZEND_ACC_PUBLIC)
 	PHP_ME(imagick, remapimage, imagick_remapimage_args, ZEND_ACC_PUBLIC)
 #endif
+#if PHP_IMAGICK_HAVE_HOUGHLINE
+	PHP_ME(imagick, houghlineimage, imagick_houghlineimage_args, ZEND_ACC_PUBLIC)
+#endif
 #if MagickLibVersion > 0x646
 	PHP_ME(imagick, exportimagepixels, imagick_exportimagepixels_args, ZEND_ACC_PUBLIC)
 #endif
@@ -2441,7 +2456,7 @@ static zend_function_entry php_imagick_class_methods[] =
 	PHP_ME(imagick, smushimages, imagick_smushimages_args, ZEND_ACC_PUBLIC)
 #endif
 	PHP_ME(imagick, __construct, imagick_construct_args, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
-	PHP_ME(imagick, __tostring, NULL, ZEND_ACC_PUBLIC)
+	PHP_ME(imagick, __tostring, imagick_zero_args, ZEND_ACC_PUBLIC)
 #if PHP_VERSION_ID >= 50600
 	PHP_ME(imagick, count, imagick_count_args, ZEND_ACC_PUBLIC)
 #else
@@ -2657,7 +2672,7 @@ static zend_function_entry php_imagick_class_methods[] =
 	PHP_ME(imagick, getimagegamma, imagick_zero_args, ZEND_ACC_PUBLIC)
 	PHP_ME(imagick, getimagegreenprimary, imagick_zero_args, ZEND_ACC_PUBLIC)
 	PHP_ME(imagick, getimageheight, imagick_zero_args, ZEND_ACC_PUBLIC)
-	PHP_ME(imagick, getimagehistogram, NULL, ZEND_ACC_PUBLIC)
+	PHP_ME(imagick, getimagehistogram, imagick_zero_args, ZEND_ACC_PUBLIC)
 	PHP_ME(imagick, getimageinterlacescheme, imagick_zero_args, ZEND_ACC_PUBLIC)
 	PHP_ME(imagick, getimageiterations, imagick_zero_args, ZEND_ACC_PUBLIC)
 #if MagickLibVersion < 0x700
@@ -3262,6 +3277,10 @@ PHP_INI_BEGIN()
 	STD_PHP_INI_ENTRY("imagick.locale_fix", "0", PHP_INI_ALL, OnUpdateBool, locale_fix, zend_imagick_globals, imagick_globals)
 	STD_PHP_INI_ENTRY("imagick.skip_version_check", "0", PHP_INI_ALL, OnUpdateBool, skip_version_check, zend_imagick_globals, imagick_globals)
 	STD_PHP_INI_ENTRY("imagick.progress_monitor", "0", PHP_INI_SYSTEM, OnUpdateBool, progress_monitor, zend_imagick_globals, imagick_globals)
+
+	STD_PHP_INI_ENTRY("imagick.set_single_thread", "0", PHP_INI_SYSTEM, OnUpdateBool, set_single_thread, zend_imagick_globals, imagick_globals)
+	STD_PHP_INI_ENTRY("imagick.shutdown_sleep_count",  "10", PHP_INI_ALL, OnUpdateLong, shutdown_sleep_count, zend_imagick_globals, imagick_globals)
+
 PHP_INI_END()
 
 static void php_imagick_init_globals(zend_imagick_globals *imagick_globals)
@@ -3269,12 +3288,21 @@ static void php_imagick_init_globals(zend_imagick_globals *imagick_globals)
 	imagick_globals->locale_fix = 0;
 	imagick_globals->progress_monitor = 0;
 	imagick_globals->skip_version_check = 0;
+	imagick_globals->set_single_thread = 0;
+	// 10 is magick number, that seems to be enough.
+	imagick_globals->shutdown_sleep_count = 10;
 }
 
 
+#if PHP_VERSION_ID >= 80000
+static int php_imagick_count_elements(zend_object *object, im_long *count) /* {{{ */
+{
+	php_imagick_object *intern= php_imagick_fetch_object(object);
+#else
 static int php_imagick_count_elements(zval *object, im_long *count TSRMLS_DC) /* {{{ */
 {
 	php_imagick_object *intern= Z_IMAGICK_P(object);
+#endif
 
 	if (intern->magick_wand) {
 		*count = MagickGetNumberImages(intern->magick_wand);
@@ -3283,6 +3311,71 @@ static int php_imagick_count_elements(zval *object, im_long *count TSRMLS_DC) /*
 	return FAILURE;
 }
 
+
+#if PHP_VERSION_ID >= 80000
+static zval *php_imagick_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv)
+{
+	int ret;
+	php_imagick_object *intern;
+	zval *retval = NULL;
+    const zend_object_handlers *std_hnd;
+
+
+	std_hnd = zend_get_std_object_handlers();
+
+	ret = std_hnd->has_property(object, member, type, cache_slot TSRMLS_CC);
+
+	if (ret) {
+		//TODO - this would allow better immutability
+		//ZVAL_COPY_VALUE(retval, std_hnd->read_property(object, member, type, cache_slot, rv TSRMLS_CC));
+		retval = std_hnd->read_property(object, member, type, cache_slot, rv TSRMLS_CC);
+	}
+	else {
+
+		intern = php_imagick_fetch_object(object);
+		/* Do we have any images? */
+		if (MagickGetNumberImages(intern->magick_wand)) {
+
+			//TODO - this seems redundant
+			/* Is this overloaded? */
+			if (!strcmp(ZSTR_VAL(member), "width") ||
+				!strcmp(ZSTR_VAL(member), "height") ||
+				!strcmp(ZSTR_VAL(member), "format")) {
+
+				if (!strcmp(ZSTR_VAL(member), "width")) {
+					retval = rv;
+					ZVAL_LONG(retval, MagickGetImageWidth(intern->magick_wand));
+				} else if (!strcmp(ZSTR_VAL(member), "height")) {
+					retval = rv;
+					ZVAL_LONG(retval, MagickGetImageHeight(intern->magick_wand));
+				} else if (!strcmp(ZSTR_VAL(member), "format")) {
+					char *format = MagickGetImageFormat(intern->magick_wand);
+
+					if (format) {
+						retval = rv;
+						ZVAL_STRING(retval, format);
+						IMAGICK_FREE_MAGICK_MEMORY(format);
+					} else {
+						retval = rv;
+						ZVAL_STRING(retval, "");
+					}
+				}
+			}
+		}
+	}
+
+	if (!retval) {
+		//TODO - why is the error silent - it would be a small BC break
+		//to enable the warning. I think it would be the correct thing to do though.
+		//zend_error(E_NOTICE,"Undefined property: \Imagick::$%s", Z_STRVAL_P(member));
+		retval = &EG(uninitialized_zval);
+	}
+
+	return retval;
+}
+
+#else // PHP_VERSION_ID >= 80000
+
 #ifdef ZEND_ENGINE_3
 static zval *php_imagick_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv TSRMLS_DC)
 {
@@ -3434,7 +3527,11 @@ static zval *php_imagick_read_property(zval *object, zval *member, int type, con
 }
 #endif
 
-#ifdef ZEND_ENGINE_3
+#endif
+
+#if PHP_VERSION_ID >= 80000
+static zend_object * php_imagick_clone_imagick_object(zend_object *this_ptr)
+#elif PHP_VERSION_ID >= 70000
 static zend_object * php_imagick_clone_imagick_object(zval *this_ptr TSRMLS_DC)
 #else
 static zend_object_value php_imagick_clone_imagick_object(zval *this_ptr TSRMLS_DC)
@@ -3442,7 +3539,11 @@ static zend_object_value php_imagick_clone_imagick_object(zval *this_ptr TSRMLS_
 {
 	MagickWand *wand_copy = NULL;
 	php_imagick_object *new_obj = NULL;
-#ifdef ZEND_ENGINE_3
+#if PHP_VERSION_ID >= 80000
+	php_imagick_object *old_obj = php_imagick_fetch_object(this_ptr);
+	zend_object * new_zo = php_imagick_object_new_ex(old_obj->zo.ce, &new_obj, 0 TSRMLS_CC);
+	zend_objects_clone_members(&new_obj->zo, &old_obj->zo TSRMLS_CC);
+#elif PHP_VERSION_ID >= 70000
 	php_imagick_object *old_obj = Z_IMAGICK_P(this_ptr);
 	zend_object * new_zo = php_imagick_object_new_ex(old_obj->zo.ce, &new_obj, 0 TSRMLS_CC);
 	zend_objects_clone_members(&new_obj->zo, &old_obj->zo TSRMLS_CC);
@@ -3466,7 +3567,9 @@ static zend_object_value php_imagick_clone_imagick_object(zval *this_ptr TSRMLS_
 	return new_zo;
 }
 
-#ifdef ZEND_ENGINE_3
+#if PHP_VERSION_ID >= 80000
+static zend_object * php_imagick_clone_imagickdraw_object(zend_object *this_ptr)
+#elif PHP_VERSION_ID >= 70000
 static zend_object * php_imagick_clone_imagickdraw_object(zval *this_ptr TSRMLS_DC)
 #else
 static zend_object_value php_imagick_clone_imagickdraw_object(zval *this_ptr TSRMLS_DC)
@@ -3474,7 +3577,11 @@ static zend_object_value php_imagick_clone_imagickdraw_object(zval *this_ptr TSR
 {
 	DrawingWand *wand_copy = NULL;
 	php_imagickdraw_object *new_obj = NULL;
-#ifdef ZEND_ENGINE_3
+#if PHP_VERSION_ID >= 80000
+	php_imagickdraw_object *old_obj = php_imagickdraw_fetch_object(this_ptr);
+	zend_object * new_zo = php_imagickdraw_object_new_ex(old_obj->zo.ce, &new_obj, 0 TSRMLS_CC);
+	zend_objects_clone_members(&new_obj->zo, &old_obj->zo TSRMLS_CC);
+#elif PHP_VERSION_ID >= 70000
 	php_imagickdraw_object *old_obj = Z_IMAGICKDRAW_P(this_ptr);
 	zend_object * new_zo = php_imagickdraw_object_new_ex(old_obj->zo.ce, &new_obj, 0 TSRMLS_CC);
 	zend_objects_clone_members(&new_obj->zo, &old_obj->zo TSRMLS_CC);
@@ -3494,7 +3601,10 @@ static zend_object_value php_imagick_clone_imagickdraw_object(zval *this_ptr TSR
 	return new_zo;
 }
 
-#ifdef ZEND_ENGINE_3
+
+#if PHP_VERSION_ID >= 80000
+static zend_object * php_imagick_clone_imagickpixel_object(zend_object *this_ptr)
+#elif PHP_VERSION_ID >= 70000
 static zend_object * php_imagick_clone_imagickpixel_object(zval *this_ptr TSRMLS_DC)
 #else
 static zend_object_value php_imagick_clone_imagickpixel_object(zval *this_ptr TSRMLS_DC)
@@ -3502,12 +3612,18 @@ static zend_object_value php_imagick_clone_imagickpixel_object(zval *this_ptr TS
 {
 	PixelWand *wand_copy = NULL;
 	php_imagickpixel_object *new_obj = NULL;
-#ifdef ZEND_ENGINE_3
+
+#if PHP_VERSION_ID >= 80000
+	zend_object *new_zo;
+	php_imagickpixel_object *old_obj = php_imagickpixel_fetch_object(this_ptr);
+	new_zo = php_imagickpixel_object_new_ex(old_obj->zo.ce, &new_obj TSRMLS_CC);
+	zend_objects_clone_members(&new_obj->zo, &old_obj->zo TSRMLS_CC);
+#elif PHP_VERSION_ID >= 70000
 	zend_object *new_zo;
 	php_imagickpixel_object *old_obj = Z_IMAGICKPIXEL_P(this_ptr);
 	new_zo = php_imagickpixel_object_new_ex(old_obj->zo.ce, &new_obj TSRMLS_CC);
 	zend_objects_clone_members(&new_obj->zo, &old_obj->zo TSRMLS_CC);
-#else 
+#else
 	php_imagickpixel_object *old_obj = (php_imagickpixel_object *) zend_object_store_get_object(this_ptr TSRMLS_CC);
 	zend_object_value new_zo = php_imagickpixel_object_new_ex(old_obj->zo.ce, &new_obj TSRMLS_CC);
 	zend_objects_clone_members(&new_obj->zo, new_zo, &old_obj->zo, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
@@ -3524,7 +3640,10 @@ static zend_object_value php_imagick_clone_imagickpixel_object(zval *this_ptr TS
 }
 
 #ifdef IMAGICK_WITH_KERNEL
-#ifdef ZEND_ENGINE_3
+
+#if PHP_VERSION_ID >= 80000
+static zend_object * php_imagick_clone_imagickkernel_object(zend_object *this_ptr TSRMLS_DC)
+#elif PHP_VERSION_ID >= 70000
 static zend_object * php_imagick_clone_imagickkernel_object(zval *this_ptr TSRMLS_DC)
 #else
 static zend_object_value php_imagick_clone_imagickkernel_object(zval *this_ptr TSRMLS_DC)
@@ -3533,7 +3652,12 @@ static zend_object_value php_imagick_clone_imagickkernel_object(zval *this_ptr T
 	KernelInfo *kernel_info_copy = NULL;
 	php_imagickkernel_object *new_obj = NULL;
 
-#ifdef ZEND_ENGINE_3
+#if PHP_VERSION_ID >= 80000
+	zend_object *new_zo;
+	php_imagickkernel_object *old_obj = php_imagickkernel_fetch_object(this_ptr);
+	new_zo = php_imagickkernel_object_new_ex(old_obj->zo.ce, &new_obj TSRMLS_CC);
+	zend_objects_clone_members(&new_obj->zo, &old_obj->zo TSRMLS_CC);
+#elif PHP_VERSION_ID >= 70000
 	zend_object *new_zo;
 	php_imagickkernel_object *old_obj = Z_IMAGICKKERNEL_P(this_ptr);
 	new_zo = php_imagickkernel_object_new_ex(old_obj->zo.ce, &new_obj TSRMLS_CC);
@@ -3748,6 +3872,10 @@ PHP_MINIT_FUNCTION(imagick)
 		checkImagickVersion();
 	}
 
+	if (IMAGICK_G(set_single_thread)) {
+		MagickSetResourceLimit(ThreadResource, 1);
+	}
+
 	return SUCCESS;
 }
 
@@ -3757,7 +3885,7 @@ PHP_MINFO_FUNCTION(imagick)
 
 #ifdef ZEND_ENGINE_3
 	smart_string formats = {0};
-#else 
+#else
 	smart_str formats = {0};
 #endif
 
@@ -3824,12 +3952,21 @@ PHP_MINFO_FUNCTION(imagick)
 
 PHP_MSHUTDOWN_FUNCTION(imagick)
 {
+    int i;
+
 // This suppresses an 'unused parameter' warning.
 	(void)type;
 
-
 	MagickWandTerminus();
 
+    // Sleep for a bit to hopefully allow OpenMP to
+    // shut down the threads it created, and avoid a segfault
+    // This hack won't be needed once everyone is compiling ImageMagick
+    // against a version of OpenMP that has omp_pause_resource_all()
+	for (i = 0; i < 100 && i < IMAGICK_G(shutdown_sleep_count); i += 1) {
+		usleep(1000);
+	}
+
 #if defined(ZTS) && defined(PHP_WIN32)
 	tsrm_mutex_free(imagick_mutex);
 #endif
diff --git a/imagick_class.c b/imagick_class.c
index 164406a..3b041c5 100644
--- a/imagick_class.c
+++ b/imagick_class.c
@@ -2488,6 +2488,37 @@ PHP_METHOD(imagick, deskewimage)
 	RETURN_TRUE;
 }
 
+
+#if PHP_IMAGICK_HAVE_HOUGHLINE
+/* {{{ proto bool Imagick::houghLineImage(int width, int height, float threshold)
+        Draw hough lines for the image
+
+*/
+PHP_METHOD(imagick, houghlineimage)
+{
+        php_imagick_object *intern;
+        MagickBooleanType status;
+        double threshold;
+        im_long width, height;
+
+        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lld", &width, &height, &threshold) == FAILURE) {
+                return;
+        }
+
+        intern = Z_IMAGICK_P(getThis());
+        if (php_imagick_ensure_not_empty (intern->magick_wand) == 0)
+                return;
+
+        status = MagickHoughLineImage(intern->magick_wand, width, height, threshold);
+        if (status == MagickFalse) {
+                php_imagick_convert_imagick_exception(intern->magick_wand, "Unable to Hough line image" TSRMLS_CC);
+                return;
+        }
+        RETURN_TRUE;
+}
+/* }}} */
+#endif
+
 PHP_METHOD(imagick, segmentimage)
 {
 	php_imagick_object *intern;
diff --git a/imagick_helpers.c b/imagick_helpers.c
index 3d90aac..a85f72e 100644
--- a/imagick_helpers.c
+++ b/imagick_helpers.c
@@ -97,6 +97,11 @@ MagickBooleanType php_imagick_progress_monitor_callable(const char *text, const
 	fci_cache = empty_fcall_info_cache;
 
 	fci.size = sizeof(fci);
+
+#if PHP_VERSION_ID >= 80000
+	fci.named_params = NULL;
+#endif
+
 #if PHP_VERSION_ID < 70100
 	fci.function_table = EG(function_table);
 #endif
@@ -113,7 +118,9 @@ MagickBooleanType php_imagick_progress_monitor_callable(const char *text, const
 #endif
 	fci.param_count = 2;
 	fci.params = zargs;
+#if PHP_VERSION_ID < 80000
 	fci.no_separation = 0;
+#endif
 #if PHP_VERSION_ID < 70100
 	fci.symbol_table = NULL;
 #endif
@@ -804,7 +811,7 @@ PixelWand *php_imagick_zval_to_pixelwand (zval *param, php_imagick_class_type_t
 		break;
 
 		case IS_OBJECT:
-			if (instanceof_function_ex(Z_OBJCE_P(param), php_imagickpixel_sc_entry, 0 TSRMLS_CC)) {
+			if (instanceof_function(Z_OBJCE_P(param), php_imagickpixel_sc_entry TSRMLS_CC)) {
 				php_imagickpixel_object *intern = Z_IMAGICKPIXEL_P(param);
 				pixel_wand = intern->pixel_wand;
 			} else
@@ -854,7 +861,7 @@ PixelWand *php_imagick_zval_to_opacity (zval *param, php_imagick_class_type_t ca
 		break;
 
 		case IS_OBJECT:
-			if (instanceof_function_ex(Z_OBJCE_P(param), php_imagickpixel_sc_entry, 0 TSRMLS_CC)) {
+			if (instanceof_function(Z_OBJCE_P(param), php_imagickpixel_sc_entry TSRMLS_CC)) {
 				php_imagickpixel_object *intern = Z_IMAGICKPIXEL_P(param);
 				pixel_wand = intern->pixel_wand;
 			} else
diff --git a/imagickkernel_class.c b/imagickkernel_class.c
index 7504d29..9cfc581 100644
--- a/imagickkernel_class.c
+++ b/imagickkernel_class.c
@@ -79,7 +79,11 @@ static void php_imagickkernelvalues_to_zval(zval *zv, KernelInfo *kernel_info) {
 }
 
 
+#if PHP_VERSION_ID >= 80000
+HashTable* php_imagickkernel_get_debug_info(zend_object *obj, int *is_temp TSRMLS_DC) /* {{{ */
+#else
 HashTable* php_imagickkernel_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{ */
+#endif
 {
 	php_imagickkernel_object *internp;
 	HashTable *debug_info;
@@ -92,7 +96,11 @@ HashTable* php_imagickkernel_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /
 
 	*is_temp = 1; //var_dump will destroy the hashtable
 
+#if PHP_VERSION_ID >= 80000
+	internp = php_imagickkernel_fetch_object(obj);
+#else
 	internp = Z_IMAGICKKERNEL_P(obj);
+#endif
 	kernel_info = internp->kernel_info;
 
 	ALLOC_HASHTABLE(debug_info);
diff --git a/php_imagick_defs.h b/php_imagick_defs.h
index 5eb57e5..dd16896 100644
--- a/php_imagick_defs.h
+++ b/php_imagick_defs.h
@@ -42,6 +42,16 @@
 #include "php_ini.h"
 #include "Zend/zend.h"
 
+#if PHP_VERSION_ID >= 80000
+	#define HAVE_LOCALE_H
+	#define TSRMLS_C
+	#define TSRMLS_CC
+	#define TSRMLS_D
+	#define TSRMLS_DC
+	#define TSRMLS_FETCH()
+	#define TSRMLS_SET_CTX(ctx)
+#endif
+
 /* Include locale header */
 #ifdef HAVE_LOCALE_H
 # include <locale.h>
@@ -83,6 +93,10 @@ ZEND_BEGIN_MODULE_GLOBALS(imagick)
 	zend_bool locale_fix;
 	zend_bool progress_monitor;
 	zend_bool skip_version_check;
+
+	zend_bool set_single_thread;
+	im_long shutdown_sleep_count;
+
 	php_imagick_callback *progress_callback;
 #ifdef PHP_IMAGICK_ZEND_MM
 	MagickWand *keep_alive;
@@ -388,6 +402,12 @@ extern zend_class_entry *php_imagickkernel_exception_class_entry;
 
 /* Forward declarations (Imagick) */
 
+#if (MagickLibVersion >= 0x700 && MagickLibVersion >= 0x709)
+  #define PHP_IMAGICK_HAVE_HOUGHLINE 1
+#else
+  #define PHP_IMAGICK_HAVE_HOUGHLINE 0
+#endif
+
 /* The conditional methods */
 #if MagickLibVersion > 0x628
 PHP_METHOD(imagick, pingimageblob);
@@ -510,6 +530,11 @@ PHP_METHOD(imagick, setimagegravity);
 #if MagickLibVersion > 0x645
 PHP_METHOD(imagick, importimagepixels);
 PHP_METHOD(imagick, deskewimage);
+
+
+#if PHP_IMAGICK_HAVE_HOUGHLINE
+PHP_METHOD(imagick, houghlineimage);
+#endif
 PHP_METHOD(imagick, segmentimage);
 PHP_METHOD(imagick, sparsecolorimage);
 PHP_METHOD(imagick, remapimage);
diff --git a/tests/034_Imagick_annotateImage_basic.phpt b/tests/034_Imagick_annotateImage_basic.phpt
index 65d113f..431df4b 100644
--- a/tests/034_Imagick_annotateImage_basic.phpt
+++ b/tests/034_Imagick_annotateImage_basic.phpt
@@ -8,6 +8,8 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'rgb(232, 227, 232)';
 
@@ -24,6 +26,8 @@ function annotateImage($strokeColor, $fillColor) {
     
     $text = "Imagick is a native php \nextension to create and \nmodify images using the\nImageMagick API.";
 
+    setFontForImagick($imagick);
+    setFontForImagickDraw($draw);
     $imagick->annotateimage($draw, 40, 40, 0, $text);
 
     $bytes = $imagick->getImageBlob();
diff --git a/tests/047_Imagick_convolveImage_6.phpt b/tests/047_Imagick_convolveImage_6.phpt
index 0bca35f..1a4cb41 100644
--- a/tests/047_Imagick_convolveImage_6.phpt
+++ b/tests/047_Imagick_convolveImage_6.phpt
@@ -38,5 +38,5 @@ convolveImage($bias, $kernelMatrix) ;
 echo "Ok";
 ?>
 --EXPECTF--
-Deprecated: Function Imagick::setimagebias() is deprecated in %s
+Deprecated: %s Imagick::setimagebias() is deprecated in %s
 Ok
diff --git a/tests/097_Imagick_newPseudoImage_basic.phpt b/tests/097_Imagick_newPseudoImage_basic.phpt
index 5b22164..fbb87ef 100644
--- a/tests/097_Imagick_newPseudoImage_basic.phpt
+++ b/tests/097_Imagick_newPseudoImage_basic.phpt
@@ -5,7 +5,7 @@ Test Imagick, newPseudoImage
 --FILE--
 <?php
 
-$canvasType = 'gradient:';
+$canvasType = 'gradient:red';
 
 function newPseudoImage($canvasType) {
     $imagick = new \Imagick();
@@ -19,4 +19,4 @@ newPseudoImage($canvasType) ;
 echo "Ok";
 ?>
 --EXPECTF--
-Ok
\ No newline at end of file
+Ok
diff --git a/tests/098_Imagick_orderedPosterizeImage_basic.phpt b/tests/098_Imagick_orderedPosterizeImage_basic.phpt
index e53ecb5..87192c5 100644
--- a/tests/098_Imagick_orderedPosterizeImage_basic.phpt
+++ b/tests/098_Imagick_orderedPosterizeImage_basic.phpt
@@ -28,5 +28,5 @@ orderedPosterizeImage($orderedPosterizeType) ;
 echo "Ok";
 ?>
 --EXPECTF--
-Deprecated: Function Imagick::orderedposterizeimage() is deprecated in %S
+Deprecated: %s Imagick::orderedposterizeimage() is deprecated in %S
 Ok
diff --git a/tests/102_Imagick_radialBlurImage_basic.phpt b/tests/102_Imagick_radialBlurImage_basic.phpt
index bfcce5e..9820957 100644
--- a/tests/102_Imagick_radialBlurImage_basic.phpt
+++ b/tests/102_Imagick_radialBlurImage_basic.phpt
@@ -24,9 +24,9 @@ radialBlurImage() ;
 echo "Ok";
 ?>
 --EXPECTF--
-Deprecated: Function Imagick::radialblurimage() is deprecated in %s
+Deprecated: %s Imagick::radialblurimage() is deprecated in %s
 
-Deprecated: Function Imagick::radialblurimage() is deprecated in %s
+Deprecated: %s Imagick::radialblurimage() is deprecated in %s
 
-Deprecated: Function Imagick::radialblurimage() is deprecated in %s
+Deprecated: %s Imagick::radialblurimage() is deprecated in %s
 Ok
diff --git a/tests/112_Imagick_roundCorners_basic.phpt b/tests/112_Imagick_roundCorners_basic.phpt
index cdf026f..98c798f 100644
--- a/tests/112_Imagick_roundCorners_basic.phpt
+++ b/tests/112_Imagick_roundCorners_basic.phpt
@@ -40,5 +40,5 @@ roundCorners() ;
 echo "Ok";
 ?>
 --EXPECTF--
-Deprecated: Function Imagick::roundcornersimage() is deprecated in %s
+Deprecated: %s Imagick::roundcornersimage() is deprecated in %s
 Ok
diff --git a/tests/121_Imagick_setImageBias_basic.phpt b/tests/121_Imagick_setImageBias_basic.phpt
index 2ceab20..662a439 100644
--- a/tests/121_Imagick_setImageBias_basic.phpt
+++ b/tests/121_Imagick_setImageBias_basic.phpt
@@ -34,5 +34,5 @@ setImageBias($bias) ;
 echo "Ok";
 ?>
 --EXPECTF--
-Deprecated: Function Imagick::setimagebias() is deprecated in %s
+Deprecated: %s Imagick::setimagebias() is deprecated in %s
 Ok
diff --git a/tests/123_Imagick_setImageClipMask_basic.phpt b/tests/123_Imagick_setImageClipMask_basic.phpt
index 7844fa7..a1620ba 100644
--- a/tests/123_Imagick_setImageClipMask_basic.phpt
+++ b/tests/123_Imagick_setImageClipMask_basic.phpt
@@ -48,5 +48,5 @@ setImageClipMask() ;
 echo "Ok";
 ?>
 --EXPECTF--
-Deprecated: Function Imagick::setimageclipmask() is deprecated in %s
+Deprecated: %s Imagick::setimageclipmask() is deprecated in %s
 Ok
diff --git a/tests/151_Imagick_subImageMatch_basic.phpt b/tests/151_Imagick_subImageMatch_basic.phpt
index 491bb79..f11884f 100644
--- a/tests/151_Imagick_subImageMatch_basic.phpt
+++ b/tests/151_Imagick_subImageMatch_basic.phpt
@@ -2,7 +2,7 @@
 Test Imagick, subImageMatch
 --SKIPIF--
 <?php
-$imageMagickRequiredVersion=0x675;
+$imageMagickRequiredVersion=0x687;
 require_once(dirname(__FILE__) . '/skipif.inc');
 ?>
 --FILE--
diff --git a/tests/159_Imagick_transformImage_basic.phpt b/tests/159_Imagick_transformImage_basic.phpt
index d3764c9..cf90987 100644
--- a/tests/159_Imagick_transformImage_basic.phpt
+++ b/tests/159_Imagick_transformImage_basic.phpt
@@ -22,5 +22,5 @@ transformimage() ;
 echo "Ok";
 ?>
 --EXPECTF--
-Deprecated: Function Imagick::transformimage() is deprecated in %s
+Deprecated: %s Imagick::transformimage() is deprecated in %s
 Ok
diff --git a/tests/177_ImagickDraw_composite_basic.phpt b/tests/177_ImagickDraw_composite_basic.phpt
index 3c87524..00bd1a3 100644
--- a/tests/177_ImagickDraw_composite_basic.phpt
+++ b/tests/177_ImagickDraw_composite_basic.phpt
@@ -8,6 +8,8 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
@@ -16,6 +18,8 @@ function composite($strokeColor, $fillColor, $backgroundColor) {
 
     $draw = new \ImagickDraw();
 
+    setFontForImagickDraw($draw);
+
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
     $draw->setFillOpacity(1);
diff --git a/tests/180_ImagickDraw_matte_basic.phpt b/tests/180_ImagickDraw_matte_basic.phpt
index 88befea..b2ea71a 100644
--- a/tests/180_ImagickDraw_matte_basic.phpt
+++ b/tests/180_ImagickDraw_matte_basic.phpt
@@ -41,5 +41,5 @@ matte($strokeColor, $fillColor, $backgroundColor, $paintType) ;
 echo "Ok";
 ?>
 --EXPECTF--
-Deprecated: Function ImagickDraw::matte() is deprecated in %s
+Deprecated: %s ImagickDraw::matte() is deprecated in %s
 Ok
diff --git a/tests/206_ImagickDraw_setFontSize_basic.phpt b/tests/206_ImagickDraw_setFontSize_basic.phpt
index 9ac6d26..97b34b5 100644
--- a/tests/206_ImagickDraw_setFontSize_basic.phpt
+++ b/tests/206_ImagickDraw_setFontSize_basic.phpt
@@ -8,6 +8,8 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
@@ -16,6 +18,8 @@ function setFontSize($fillColor, $strokeColor, $backgroundColor) {
 
     $draw = new \ImagickDraw();
 
+    setFontForImagickDraw($draw);
+
     $draw->setStrokeOpacity(1);
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
diff --git a/tests/207_ImagickDraw_setFontFamily_basic.phpt b/tests/207_ImagickDraw_setFontFamily_basic.phpt
index 230e77c..cf4ad1c 100644
--- a/tests/207_ImagickDraw_setFontFamily_basic.phpt
+++ b/tests/207_ImagickDraw_setFontFamily_basic.phpt
@@ -8,6 +8,8 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
@@ -15,6 +17,7 @@ $fillColor = 'DodgerBlue2';
 function setFontFamily($fillColor, $strokeColor, $backgroundColor) {
 
     $draw = new \ImagickDraw();
+    setFontForImagickDraw($draw);
 
     $strokeColor = new \ImagickPixel($strokeColor);
     $fillColor = new \ImagickPixel($fillColor);
diff --git a/tests/208_ImagickDraw_setFontStretch_basic.phpt b/tests/208_ImagickDraw_setFontStretch_basic.phpt
index af3cb92..08c2d9e 100644
--- a/tests/208_ImagickDraw_setFontStretch_basic.phpt
+++ b/tests/208_ImagickDraw_setFontStretch_basic.phpt
@@ -8,6 +8,8 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
@@ -15,6 +17,7 @@ $fillColor = 'DodgerBlue2';
 function setFontStretch($fillColor, $strokeColor, $backgroundColor) {
 
     $draw = new \ImagickDraw();
+    setFontForImagickDraw($draw);
 
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
diff --git a/tests/209_ImagickDraw_setFontWeight_basic.phpt b/tests/209_ImagickDraw_setFontWeight_basic.phpt
index e98dc27..7fe9a6a 100644
--- a/tests/209_ImagickDraw_setFontWeight_basic.phpt
+++ b/tests/209_ImagickDraw_setFontWeight_basic.phpt
@@ -8,6 +8,8 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
@@ -15,6 +17,7 @@ $fillColor = 'DodgerBlue2';
 function setFontWeight($fillColor, $strokeColor, $backgroundColor) {
 
     $draw = new \ImagickDraw();
+    setFontForImagickDraw($draw);
 
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
diff --git a/tests/210_ImagickDraw_setFontStyle_basic.phpt b/tests/210_ImagickDraw_setFontStyle_basic.phpt
index 920cce2..0bbc882 100644
--- a/tests/210_ImagickDraw_setFontStyle_basic.phpt
+++ b/tests/210_ImagickDraw_setFontStyle_basic.phpt
@@ -8,12 +8,16 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
 
 function setFontStyle($fillColor, $strokeColor, $backgroundColor) {
     $draw = new \ImagickDraw();
+    setFontForImagickDraw($draw);
+
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
     $draw->setStrokeWidth(1);
diff --git a/tests/212_ImagickDraw_setGravity_basic.phpt b/tests/212_ImagickDraw_setGravity_basic.phpt
index b6ad07d..a803e1d 100644
--- a/tests/212_ImagickDraw_setGravity_basic.phpt
+++ b/tests/212_ImagickDraw_setGravity_basic.phpt
@@ -8,6 +8,8 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
@@ -15,6 +17,7 @@ $fillColor = 'DodgerBlue2';
 function setGravity($fillColor, $strokeColor, $backgroundColor) {
 
     $draw = new \ImagickDraw();
+    setFontForImagickDraw($draw);
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
     $draw->setStrokeWidth(1);
diff --git a/tests/222_ImagickDraw_setTextAlignment_basic.phpt b/tests/222_ImagickDraw_setTextAlignment_basic.phpt
index bda8249..939e473 100644
--- a/tests/222_ImagickDraw_setTextAlignment_basic.phpt
+++ b/tests/222_ImagickDraw_setTextAlignment_basic.phpt
@@ -8,12 +8,15 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
 
 function setTextAlignment($strokeColor, $fillColor, $backgroundColor) {
     $draw = new \ImagickDraw();
+    setFontForImagickDraw($draw);
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
     $draw->setStrokeWidth(1);
diff --git a/tests/223_ImagickDraw_setTextAntialias_basic.phpt b/tests/223_ImagickDraw_setTextAntialias_basic.phpt
index 0c9bcaf..e7cd7f2 100644
--- a/tests/223_ImagickDraw_setTextAntialias_basic.phpt
+++ b/tests/223_ImagickDraw_setTextAntialias_basic.phpt
@@ -8,6 +8,8 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
@@ -15,6 +17,7 @@ $fillColor = 'DodgerBlue2';
 function setTextAntialias($fillColor, $backgroundColor) {
 
     $draw = new \ImagickDraw();
+    setFontForImagickDraw($draw);
     $draw->setStrokeColor('none');
     $draw->setFillColor($fillColor);
     $draw->setStrokeWidth(1);
diff --git a/tests/224_ImagickDraw_setTextUnderColor_basic.phpt b/tests/224_ImagickDraw_setTextUnderColor_basic.phpt
index 69a788e..141eacc 100644
--- a/tests/224_ImagickDraw_setTextUnderColor_basic.phpt
+++ b/tests/224_ImagickDraw_setTextUnderColor_basic.phpt
@@ -8,6 +8,8 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
@@ -15,6 +17,7 @@ $textUnderColor = 'DeepPink2';
 
 function setTextUnderColor($strokeColor, $fillColor, $backgroundColor, $textUnderColor) {
     $draw = new \ImagickDraw();
+    setFontForImagickDraw($draw);
 
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
diff --git a/tests/225_ImagickDraw_setTextDecoration_basic.phpt b/tests/225_ImagickDraw_setTextDecoration_basic.phpt
index 5479971..b656158 100644
--- a/tests/225_ImagickDraw_setTextDecoration_basic.phpt
+++ b/tests/225_ImagickDraw_setTextDecoration_basic.phpt
@@ -8,6 +8,8 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
@@ -16,6 +18,7 @@ $textDecoration = 2;
 function setTextDecoration($strokeColor, $fillColor, $backgroundColor, $textDecoration) {
 
     $draw = new \ImagickDraw();
+    setFontForImagickDraw($draw);
 
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
diff --git a/tests/241_Tutorial_psychedelicFont_basic.phpt b/tests/241_Tutorial_psychedelicFont_basic.phpt
index b2e9873..9a9eba3 100644
--- a/tests/241_Tutorial_psychedelicFont_basic.phpt
+++ b/tests/241_Tutorial_psychedelicFont_basic.phpt
@@ -8,9 +8,11 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
 
 function psychedelicFont() {
     $draw = new \ImagickDraw();
+    setFontForImagickDraw($draw);
     $name = 'Danack';
 
     $draw->setStrokeOpacity(1);
diff --git a/tests/244_Tutorial_psychedelicFontGif_basic.phpt b/tests/244_Tutorial_psychedelicFontGif_basic.phpt
index f03bdf7..3fde1d7 100644
--- a/tests/244_Tutorial_psychedelicFontGif_basic.phpt
+++ b/tests/244_Tutorial_psychedelicFontGif_basic.phpt
@@ -8,6 +8,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
 
 function psychedelicFontGif($name = 'Danack') {
 
@@ -22,6 +23,7 @@ function psychedelicFontGif($name = 'Danack') {
     for ($frame = 0; $frame < $maxFrames; $frame++) {
 
         $draw = new \ImagickDraw();
+        setFontForImagickDraw($draw);
 
         $draw->setStrokeOpacity(1);
         $draw->setfontsize(150 * $scale);
diff --git a/tests/256_Imagick_exportImagePixels_basic.phpt b/tests/256_Imagick_exportImagePixels_basic.phpt
index d3eceb5..96a57b9 100644
--- a/tests/256_Imagick_exportImagePixels_basic.phpt
+++ b/tests/256_Imagick_exportImagePixels_basic.phpt
@@ -2,7 +2,7 @@
 Test Imagick, Imagick::exportImagePixels
 --SKIPIF--
 <?php
-$imageMagickRequiredVersion=0x675;
+$imageMagickRequiredVersion=0x687;
 require_once(dirname(__FILE__) . '/skipif.inc');
 ?>
 --FILE--
diff --git a/tests/264_ImagickDraw_getTextDirection_basic.phpt b/tests/264_ImagickDraw_getTextDirection_basic.phpt
index 8dbcbcd..210d99a 100644
--- a/tests/264_ImagickDraw_getTextDirection_basic.phpt
+++ b/tests/264_ImagickDraw_getTextDirection_basic.phpt
@@ -8,6 +8,8 @@ checkClassMethods('ImagickDraw', array('getTextDirection', 'setTextDirection'));
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
@@ -15,6 +17,7 @@ $fillColor = 'DodgerBlue2';
 
 
 $draw = new \ImagickDraw();
+setFontForImagickDraw($draw);
 
 $draw->setStrokeColor($strokeColor);
 $draw->setFillColor($fillColor);
diff --git a/tests/266_ImagickDraw_getFontResolution_basic.phpt b/tests/266_ImagickDraw_getFontResolution_basic.phpt
index 43a2e46..31bccfc 100644
--- a/tests/266_ImagickDraw_getFontResolution_basic.phpt
+++ b/tests/266_ImagickDraw_getFontResolution_basic.phpt
@@ -8,13 +8,15 @@ checkClassMethods('ImagickDraw', array('getFontResolution', 'setFontResolution')
 --FILE--
 <?php
 
+require_once(dirname(__FILE__) . '/functions.inc');
+
 $backgroundColor = 'rgb(225, 225, 225)';
 $strokeColor = 'rgb(0, 0, 0)';
 $fillColor = 'DodgerBlue2';
 
 
-
 $draw = new \ImagickDraw();
+setFontForImagickDraw($draw);
 
 $draw->setStrokeColor($strokeColor);
 $draw->setFillColor($fillColor);
diff --git a/tests/274_imagick_setImageAlpha.phpt b/tests/274_imagick_setImageAlpha.phpt
index 28f1ef1..760f088 100644
--- a/tests/274_imagick_setImageAlpha.phpt
+++ b/tests/274_imagick_setImageAlpha.phpt
@@ -8,6 +8,10 @@ require_once(dirname(__FILE__) . '/skipif.inc');
 --FILE--
 <?php
 
+require_once __DIR__ . "/../util/functions.php";
+
+
+
 $imagick = new Imagick();
 $imagick->newPseudoImage(256, 256, 'xc:purple');
 $imagick->setImageAlpha(0.5);
@@ -18,19 +22,47 @@ $imagick->writeImage("./setAlphaTest.png");
 $pixelTypes = array(
 	Imagick::PIXEL_CHAR => array(128, 0, 128, 128),
 	Imagick::PIXEL_FLOAT => array(0.50196081399918, 0, 0.50196081399918, 0.5),
-	Imagick::PIXEL_DOUBLE => array(0.50196078431373, 0, 0.50196078431373, 0.5),
+    Imagick::PIXEL_DOUBLE => array(0.50196078431373, 0, 0.50196078431373, 0.5),
 	Imagick::PIXEL_SHORT => array(32896, 0, 32896, 32768),
 );
 
+function getColorError($type, $expected, $actual) {
+
+    if ($type == Imagick::PIXEL_CHAR ||
+        $type == Imagick::PIXEL_SHORT) {
+        $string  = "Expected: " . $actual . "\n";
+        $string .= "Actual  : " . $actual . "\n";
+
+        return $string;
+    }
+
+    if ($type == Imagick::PIXEL_FLOAT) {
+        return float_compare_32($expected, $actual);
+    }
+
+    if ($type == Imagick::PIXEL_DOUBLE) {
+        return float_compare($expected, $actual);
+    }
+
+    echo "Unknown type: $type \n";
+    exit(-1);
+
+}
+
 
 foreach ($pixelTypes as $pixelType => $expectedValues) {
 	$pixels = $imagick->exportImagePixels(0, 0, 1, 1, "RGBA", $pixelType);
-	for ($i=0; $i<4; $i++) {
-		$actual = $pixels[$i];
-		$expected = $expectedValues[$i];
+	$channelNames = ['R', 'G', 'B', 'A'];
+
+	// Loop over the colours
+	for ($channel=0; $channel<4; $channel++) {
+		$actual = $pixels[$channel];
+		$expected = $expectedValues[$channel];
 		if (abs($actual - $expected) > 0.0000001) {
-			echo "Pixel values appear incorrect for pixelType $pixelType:";
-			var_dump($pixels);
+		    $channelName = $channelNames[$channel];
+
+			echo "Pixel values appear incorrect for pixelType $pixelType channel:$channelName\n";
+            echo getColorError($pixelType, $expected, $actual);
 			break;
 		}
 	}
diff --git a/tests/279_ImagickDraw_setTextInterlineSpacing.phpt b/tests/279_ImagickDraw_setTextInterlineSpacing.phpt
index 27250e3..c7e6462 100644
--- a/tests/279_ImagickDraw_setTextInterlineSpacing.phpt
+++ b/tests/279_ImagickDraw_setTextInterlineSpacing.phpt
@@ -23,6 +23,8 @@ foreach ($interlineSpacings as $interlineSpacing) {
 
     $draw = new \ImagickDraw();
 
+    setFontForImagickDraw($draw);
+
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
 
diff --git a/tests/281_ini_settings_default.phpt b/tests/281_ini_settings_default.phpt
new file mode 100644
index 0000000..e397e98
--- /dev/null
+++ b/tests/281_ini_settings_default.phpt
@@ -0,0 +1,29 @@
+--TEST--
+OpenMP segfault hacks
+--SKIPIF--
+<?php 
+
+
+require_once(dirname(__FILE__) . '/skipif.inc');
+ 
+?>
+--FILE--
+<?php
+
+
+$sleepCount = ini_get('imagick.shutdown_sleep_count');
+$setSingleThread = ini_get('imagick.set_single_thread');
+
+if ($sleepCount != 10) {
+    echo "imagick.shutdown_sleep_count is not set to 10 but instead " . var_export($sleepCount, true) ."\n";
+}
+
+if ($setSingleThread != 0) {
+    echo "imagick.set_single_thread setting is not false but instead " . var_export($setSingleThread, true) ."\n";
+}
+
+
+echo "Complete".PHP_EOL;
+?>
+--EXPECTF--
+Complete
diff --git a/tests/282_ini_settings_set_falsy_string.phpt b/tests/282_ini_settings_set_falsy_string.phpt
new file mode 100644
index 0000000..4ed4f1d
--- /dev/null
+++ b/tests/282_ini_settings_set_falsy_string.phpt
@@ -0,0 +1,41 @@
+--TEST--
+OpenMP segfault hacks
+
+--INI--
+imagick.shutdown_sleep_count=Off
+imagick.set_single_thread=0
+--SKIPIF--
+<?php 
+
+
+require_once(dirname(__FILE__) . '/skipif.inc');
+ 
+?>
+--FILE--
+<?php
+
+
+// So, this can't be tested for properly. ini values are stored as strings internally
+// to PHP, and are not normalised to the actual type used by an extension. Which means
+// you can't easily get the actual value being used by an extension, when the input
+// type isn't the same type as the extension is going to use it as.
+// aka 'Off' is stored as '' not 0.
+//
+//$sleepCount = ini_get('imagick.shutdown_sleep_count');
+//if ($sleepCount !== 0) {
+//    echo "imagick.shutdown_sleep_count is not set to 0 but instead " . var_export($sleepCount, true) ."\n";
+//}
+
+$setSingleThread = ini_get('imagick.set_single_thread');
+
+// This should be a strict compare but can't be because
+// it's stored as a string...
+if ($setSingleThread != 0) {
+    echo "imagick.set_single_thread setting is not 0 but instead " . var_export($setSingleThread, true) ."\n";
+}
+
+
+echo "Complete".PHP_EOL;
+?>
+--EXPECTF--
+Complete
diff --git a/tests/283_ini_settings_set_falsy_zero.phpt b/tests/283_ini_settings_set_falsy_zero.phpt
new file mode 100644
index 0000000..8e41a35
--- /dev/null
+++ b/tests/283_ini_settings_set_falsy_zero.phpt
@@ -0,0 +1,33 @@
+--TEST--
+OpenMP segfault hacks
+
+--INI--
+imagick.shutdown_sleep_count=0
+imagick.set_single_thread=0
+--SKIPIF--
+<?php 
+
+
+require_once(dirname(__FILE__) . '/skipif.inc');
+ 
+?>
+--FILE--
+<?php
+
+
+$sleepCount = ini_get('imagick.shutdown_sleep_count');
+$setSingleThread = ini_get('imagick.set_single_thread');
+
+if ($sleepCount != 0) {
+    echo "imagick.shutdown_sleep_count is not set to 10 but instead " . var_export($sleepCount, true) ."\n";
+}
+
+if ($setSingleThread != 0) {
+    echo "imagick.set_single_thread setting is not false but instead " . var_export($sleepCount, true) ."\n";
+}
+
+
+echo "Complete".PHP_EOL;
+?>
+--EXPECTF--
+Complete
diff --git a/tests/284_ini_settings_set_truthy_number.phpt b/tests/284_ini_settings_set_truthy_number.phpt
new file mode 100644
index 0000000..fc0a0bb
--- /dev/null
+++ b/tests/284_ini_settings_set_truthy_number.phpt
@@ -0,0 +1,33 @@
+--TEST--
+OpenMP segfault hacks
+
+--INI--
+imagick.shutdown_sleep_count=20
+imagick.set_single_thread=1
+--SKIPIF--
+<?php 
+
+
+require_once(dirname(__FILE__) . '/skipif.inc');
+ 
+?>
+--FILE--
+<?php
+
+
+$sleepCount = intval(ini_get('imagick.shutdown_sleep_count'));
+$setSingleThread = ini_get('imagick.set_single_thread');
+
+if ($sleepCount != 20) {
+    echo "imagick.shutdown_sleep_count is not set to 10 but instead " . var_export($sleepCount, true) ."\n";
+}
+
+if ($setSingleThread != 1) {
+    echo "imagick.set_single_thread setting is not true but instead " . var_export($setSingleThread, true) ."\n";
+}
+
+
+echo "Complete".PHP_EOL;
+?>
+--EXPECTF--
+Complete
diff --git a/tests/285_ini_settings_set_truthy_string.phpt b/tests/285_ini_settings_set_truthy_string.phpt
new file mode 100644
index 0000000..c35a213
--- /dev/null
+++ b/tests/285_ini_settings_set_truthy_string.phpt
@@ -0,0 +1,33 @@
+--TEST--
+OpenMP segfault hacks
+
+--INI--
+imagick.shutdown_sleep_count=On
+imagick.set_single_thread=On
+--SKIPIF--
+<?php 
+
+
+require_once(dirname(__FILE__) . '/skipif.inc');
+ 
+?>
+--FILE--
+<?php
+
+
+$sleepCount = intval(ini_get('imagick.shutdown_sleep_count'));
+$setSingleThread = ini_get('imagick.set_single_thread');
+
+if ($sleepCount != 1) {
+    echo "imagick.shutdown_sleep_count is not set to 1 but instead " . var_export($sleepCount, true) ."\n";
+}
+
+if ($setSingleThread != 1) {
+    echo "imagick.set_single_thread setting is not true but instead " . var_export($setSingleThread, true) ."\n";
+}
+
+
+echo "Complete".PHP_EOL;
+?>
+--EXPECTF--
+Complete
diff --git a/tests/bug20636.phpt b/tests/bug20636.phpt
index adba98a..eb64b39 100644
--- a/tests/bug20636.phpt
+++ b/tests/bug20636.phpt
@@ -27,5 +27,5 @@ try {
 
 ?>
 --EXPECTF--
-Deprecated: Function Imagick::roundcorners() is deprecated in %s
+Deprecated: %s Imagick::roundcorners() is deprecated in %s
 success
diff --git a/tests/functions.inc b/tests/functions.inc
index f5c1ef1..5fa3d2f 100644
--- a/tests/functions.inc
+++ b/tests/functions.inc
@@ -61,5 +61,52 @@ function isVersionGreaterEqual($testIm6Version, $im7Version)
     return false;
 }
 
+/**
+ * On some systems, where the standard fonts aren't available, trying
+ * to draw any text fails as the ImageMagick default font is null.
+ *
+ * This function just find a 'sensible' font to use, either from the
+ * preferred list, or just the first one from queryFonts(). That 'probably'
+ * is the right thing to do, as it makes the tests more stable.
+ */
+function findDefaultFont()
+{
+    $knownFonts = [
+        'Courier',
+        'Helvetica',
+        'Times-Roman',
+        'Liberation-Mono',
+        'Utopia',
+    ];
+
+    $fontList = \Imagick::queryFonts();
+
+    foreach ($knownFonts as $knownFont) {
+
+        if (in_array($knownFont, $fontList, true) === true) {
+            return $knownFont;
+        }
+    }
+
+    if (count($fontList) !== 0) {
+        return $fontList[0];
+    }
 
+    throw new \Exception("No fonts available on system, apparently.");
+}
 
+// Find and set a font for the Imagick object
+function setFontForImagick(\Imagick $imagick)
+{
+    $font = findDefaultFont();
+
+    $imagick->setFont($font);
+}
+
+// Find and set a font for the ImagickDraw object
+function setFontForImagickDraw(\ImagickDraw $imagickDraw)
+{
+    $font = findDefaultFont();
+
+    $imagickDraw->setFont($font);
+}