rmagick 2.15.3 → 2.15.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rmagick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.editorconfig +14 -0
- data/.rubocop.yml +27 -3
- data/.travis.yml +9 -6
- data/CHANGELOG.md +4 -0
- data/CONTRIBUTING.md +10 -0
- data/README.textile +4 -0
- data/before_install_linux.sh +4 -4
- data/doc/ex/gravity.rb +2 -1
- data/ext/RMagick/extconf.rb +60 -17
- data/lib/rmagick/version.rb +1 -1
- data/lib/rvg/clippath.rb +37 -36
- data/lib/rvg/container.rb +106 -107
- data/lib/rvg/deep_equal.rb +46 -48
- data/lib/rvg/describable.rb +35 -36
- data/lib/rvg/embellishable.rb +384 -380
- data/lib/rvg/misc.rb +705 -690
- data/lib/rvg/paint.rb +39 -40
- data/lib/rvg/pathdata.rb +120 -121
- data/lib/rvg/rvg.rb +212 -209
- data/lib/rvg/stretchable.rb +159 -158
- data/lib/rvg/stylable.rb +99 -100
- data/lib/rvg/text.rb +0 -1
- data/lib/rvg/transformable.rb +110 -110
- data/lib/rvg/units.rb +58 -58
- data/rmagick.gemspec +1 -1
- data/spec/rmagick/image/blue_shift_spec.rb +16 -0
- data/spec/rmagick/image/composite_spec.rb +140 -0
- data/spec/rmagick/image/constitute_spec.rb +15 -0
- data/spec/rmagick/image/dispatch_spec.rb +18 -0
- data/spec/rmagick/image/from_blob_spec.rb +14 -0
- data/spec/rmagick/image/ping_spec.rb +14 -0
- data/spec/rmagick/image/properties_spec.rb +29 -0
- data/spec/spec_helper.rb +3 -0
- data/test/Image1.rb +524 -718
- data/test/Image2.rb +1262 -1262
- data/test/Image3.rb +973 -973
- data/test/ImageList2.rb +341 -341
- data/test/Image_attributes.rb +678 -678
- data/test/Info.rb +336 -336
- data/test/Magick.rb +245 -242
- data/test/Pixel.rb +105 -105
- data/test/Preview.rb +42 -42
- metadata +21 -6
data/test/Image3.rb
CHANGED
@@ -48,979 +48,979 @@ Filters = [
|
|
48
48
|
]
|
49
49
|
|
50
50
|
class Image3_UT < Test::Unit::TestCase
|
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
|
-
|
51
|
+
FreezeError = RUBY_VERSION[/^1\.9|^2/] ? RuntimeError : TypeError
|
52
|
+
|
53
|
+
def setup
|
54
|
+
@img = Magick::Image.new(20, 20)
|
55
|
+
@p = Magick::Image.read(IMAGE_WITH_PROFILE).first.color_profile
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_profile!
|
59
|
+
assert_nothing_raised do
|
60
|
+
res = @img.profile!('*', nil)
|
61
|
+
assert_same(@img, res)
|
62
|
+
end
|
63
|
+
assert_nothing_raised { @img.profile!('icc', @p) }
|
64
|
+
assert_nothing_raised { @img.profile!('iptc', 'xxx') }
|
65
|
+
assert_nothing_raised { @img.profile!('icc', nil) }
|
66
|
+
assert_nothing_raised { @img.profile!('iptc', nil) }
|
67
|
+
|
68
|
+
@img.freeze
|
69
|
+
assert_raise(FreezeError) { @img.profile!('icc', 'xxx') }
|
70
|
+
assert_raise(FreezeError) { @img.profile!('*', nil) }
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_quantize
|
74
|
+
assert_nothing_raised do
|
75
|
+
res = @img.quantize
|
76
|
+
assert_instance_of(Magick::Image, res)
|
77
|
+
end
|
78
|
+
|
79
|
+
ColorspaceTypes.each do |cs|
|
80
|
+
assert_nothing_raised { @img.quantize(256, cs) }
|
81
|
+
end
|
82
|
+
assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, false) }
|
83
|
+
assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, true) }
|
84
|
+
assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, Magick::NoDitherMethod) }
|
85
|
+
assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, Magick::RiemersmaDitherMethod) }
|
86
|
+
assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, Magick::FloydSteinbergDitherMethod) }
|
87
|
+
assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, true, 2) }
|
88
|
+
assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, true, 2, true) }
|
89
|
+
assert_raise(TypeError) { @img.quantize('x') }
|
90
|
+
assert_raise(TypeError) { @img.quantize(16, 2) }
|
91
|
+
assert_raise(TypeError) { @img.quantize(16, Magick::RGBColorspace, false, 'x') }
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_quantum_operator
|
95
|
+
quantum_ops = [
|
96
|
+
Magick::AddQuantumOperator,
|
97
|
+
Magick::AndQuantumOperator,
|
98
|
+
Magick::DivideQuantumOperator,
|
99
|
+
Magick::LShiftQuantumOperator,
|
100
|
+
Magick::MultiplyQuantumOperator,
|
101
|
+
Magick::OrQuantumOperator,
|
102
|
+
Magick::RShiftQuantumOperator,
|
103
|
+
Magick::SubtractQuantumOperator,
|
104
|
+
Magick::XorQuantumOperator ]
|
105
|
+
|
106
|
+
assert_nothing_raised do
|
107
|
+
res = @img.quantum_operator(Magick::AddQuantumOperator, 2)
|
108
|
+
assert_instance_of(Magick::Image, res)
|
109
|
+
end
|
110
|
+
quantum_ops.each do |op|
|
111
|
+
assert_nothing_raised { @img.quantum_operator(op, 2) }
|
112
|
+
end
|
113
|
+
assert_nothing_raised { @img.quantum_operator(Magick::AddQuantumOperator, 2, Magick::RedChannel) }
|
114
|
+
assert_raise(TypeError) { @img.quantum_operator(2, 2) }
|
115
|
+
assert_raise(TypeError) { @img.quantum_operator(Magick::AddQuantumOperator, 'x') }
|
116
|
+
assert_raise(TypeError) { @img.quantum_operator(Magick::AddQuantumOperator, 2, 2) }
|
117
|
+
assert_raise(ArgumentError) { @img.quantum_operator(Magick::AddQuantumOperator, 2, Magick::RedChannel, 2) }
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_radial_blur
|
121
|
+
assert_nothing_raised do
|
122
|
+
res = @img.radial_blur(30)
|
123
|
+
assert_instance_of(Magick::Image, res)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_radial_blur_channel
|
128
|
+
res = nil
|
129
|
+
assert_nothing_raised { res = @img.radial_blur_channel(30) }
|
130
|
+
assert_not_nil(res)
|
131
|
+
assert_instance_of(Magick::Image, res)
|
132
|
+
assert_nothing_raised { res = @img.radial_blur_channel(30, Magick::RedChannel) }
|
133
|
+
assert_nothing_raised { res = @img.radial_blur_channel(30, Magick::RedChannel, Magick::BlueChannel) }
|
134
|
+
|
135
|
+
assert_raise(ArgumentError) { @img.radial_blur_channel }
|
136
|
+
assert_raise(TypeError) { @img.radial_blur_channel(30, 2) }
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_raise
|
140
|
+
assert_nothing_raised do
|
141
|
+
res = @img.raise
|
142
|
+
assert_instance_of(Magick::Image, res)
|
143
|
+
end
|
144
|
+
assert_nothing_raised { @img.raise(4) }
|
145
|
+
assert_nothing_raised { @img.raise(4,4) }
|
146
|
+
assert_nothing_raised { @img.raise(4,4, false) }
|
147
|
+
assert_raise(TypeError) { @img.raise('x') }
|
148
|
+
assert_raise(TypeError) { @img.raise(2, 'x') }
|
149
|
+
assert_raise(ArgumentError) { @img.raise(4, 4, false, 2) }
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_random_threshold_channel
|
153
|
+
assert_nothing_raised do
|
154
|
+
res = @img.random_threshold_channel('20%')
|
155
|
+
assert_instance_of(Magick::Image, res)
|
156
|
+
end
|
157
|
+
threshold = Magick::Geometry.new(20)
|
158
|
+
assert_nothing_raised { @img.random_threshold_channel(threshold) }
|
159
|
+
assert_nothing_raised { @img.random_threshold_channel(threshold, Magick::RedChannel) }
|
160
|
+
assert_nothing_raised { @img.random_threshold_channel(threshold, Magick::RedChannel, Magick::BlueChannel) }
|
161
|
+
assert_raise(ArgumentError) { @img.random_threshold_channel }
|
162
|
+
assert_raise(TypeError) { @img.random_threshold_channel('20%', 2) }
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_reduce_noise
|
166
|
+
assert_nothing_raised do
|
167
|
+
res = @img.reduce_noise(0)
|
168
|
+
assert_instance_of(Magick::Image, res)
|
169
|
+
end
|
170
|
+
assert_nothing_raised { @img.reduce_noise(4) }
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_remap
|
174
|
+
remap_image = Magick::Image.new(20,20) {self.background_color = 'green'}
|
175
|
+
assert_nothing_raised { @img.remap(remap_image) }
|
176
|
+
assert_nothing_raised { @img.remap(remap_image, Magick::NoDitherMethod) }
|
177
|
+
assert_nothing_raised { @img.remap(remap_image, Magick::RiemersmaDitherMethod) }
|
178
|
+
assert_nothing_raised { @img.remap(remap_image, Magick::FloydSteinbergDitherMethod) }
|
179
|
+
|
180
|
+
assert_raise(ArgumentError) {@img.remap }
|
181
|
+
assert_raise(ArgumentError) {@img.remap(remap_image, Magick::NoDitherMethod, 1) }
|
182
|
+
assert_raise(TypeError) {@img.remap(remap_image, 1) }
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_resample
|
186
|
+
@img.x_resolution = 72
|
187
|
+
@img.y_resolution = 72
|
188
|
+
assert_nothing_raised { @img.resample }
|
189
|
+
assert_nothing_raised { @img.resample(100) }
|
190
|
+
assert_nothing_raised { @img.resample(100, 100) }
|
191
|
+
|
192
|
+
@img.x_resolution = 0
|
193
|
+
@img.y_resolution = 0
|
194
|
+
assert_nothing_raised { @img.resample }
|
195
|
+
assert_nothing_raised { @img.resample(100) }
|
196
|
+
assert_nothing_raised { @img.resample(100, 100) }
|
197
|
+
|
198
|
+
girl = Magick::Image.read(IMAGES_DIR+'/Flower_Hat.jpg').first
|
199
|
+
assert_equal(240.0, girl.x_resolution)
|
200
|
+
assert_equal(240.0, girl.y_resolution)
|
201
|
+
res = girl.resample(120, 120)
|
202
|
+
assert_equal(100, res.columns)
|
203
|
+
assert_equal(125, res.rows)
|
204
|
+
assert_equal(120.0, res.x_resolution)
|
205
|
+
assert_equal(120.0, res.y_resolution)
|
206
|
+
assert_equal(200, girl.columns)
|
207
|
+
assert_equal(250, girl.rows)
|
208
|
+
assert_equal(240.0, girl.x_resolution)
|
209
|
+
assert_equal(240.0, girl.y_resolution)
|
210
|
+
|
211
|
+
Filters.each do |filter|
|
212
|
+
assert_nothing_raised { @img.resample(50, 50, filter) }
|
213
|
+
end
|
214
|
+
assert_nothing_raised { @img.resample(50, 50, Magick::PointFilter, 2.0) }
|
215
|
+
|
216
|
+
assert_raise(TypeError) { @img.resample('x') }
|
217
|
+
assert_raise(TypeError) { @img.resample(100, 'x') }
|
218
|
+
assert_raise(TypeError) { @img.resample(50, 50, 2) }
|
219
|
+
assert_raise(TypeError) { @img.resample(50, 50, Magick::CubicFilter, 'x') }
|
220
|
+
assert_raise(ArgumentError) { @img.resample(50, 50, Magick::SincFilter, 2.0, 'x') }
|
221
|
+
assert_raise(ArgumentError) { @img.resample(-100) }
|
222
|
+
assert_raise(ArgumentError) { @img.resample(100, -100) }
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_resample!
|
226
|
+
assert_nothing_raised do
|
227
|
+
res = @img.resample!(50)
|
228
|
+
assert_same(@img, res)
|
229
|
+
end
|
230
|
+
@img.freeze
|
231
|
+
assert_raise(FreezeError) { @img.resample!(50) }
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_resize
|
235
|
+
assert_nothing_raised do
|
236
|
+
res = @img.resize(2)
|
237
|
+
assert_instance_of(Magick::Image, res)
|
238
|
+
end
|
239
|
+
assert_nothing_raised { @img.resize(50,50) }
|
240
|
+
|
241
|
+
Filters.each do |filter|
|
242
|
+
assert_nothing_raised { @img.resize(50, 50, filter) }
|
243
|
+
end
|
244
|
+
assert_nothing_raised { @img.resize(50, 50, Magick::PointFilter, 2.0) }
|
245
|
+
assert_raise(TypeError) { @img.resize('x') }
|
246
|
+
assert_raise(TypeError) { @img.resize(50, 'x') }
|
247
|
+
assert_raise(TypeError) { @img.resize(50, 50, 2) }
|
248
|
+
assert_raise(TypeError) { @img.resize(50, 50, Magick::CubicFilter, 'x') }
|
249
|
+
assert_raise(ArgumentError) { @img.resize(50, 50, Magick::SincFilter, 2.0, 'x') }
|
250
|
+
assert_raise(ArgumentError) { @img.resize }
|
251
|
+
end
|
252
|
+
|
253
|
+
def test_resize!
|
254
|
+
assert_nothing_raised do
|
255
|
+
res = @img.resize!(2)
|
256
|
+
assert_same(@img, res)
|
257
|
+
end
|
258
|
+
@img.freeze
|
259
|
+
assert_raise(FreezeError) { @img.resize!(0.50) }
|
260
|
+
end
|
261
|
+
|
262
|
+
def test_resize_to_fill_0
|
263
|
+
changed = @img.resize_to_fill(@img.columns,@img.rows)
|
264
|
+
assert_equal(@img.columns, changed.columns)
|
265
|
+
assert_equal(@img.rows, changed.rows)
|
266
|
+
assert_not_same(changed, @img)
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_resize_to_fill_1
|
270
|
+
@img = Magick::Image.new(200, 250)
|
271
|
+
@img.resize_to_fill!(100,100)
|
272
|
+
assert_equal(100, @img.columns)
|
273
|
+
assert_equal(100, @img.rows)
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_resize_to_fill_2
|
277
|
+
@img = Magick::Image.new(200, 250)
|
278
|
+
changed = @img.resize_to_fill(300,100)
|
279
|
+
assert_equal(300, changed.columns)
|
280
|
+
assert_equal(100, changed.rows)
|
281
|
+
end
|
282
|
+
|
283
|
+
def test_resize_to_fill_3
|
284
|
+
@img = Magick::Image.new(200, 250)
|
285
|
+
changed = @img.resize_to_fill(100,300)
|
286
|
+
assert_equal(100, changed.columns)
|
287
|
+
assert_equal(300, changed.rows)
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_resize_to_fill_4
|
291
|
+
@img = Magick::Image.new(200, 250)
|
292
|
+
changed = @img.resize_to_fill(300,350)
|
293
|
+
assert_equal(300, changed.columns)
|
294
|
+
assert_equal(350, changed.rows)
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_resize_to_fill_5
|
298
|
+
changed = @img.resize_to_fill(20,400)
|
299
|
+
assert_equal(20, changed.columns)
|
300
|
+
assert_equal(400, changed.rows)
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_resize_to_fill_6
|
304
|
+
changed = @img.resize_to_fill(3000,400)
|
305
|
+
assert_equal(3000, changed.columns)
|
306
|
+
assert_equal(400, changed.rows)
|
307
|
+
end
|
308
|
+
|
309
|
+
# Make sure the old name is still around
|
310
|
+
def test_resize_to_fill_7
|
311
|
+
assert_block {@img.respond_to? :crop_resized}
|
312
|
+
assert_block {@img.respond_to? :crop_resized!}
|
313
|
+
end
|
314
|
+
|
315
|
+
# 2nd argument defaults to the same value as the 1st argument
|
316
|
+
def test_resize_to_fill_8
|
317
|
+
changed = @img.resize_to_fill(100)
|
318
|
+
assert_equal(100, changed.columns)
|
319
|
+
assert_equal(100, changed.rows)
|
320
|
+
end
|
321
|
+
|
322
|
+
def test_resize_to_fit
|
323
|
+
img = Magick::Image.new(200, 250)
|
324
|
+
res = nil
|
325
|
+
assert_nothing_raised { res = img.resize_to_fit(50, 50) }
|
326
|
+
assert_not_nil(res)
|
327
|
+
assert_instance_of(Magick::Image, res)
|
328
|
+
assert_not_same(img, res)
|
329
|
+
assert_equal(40, res.columns)
|
330
|
+
assert_equal(50, res.rows)
|
331
|
+
end
|
332
|
+
|
333
|
+
def test_resize_to_fit2
|
334
|
+
img = Magick::Image.new(200, 300)
|
335
|
+
changed = img.resize_to_fit(100)
|
336
|
+
assert_instance_of(Magick::Image, changed)
|
337
|
+
assert_not_same(img, changed)
|
338
|
+
assert_equal(67, changed.columns)
|
339
|
+
assert_equal(100, changed.rows)
|
340
|
+
end
|
341
|
+
|
342
|
+
def test_resize_to_fit3
|
343
|
+
img = Magick::Image.new(200, 300)
|
344
|
+
keep = img
|
345
|
+
img.resize_to_fit!(100)
|
346
|
+
assert_instance_of(Magick::Image, img)
|
347
|
+
assert_same(img, keep)
|
348
|
+
assert_equal(67, img.columns)
|
349
|
+
assert_equal(100, img.rows)
|
350
|
+
end
|
351
|
+
|
352
|
+
def test_roll
|
353
|
+
assert_nothing_raised do
|
354
|
+
res = @img.roll(5, 5)
|
355
|
+
assert_instance_of(Magick::Image, res)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
def test_rotate
|
360
|
+
assert_nothing_raised do
|
361
|
+
res = @img.rotate(45)
|
362
|
+
assert_instance_of(Magick::Image, res)
|
363
|
+
end
|
364
|
+
assert_nothing_raised { @img.rotate(-45) }
|
365
|
+
|
366
|
+
img = Magick::Image.new(100, 50)
|
367
|
+
assert_nothing_raised do
|
368
|
+
res = img.rotate(90, '>')
|
369
|
+
assert_instance_of(Magick::Image, res)
|
370
|
+
assert_equal(50, res.columns)
|
371
|
+
assert_equal(100, res.rows)
|
372
|
+
end
|
373
|
+
assert_nothing_raised do
|
374
|
+
res = img.rotate(90, '<')
|
375
|
+
assert_nil(res)
|
376
|
+
end
|
377
|
+
assert_raise(ArgumentError) { img.rotate(90, 't') }
|
378
|
+
assert_raise(TypeError) { img.rotate(90, []) }
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_rotate!
|
382
|
+
assert_nothing_raised do
|
383
|
+
res = @img.rotate!(45)
|
384
|
+
assert_same(@img, res)
|
385
|
+
end
|
386
|
+
@img.freeze
|
387
|
+
assert_raise(FreezeError) { @img.rotate!(45) }
|
388
|
+
end
|
389
|
+
|
390
|
+
def test_sample
|
391
|
+
assert_nothing_raised do
|
392
|
+
res = @img.sample(10, 10)
|
393
|
+
assert_instance_of(Magick::Image, res)
|
394
|
+
end
|
395
|
+
assert_nothing_raised { @img.sample(2) }
|
396
|
+
assert_raise(ArgumentError) { @img.sample }
|
397
|
+
assert_raise(ArgumentError) { @img.sample(25, 25, 25) }
|
398
|
+
assert_raise(TypeError) { @img.sample('x') }
|
399
|
+
assert_raise(TypeError) { @img.sample(10, 'x') }
|
400
|
+
end
|
401
|
+
|
402
|
+
def test_sample!
|
403
|
+
assert_nothing_raised do
|
404
|
+
res = @img.sample!(2)
|
405
|
+
assert_same(@img, res)
|
406
|
+
end
|
407
|
+
@img.freeze
|
408
|
+
assert_raise(FreezeError) { @img.sample!(0.50) }
|
409
|
+
end
|
410
|
+
|
411
|
+
def test_scale
|
412
|
+
assert_nothing_raised do
|
413
|
+
res = @img.scale(10, 10)
|
414
|
+
assert_instance_of(Magick::Image, res)
|
415
|
+
end
|
416
|
+
assert_nothing_raised { @img.scale(2) }
|
417
|
+
assert_raise(ArgumentError) { @img.scale }
|
418
|
+
assert_raise(ArgumentError) { @img.scale(25, 25, 25) }
|
419
|
+
assert_raise(TypeError) { @img.scale('x') }
|
420
|
+
assert_raise(TypeError) { @img.scale(10, 'x') }
|
421
|
+
end
|
422
|
+
|
423
|
+
def test_scale!
|
424
|
+
assert_nothing_raised do
|
425
|
+
res = @img.scale!(2)
|
426
|
+
assert_same(@img, res)
|
427
|
+
end
|
428
|
+
@img.freeze
|
429
|
+
assert_raise(FreezeError) { @img.scale!(0.50) }
|
430
|
+
end
|
431
|
+
|
432
|
+
def test_segment
|
433
|
+
assert_nothing_raised do
|
434
|
+
res = @img.segment
|
435
|
+
assert_instance_of(Magick::Image, res)
|
436
|
+
end
|
437
|
+
|
438
|
+
# Don't test colorspaces that require PsuedoColor images
|
439
|
+
(ColorspaceTypes - [Magick::OHTAColorspace,
|
440
|
+
Magick::LabColorspace,
|
441
|
+
Magick::XYZColorspace,
|
442
|
+
Magick::YCbCrColorspace,
|
443
|
+
Magick::YCCColorspace,
|
444
|
+
Magick::YIQColorspace,
|
445
|
+
Magick::YPbPrColorspace,
|
446
|
+
Magick::YUVColorspace,
|
447
|
+
Magick::Rec601YCbCrColorspace,
|
448
|
+
Magick::Rec709YCbCrColorspace,
|
449
|
+
Magick::LogColorspace]).each do |cs|
|
450
|
+
assert_nothing_raised { @img.segment(cs) }
|
451
|
+
end
|
452
|
+
|
453
|
+
assert_nothing_raised { @img.segment(Magick::RGBColorspace, 2.0) }
|
454
|
+
assert_nothing_raised { @img.segment(Magick::RGBColorspace, 2.0, 2.0) }
|
455
|
+
assert_nothing_raised { @img.segment(Magick::RGBColorspace, 2.0, 2.0, false) }
|
456
|
+
|
457
|
+
assert_raise(ArgumentError) { @img.segment(Magick::RGBColorspace, 2.0, 2.0, false, 2) }
|
458
|
+
assert_raise(TypeError) { @img.segment(2) }
|
459
|
+
assert_raise(TypeError) { @img.segment(Magick::RGBColorspace, 'x') }
|
460
|
+
assert_raise(TypeError) { @img.segment(Magick::RGBColorspace, 2.0, 'x') }
|
461
|
+
end
|
462
|
+
|
463
|
+
def test_selective_blur_channel
|
464
|
+
res = nil
|
465
|
+
assert_nothing_raised { res = @img.selective_blur_channel(0, 1, '10%') }
|
466
|
+
assert_instance_of(Magick::Image, res)
|
467
|
+
assert_not_same(@img, res)
|
468
|
+
assert_equal([@img.columns, @img.rows], [res.columns, res.rows])
|
469
|
+
|
470
|
+
assert_nothing_raised { @img.selective_blur_channel(0, 1, 0.1) }
|
471
|
+
assert_nothing_raised { @img.selective_blur_channel(0, 1, '10%', Magick::RedChannel) }
|
472
|
+
assert_nothing_raised { @img.selective_blur_channel(0, 1, '10%', Magick::RedChannel, Magick::BlueChannel) }
|
473
|
+
assert_nothing_raised { @img.selective_blur_channel(0, 1, '10%', Magick::RedChannel, Magick::BlueChannel, Magick::GreenChannel) }
|
474
|
+
# not enough arguments
|
475
|
+
assert_raise(ArgumentError) { @img.selective_blur_channel(0, 1) }
|
476
|
+
end
|
477
|
+
|
478
|
+
def test_sepiatone
|
479
|
+
assert_nothing_raised do
|
480
|
+
res = @img.sepiatone
|
481
|
+
assert_instance_of(Magick::Image, res)
|
482
|
+
end
|
483
|
+
assert_nothing_raised { @img.sepiatone(Magick::QuantumRange*0.80) }
|
484
|
+
assert_raise(ArgumentError) { @img.sepiatone(Magick::QuantumRange, 2) }
|
485
|
+
assert_raise(TypeError) { @img.sepiatone('x') }
|
486
|
+
end
|
487
|
+
|
488
|
+
def test_set_channel_depth
|
489
|
+
channels = [
|
490
|
+
Magick::RedChannel,
|
491
|
+
Magick::GrayChannel,
|
492
|
+
Magick::CyanChannel,
|
493
|
+
Magick::GreenChannel,
|
494
|
+
Magick::MagentaChannel,
|
495
|
+
Magick::BlueChannel,
|
496
|
+
Magick::YellowChannel,
|
497
|
+
# Magick::AlphaChannel,
|
498
|
+
Magick::OpacityChannel,
|
499
|
+
Magick::MatteChannel,
|
500
|
+
Magick::BlackChannel,
|
501
|
+
Magick::IndexChannel,
|
502
|
+
Magick::AllChannels]
|
503
|
+
|
504
|
+
channels.each do |ch|
|
505
|
+
assert_nothing_raised {@img.set_channel_depth(ch, 8) }
|
506
|
+
end
|
507
|
+
end
|
508
|
+
|
509
|
+
def test_shade
|
510
|
+
assert_nothing_raised do
|
511
|
+
res = @img.shade
|
512
|
+
assert_instance_of(Magick::Image, res)
|
513
|
+
end
|
514
|
+
assert_nothing_raised { @img.shade(true) }
|
515
|
+
assert_nothing_raised { @img.shade(true, 30) }
|
516
|
+
assert_nothing_raised { @img.shade(true, 30, 30) }
|
517
|
+
assert_raise(ArgumentError) { @img.shade(true, 30, 30, 2) }
|
518
|
+
assert_raise(TypeError) { @img.shade(true, 'x') }
|
519
|
+
assert_raise(TypeError) { @img.shade(true, 30, 'x') }
|
520
|
+
end
|
521
|
+
|
522
|
+
def test_shadow
|
523
|
+
assert_nothing_raised do
|
524
|
+
res = @img.shadow
|
525
|
+
assert_instance_of(Magick::Image, res)
|
526
|
+
end
|
527
|
+
assert_nothing_raised { @img.shadow(5) }
|
528
|
+
assert_nothing_raised { @img.shadow(5, 5) }
|
529
|
+
assert_nothing_raised { @img.shadow(5, 5, 3.0) }
|
530
|
+
assert_nothing_raised { @img.shadow(5, 5, 3.0, 0.50) }
|
531
|
+
assert_nothing_raised { @img.shadow(5, 5, 3.0, '50%') }
|
532
|
+
assert_raise(ArgumentError) { @img.shadow(5, 5, 3.0, 0.50, 2) }
|
533
|
+
assert_raise(TypeError) { @img.shadow('x') }
|
534
|
+
assert_raise(TypeError) { @img.shadow(5, 'x') }
|
535
|
+
assert_raise(TypeError) { @img.shadow(5, 5, 'x') }
|
536
|
+
assert_raise(ArgumentError) { @img.shadow(5, 5, 3.0, 'x') }
|
537
|
+
end
|
538
|
+
|
539
|
+
def test_sharpen
|
540
|
+
assert_nothing_raised do
|
541
|
+
res = @img.sharpen
|
542
|
+
assert_instance_of(Magick::Image, res)
|
543
|
+
end
|
544
|
+
assert_nothing_raised { @img.sharpen(2.0) }
|
545
|
+
assert_nothing_raised { @img.sharpen(2.0, 1.0) }
|
546
|
+
assert_raise(ArgumentError) { @img.sharpen(2.0, 1.0, 2) }
|
547
|
+
assert_raise(TypeError) { @img.sharpen('x') }
|
548
|
+
assert_raise(TypeError) { @img.sharpen(2.0, 'x') }
|
549
|
+
end
|
550
|
+
|
551
|
+
def test_sharpen_channel
|
552
|
+
assert_nothing_raised do
|
553
|
+
res = @img.sharpen_channel
|
554
|
+
assert_instance_of(Magick::Image, res)
|
555
|
+
end
|
556
|
+
assert_nothing_raised { @img.sharpen_channel(2.0) }
|
557
|
+
assert_nothing_raised { @img.sharpen_channel(2.0, 1.0) }
|
558
|
+
assert_nothing_raised { @img.sharpen_channel(2.0, 1.0, Magick::RedChannel) }
|
559
|
+
assert_nothing_raised { @img.sharpen_channel(2.0, 1.0, Magick::RedChannel, Magick::BlueChannel) }
|
560
|
+
assert_raise(TypeError) { @img.sharpen_channel(2.0, 1.0, Magick::RedChannel, 2) }
|
561
|
+
assert_raise(TypeError) { @img.sharpen_channel('x') }
|
562
|
+
assert_raise(TypeError) { @img.sharpen_channel(2.0, 'x') }
|
563
|
+
end
|
564
|
+
|
565
|
+
def test_shave
|
566
|
+
assert_nothing_raised do
|
567
|
+
res = @img.shave(5,5)
|
568
|
+
assert_instance_of(Magick::Image, res)
|
569
|
+
end
|
570
|
+
assert_nothing_raised do
|
571
|
+
res = @img.shave!(5,5)
|
572
|
+
assert_same(@img, res)
|
573
|
+
end
|
574
|
+
@img.freeze
|
575
|
+
assert_raise(FreezeError) { @img.shave!(2,2) }
|
576
|
+
end
|
577
|
+
|
578
|
+
def test_shear
|
579
|
+
assert_nothing_raised do
|
580
|
+
res = @img.shear(30, 30)
|
581
|
+
assert_instance_of(Magick::Image, res)
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
585
|
+
def test_sigmoidal_contrast_channel
|
586
|
+
assert_nothing_raised do
|
587
|
+
res = @img.sigmoidal_contrast_channel
|
588
|
+
assert_instance_of(Magick::Image, res)
|
589
|
+
end
|
590
|
+
assert_nothing_raised { @img.sigmoidal_contrast_channel(3.0) }
|
591
|
+
assert_nothing_raised { @img.sigmoidal_contrast_channel(3.0, 50.0) }
|
592
|
+
assert_nothing_raised { @img.sigmoidal_contrast_channel(3.0, 50.0, true) }
|
593
|
+
assert_nothing_raised { @img.sigmoidal_contrast_channel(3.0, 50.0, true, Magick::RedChannel) }
|
594
|
+
assert_nothing_raised { @img.sigmoidal_contrast_channel(3.0, 50.0, true, Magick::RedChannel, Magick::BlueChannel) }
|
595
|
+
assert_raise(TypeError) { @img.sigmoidal_contrast_channel(3.0, 50.0, true, Magick::RedChannel, 2) }
|
596
|
+
assert_raise(TypeError) { @img.sigmoidal_contrast_channel('x') }
|
597
|
+
assert_raise(TypeError) { @img.sigmoidal_contrast_channel(3.0, 'x') }
|
598
|
+
end
|
599
|
+
|
600
|
+
def test_signature
|
601
|
+
assert_nothing_raised do
|
602
|
+
res = @img.signature
|
603
|
+
assert_instance_of(String, res)
|
604
|
+
end
|
605
|
+
end
|
606
|
+
|
607
|
+
def test_sketch
|
608
|
+
assert_nothing_raised { @img.sketch }
|
609
|
+
assert_nothing_raised { @img.sketch(0) }
|
610
|
+
assert_nothing_raised { @img.sketch(0, 1) }
|
611
|
+
assert_nothing_raised { @img.sketch(0, 1, 0) }
|
612
|
+
assert_raise(ArgumentError) { @img.sketch(0, 1, 0, 1) }
|
613
|
+
assert_raise(TypeError) { @img.sketch('x') }
|
614
|
+
assert_raise(TypeError) { @img.sketch(0, 'x') }
|
615
|
+
assert_raise(TypeError) { @img.sketch(0, 1, 'x') }
|
616
|
+
end
|
617
|
+
|
618
|
+
def test_solarize
|
619
|
+
assert_nothing_raised do
|
620
|
+
res = @img.solarize
|
621
|
+
assert_instance_of(Magick::Image, res)
|
622
|
+
end
|
623
|
+
assert_nothing_raised { @img.solarize(100) }
|
624
|
+
assert_raise(ArgumentError) { @img.solarize(100, 2) }
|
625
|
+
assert_raise(TypeError) { @img.solarize('x') }
|
626
|
+
end
|
627
|
+
|
628
|
+
def test_sparse_color
|
629
|
+
img = Magick::Image.new(100, 100)
|
630
|
+
args = [30, 10, 'red', 10, 80, 'blue', 70, 60, 'lime', 80, 20, 'yellow']
|
631
|
+
# assert good calls work
|
632
|
+
Magick::SparseColorMethod.values do |v|
|
633
|
+
next if v == Magick::UndefinedColorInterpolate
|
634
|
+
assert_nothing_raised { img.sparse_color(v, *args) }
|
635
|
+
end
|
636
|
+
args << Magick::RedChannel
|
637
|
+
assert_nothing_raised { img.sparse_color(Magick::VoronoiColorInterpolate, *args) }
|
638
|
+
args << Magick::GreenChannel
|
639
|
+
assert_nothing_raised { img.sparse_color(Magick::VoronoiColorInterpolate, *args) }
|
640
|
+
args << Magick::BlueChannel
|
641
|
+
assert_nothing_raised { img.sparse_color(Magick::VoronoiColorInterpolate, *args) }
|
642
|
+
|
643
|
+
# bad calls
|
644
|
+
args = [30, 10, 'red', 10, 80, 'blue', 70, 60, 'lime', 80, 20, 'yellow']
|
645
|
+
# invalid method
|
646
|
+
assert_raise(TypeError) { img.sparse_color(1, *args) }
|
647
|
+
# missing arguments
|
648
|
+
assert_raise(ArgumentError) { img.sparse_color(Magick::VoronoiColorInterpolate) }
|
649
|
+
args << 10 # too many arguments
|
650
|
+
assert_raise(ArgumentError) { img.sparse_color(Magick::VoronoiColorInterpolate, *args) }
|
651
|
+
args.shift
|
652
|
+
args.shift # too few
|
653
|
+
assert_raise(ArgumentError) { img.sparse_color(Magick::VoronoiColorInterpolate, *args) }
|
654
|
+
end
|
655
|
+
|
656
|
+
def test_splice
|
657
|
+
assert_nothing_raised do
|
658
|
+
res = @img.splice(0, 0, 2, 2)
|
659
|
+
assert_instance_of(Magick::Image, res)
|
660
|
+
end
|
661
|
+
assert_nothing_raised { @img.splice(0, 0, 2, 2, 'red') }
|
662
|
+
red = Magick::Pixel.new(Magick::QuantumRange)
|
663
|
+
assert_nothing_raised { @img.splice(0, 0, 2, 2, red) }
|
664
|
+
assert_raise(ArgumentError) { @img.splice(0,0, 2, 2, red, 'x') }
|
665
|
+
assert_raise(TypeError) { @img.splice([], 0, 2, 2, red) }
|
666
|
+
assert_raise(TypeError) { @img.splice(0, 'x', 2, 2, red) }
|
667
|
+
assert_raise(TypeError) { @img.splice(0, 0, 'x', 2, red) }
|
668
|
+
assert_raise(TypeError) { @img.splice(0, 0, 2, [], red) }
|
669
|
+
assert_raise(TypeError) { @img.splice(0, 0, 2, 2, /m/) }
|
670
|
+
end
|
671
|
+
|
672
|
+
def test_spread
|
673
|
+
assert_nothing_raised do
|
674
|
+
res = @img.spread
|
675
|
+
assert_instance_of(Magick::Image, res)
|
676
|
+
end
|
677
|
+
assert_nothing_raised { @img.spread(3.0) }
|
678
|
+
assert_raise(ArgumentError) { @img.spread(3.0, 2) }
|
679
|
+
assert_raise(TypeError) { @img.spread('x') }
|
680
|
+
end
|
681
|
+
|
682
|
+
def test_stegano
|
683
|
+
img = Magick::Image.new(100, 100) { self.background_color = 'black' }
|
684
|
+
watermark = Magick::Image.new(10, 10) { self.background_color = 'white' }
|
685
|
+
assert_nothing_raised do
|
686
|
+
res = @img.stegano(watermark, 0)
|
687
|
+
assert_instance_of(Magick::Image, res)
|
688
|
+
end
|
689
|
+
|
690
|
+
watermark.destroy!
|
691
|
+
assert_raise(Magick::DestroyedImageError) { @img.stegano(watermark, 0) }
|
692
|
+
end
|
693
|
+
|
694
|
+
def test_stereo
|
695
|
+
assert_nothing_raised do
|
696
|
+
res = @img.stereo(@img)
|
697
|
+
assert_instance_of(Magick::Image, res)
|
698
|
+
end
|
699
|
+
|
700
|
+
img = Magick::Image.new(20,20)
|
701
|
+
img.destroy!
|
702
|
+
assert_raise(Magick::DestroyedImageError) { @img.stereo(img) }
|
703
|
+
end
|
704
|
+
|
705
|
+
def test_store_pixels
|
706
|
+
pixels = @img.get_pixels(0, 0, @img.columns, 1)
|
707
|
+
assert_nothing_raised do
|
708
|
+
res = @img.store_pixels(0, 0, @img.columns, 1, pixels)
|
709
|
+
assert_same(@img, res)
|
710
|
+
end
|
711
|
+
|
712
|
+
pixels[0] = 'x'
|
713
|
+
assert_raise(TypeError) { @img.store_pixels(0, 0, @img.columns, 1, pixels) }
|
714
|
+
assert_raise(RangeError) { @img.store_pixels(-1, 0, @img.columns, 1, pixels) }
|
715
|
+
assert_raise(RangeError) { @img.store_pixels(0, -1, @img.columns, 1, pixels) }
|
716
|
+
assert_raise(RangeError) { @img.store_pixels(0, 0, 1+@img.columns, 1, pixels) }
|
717
|
+
assert_raise(RangeError) { @img.store_pixels(-1, 0, 1, 1+@img.rows, pixels) }
|
718
|
+
assert_raise(IndexError) { @img.store_pixels(0, 0, @img.columns, 1, ['x']) }
|
719
|
+
end
|
720
|
+
|
721
|
+
def test_strip!
|
722
|
+
assert_nothing_raised do
|
723
|
+
res = @img.strip!
|
724
|
+
assert_same(@img, res)
|
725
|
+
end
|
726
|
+
end
|
727
|
+
|
728
|
+
def test_swirl
|
729
|
+
assert_nothing_raised do
|
730
|
+
res = @img.swirl(30)
|
731
|
+
assert_instance_of(Magick::Image, res)
|
732
|
+
end
|
733
|
+
end
|
734
|
+
|
735
|
+
def test_sync_profiles
|
736
|
+
assert_nothing_raised { assert(@img.sync_profiles) }
|
737
|
+
end
|
738
|
+
|
739
|
+
def test_texture_fill_to_border
|
740
|
+
texture = Magick::Image.read('granite:').first
|
741
|
+
assert_nothing_raised do
|
742
|
+
res = @img.texture_fill_to_border(@img.columns/2, @img.rows/2, texture)
|
743
|
+
assert_instance_of(Magick::Image, res)
|
744
|
+
end
|
745
|
+
assert_raise(NoMethodError) { @img.texture_fill_to_border(@img.columns/2, @img.rows/2, 'x') }
|
746
|
+
end
|
747
|
+
|
748
|
+
def test_texture_floodfill
|
749
|
+
texture = Magick::Image.read('granite:').first
|
750
|
+
assert_nothing_raised do
|
751
|
+
res = @img.texture_floodfill(@img.columns/2, @img.rows/2, texture)
|
752
|
+
assert_instance_of(Magick::Image, res)
|
753
|
+
end
|
754
|
+
assert_raise(NoMethodError) { @img.texture_floodfill(@img.columns/2, @img.rows/2, 'x') }
|
755
|
+
texture.destroy!
|
756
|
+
assert_raise(Magick::DestroyedImageError) { @img.texture_floodfill(@img.columns/2, @img.rows/2, texture) }
|
757
|
+
end
|
758
|
+
|
759
|
+
def test_threshold
|
760
|
+
assert_nothing_raised do
|
761
|
+
res = @img.threshold(100)
|
762
|
+
assert_instance_of(Magick::Image, res)
|
763
|
+
end
|
764
|
+
end
|
765
|
+
|
766
|
+
def test_thumbnail
|
767
|
+
assert_nothing_raised do
|
768
|
+
res = @img.thumbnail(10, 10)
|
769
|
+
assert_instance_of(Magick::Image, res)
|
770
|
+
end
|
771
|
+
assert_nothing_raised { @img.thumbnail(2) }
|
772
|
+
assert_raise(ArgumentError) { @img.thumbnail }
|
773
|
+
assert_raise(ArgumentError) { @img.thumbnail(25, 25, 25) }
|
774
|
+
assert_raise(TypeError) { @img.thumbnail('x') }
|
775
|
+
assert_raise(TypeError) { @img.thumbnail(10, 'x') }
|
776
|
+
end
|
777
|
+
|
778
|
+
def test_thumbnail!
|
779
|
+
assert_nothing_raised do
|
780
|
+
res = @img.thumbnail!(2)
|
781
|
+
assert_same(@img, res)
|
782
|
+
end
|
783
|
+
@img.freeze
|
784
|
+
assert_raise(FreezeError) { @img.thumbnail!(0.50) }
|
785
|
+
end
|
786
|
+
|
787
|
+
def test_to_blob
|
788
|
+
res = nil
|
789
|
+
assert_nothing_raised { res = @img.to_blob { self.format = 'miff' } }
|
790
|
+
assert_instance_of(String, res)
|
791
|
+
restored = Magick::Image.from_blob(res)
|
792
|
+
assert_equal(@img, restored[0])
|
793
|
+
end
|
794
|
+
|
795
|
+
def test_to_color
|
796
|
+
red = Magick::Pixel.new(Magick::QuantumRange)
|
797
|
+
assert_nothing_raised do
|
798
|
+
res = @img.to_color(red)
|
799
|
+
assert_equal('red', res)
|
800
|
+
end
|
801
|
+
end
|
802
|
+
|
803
|
+
def test_transparent
|
804
|
+
assert_nothing_raised do
|
805
|
+
res = @img.transparent('white')
|
806
|
+
assert_instance_of(Magick::Image, res)
|
807
|
+
end
|
808
|
+
pixel = Magick::Pixel.new
|
809
|
+
assert_nothing_raised { @img.transparent(pixel) }
|
810
|
+
assert_nothing_raised { @img.transparent('white', Magick::TransparentOpacity) }
|
811
|
+
assert_raise(ArgumentError) { @img.transparent('white', Magick::TransparentOpacity, 2) }
|
812
|
+
assert_nothing_raised { @img.transparent('white', Magick::QuantumRange/2) }
|
813
|
+
assert_raise(TypeError) { @img.transparent(2) }
|
814
|
+
end
|
815
|
+
|
816
|
+
def test_transpose
|
817
|
+
assert_nothing_raised do
|
818
|
+
res = @img.transpose
|
819
|
+
assert_instance_of(Magick::Image, res)
|
820
|
+
assert_not_same(@img, res)
|
821
|
+
end
|
822
|
+
assert_nothing_raised do
|
823
|
+
res = @img.transpose!
|
824
|
+
assert_instance_of(Magick::Image, res)
|
825
|
+
assert_same(@img, res)
|
826
|
+
end
|
827
|
+
end
|
828
|
+
|
829
|
+
def test_transverse
|
830
|
+
assert_nothing_raised do
|
831
|
+
res = @img.transverse
|
832
|
+
assert_instance_of(Magick::Image, res)
|
833
|
+
assert_not_same(@img, res)
|
834
|
+
end
|
835
|
+
assert_nothing_raised do
|
836
|
+
res = @img.transverse!
|
837
|
+
assert_instance_of(Magick::Image, res)
|
838
|
+
assert_same(@img, res)
|
839
|
+
end
|
840
|
+
end
|
841
|
+
|
842
|
+
def test_trim
|
843
|
+
# Can't use the default image because it's a solid color
|
844
|
+
hat = Magick::Image.read(IMAGES_DIR+'/Flower_Hat.jpg').first
|
845
|
+
assert_nothing_raised do
|
846
|
+
res = hat.trim
|
847
|
+
assert_instance_of(Magick::Image, res)
|
848
|
+
end
|
849
|
+
assert_nothing_raised do
|
850
|
+
res = hat.trim!
|
851
|
+
assert_same(hat, res)
|
852
|
+
end
|
853
|
+
end
|
854
|
+
|
855
|
+
def test_unique_colors
|
856
|
+
assert_nothing_raised do
|
857
|
+
res = @img.unique_colors
|
858
|
+
assert_instance_of(Magick::Image, res)
|
859
|
+
assert_equal(1, res.columns)
|
860
|
+
assert_equal(1, res.rows)
|
861
|
+
end
|
862
|
+
end
|
863
|
+
|
864
|
+
def test_unsharp_mask
|
865
|
+
assert_nothing_raised do
|
866
|
+
res = @img.unsharp_mask
|
867
|
+
assert_instance_of(Magick::Image, res)
|
868
|
+
end
|
869
|
+
|
870
|
+
assert_nothing_raised { @img.unsharp_mask(2.0) }
|
871
|
+
assert_nothing_raised { @img.unsharp_mask(2.0, 1.0) }
|
872
|
+
assert_nothing_raised { @img.unsharp_mask(2.0, 1.0, 0.50) }
|
873
|
+
assert_nothing_raised { @img.unsharp_mask(2.0, 1.0, 0.50, 0.10) }
|
874
|
+
assert_raise(ArgumentError) { @img.unsharp_mask(2.0, 1.0, 0.50, 0.10, 2) }
|
875
|
+
assert_raise(TypeError) { @img.unsharp_mask('x') }
|
876
|
+
assert_raise(TypeError) { @img.unsharp_mask(2.0, 'x') }
|
877
|
+
assert_raise(TypeError) { @img.unsharp_mask(2.0, 1.0, 'x') }
|
878
|
+
assert_raise(TypeError) { @img.unsharp_mask(2.0, 1.0, 0.50, 'x') }
|
879
|
+
end
|
880
|
+
|
881
|
+
def test_unsharp_mask_channel
|
882
|
+
assert_nothing_raised do
|
883
|
+
res = @img.unsharp_mask_channel
|
884
|
+
assert_instance_of(Magick::Image, res)
|
885
|
+
end
|
886
|
+
|
887
|
+
assert_nothing_raised { @img.unsharp_mask_channel(2.0) }
|
888
|
+
assert_nothing_raised { @img.unsharp_mask_channel(2.0, 1.0) }
|
889
|
+
assert_nothing_raised { @img.unsharp_mask_channel(2.0, 1.0, 0.50) }
|
890
|
+
assert_nothing_raised { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 0.10) }
|
891
|
+
assert_nothing_raised { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 0.10, Magick::RedChannel) }
|
892
|
+
assert_nothing_raised { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 0.10, Magick::RedChannel, Magick::BlueChannel) }
|
893
|
+
assert_raise(TypeError) { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 0.10, Magick::RedChannel, 2) }
|
894
|
+
assert_raise(TypeError) { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 0.10, 2) }
|
895
|
+
assert_raise(TypeError) { @img.unsharp_mask_channel('x') }
|
896
|
+
assert_raise(TypeError) { @img.unsharp_mask_channel(2.0, 'x') }
|
897
|
+
assert_raise(TypeError) { @img.unsharp_mask_channel(2.0, 1.0, 'x') }
|
898
|
+
assert_raise(TypeError) { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 'x') }
|
899
|
+
end
|
900
|
+
|
901
|
+
def test_view
|
902
|
+
assert_nothing_raised do
|
903
|
+
res = @img.view(0, 0, 5, 5)
|
904
|
+
assert_instance_of(Magick::Image::View, res)
|
905
|
+
end
|
906
|
+
assert_nothing_raised do
|
907
|
+
@img.view(0, 0, 5, 5) { |v| assert_instance_of(Magick::Image::View, v) }
|
908
|
+
end
|
909
|
+
assert_raise(RangeError) { @img.view(-1, 0, 5, 5) }
|
910
|
+
assert_raise(RangeError) { @img.view(0, -1, 5, 5) }
|
911
|
+
assert_raise(RangeError) { @img.view(1, 0, @img.columns, 5) }
|
912
|
+
assert_raise(RangeError) { @img.view(0, 1, 5, @img.rows) }
|
913
|
+
assert_raise(ArgumentError) { @img.view(0, 0, 0, 1) }
|
914
|
+
assert_raise(ArgumentError) { @img.view(0, 0, 1, 0) }
|
915
|
+
end
|
916
|
+
|
917
|
+
def test_vignette
|
918
|
+
assert_nothing_raised do
|
919
|
+
res = @img.vignette
|
920
|
+
assert_instance_of(Magick::Image, res)
|
921
|
+
assert_not_same(res, @img)
|
922
|
+
end
|
923
|
+
assert_nothing_raised { @img.vignette(0) }
|
924
|
+
assert_nothing_raised { @img.vignette(0, 0) }
|
925
|
+
assert_nothing_raised { @img.vignette(0, 0, 0) }
|
926
|
+
assert_nothing_raised { @img.vignette(0, 0, 0, 1) }
|
927
|
+
# too many arguments
|
928
|
+
assert_raise(ArgumentError) { @img.vignette(0, 0, 0, 1, 1) }
|
929
|
+
end
|
930
|
+
|
931
|
+
def test_watermark
|
932
|
+
mark = Magick::Image.new(5,5)
|
933
|
+
mark_list = Magick::ImageList.new
|
934
|
+
mark_list << mark.copy
|
935
|
+
assert_nothing_raised { @img.watermark(mark) }
|
936
|
+
assert_nothing_raised { @img.watermark(mark_list) }
|
937
|
+
assert_nothing_raised { @img.watermark(mark, 0.50) }
|
938
|
+
assert_nothing_raised { @img.watermark(mark, '50%') }
|
939
|
+
assert_nothing_raised { @img.watermark(mark, 0.50, 0.50) }
|
940
|
+
assert_nothing_raised { @img.watermark(mark, 0.50, '50%') }
|
941
|
+
assert_nothing_raised { @img.watermark(mark, 0.50, 0.50, 10) }
|
942
|
+
assert_nothing_raised { @img.watermark(mark, 0.50, 0.50, 10, 10) }
|
943
|
+
assert_nothing_raised { @img.watermark(mark, 0.50, 0.50, Magick::NorthEastGravity) }
|
944
|
+
assert_nothing_raised { @img.watermark(mark, 0.50, 0.50, Magick::NorthEastGravity, 10) }
|
945
|
+
assert_nothing_raised { @img.watermark(mark, 0.50, 0.50, Magick::NorthEastGravity, 10, 10) }
|
946
|
+
|
947
|
+
assert_raise(ArgumentError) { @img.watermark(mark, 'x') }
|
948
|
+
assert_raise(ArgumentError) { @img.watermark(mark, 0.50, 'x') }
|
949
|
+
assert_raise(TypeError) { @img.watermark(mark, 0.50, 0.50, 'x') }
|
950
|
+
assert_raise(TypeError) { @img.watermark(mark, 0.50, 0.50, Magick::NorthEastGravity, 'x') }
|
951
|
+
assert_raise(TypeError) { @img.watermark(mark, 0.50, 0.50, Magick::NorthEastGravity, 10, 'x') }
|
952
|
+
|
953
|
+
mark.destroy!
|
954
|
+
assert_raise(Magick::DestroyedImageError) { @img.watermark(mark) }
|
955
|
+
end
|
956
|
+
|
957
|
+
def test_wave
|
958
|
+
assert_nothing_raised do
|
959
|
+
res = @img.wave
|
960
|
+
assert_instance_of(Magick::Image, res)
|
961
|
+
end
|
962
|
+
assert_nothing_raised { @img.wave(25) }
|
963
|
+
assert_nothing_raised { @img.wave(25, 200) }
|
964
|
+
assert_raise(ArgumentError) { @img.wave(25, 200, 2) }
|
965
|
+
assert_raise(TypeError) { @img.wave('x') }
|
966
|
+
assert_raise(TypeError) { @img.wave(25, 'x') }
|
967
|
+
end
|
968
|
+
|
969
|
+
def test_white_threshold
|
970
|
+
assert_raise(ArgumentError) { @img.white_threshold }
|
971
|
+
assert_nothing_raised { @img.white_threshold(50) }
|
972
|
+
assert_nothing_raised { @img.white_threshold(50, 50) }
|
973
|
+
assert_nothing_raised { @img.white_threshold(50, 50, 50) }
|
974
|
+
assert_nothing_raised { @img.white_threshold(50, 50, 50, 50) }
|
975
|
+
assert_raise(ArgumentError) { @img.white_threshold(50, 50, 50, 50, 50) }
|
976
|
+
res = @img.white_threshold(50)
|
977
|
+
assert_instance_of(Magick::Image, res)
|
978
|
+
end
|
979
|
+
|
980
|
+
# test write with #format= attribute
|
981
|
+
def test_write
|
982
|
+
@img.write('temp.gif')
|
983
|
+
img = Magick::Image.read('temp.gif')
|
984
|
+
assert_equal('GIF', img.first.format)
|
985
|
+
FileUtils.rm('temp.gif')
|
986
|
+
|
987
|
+
@img.write('jpg:temp.foo')
|
988
|
+
img = Magick::Image.read('temp.foo')
|
989
|
+
assert_equal('JPEG', img.first.format)
|
990
|
+
FileUtils.rm('temp.foo')
|
991
|
+
|
992
|
+
@img.write('temp.0') { self.format = 'JPEG' }
|
993
|
+
img = Magick::Image.read('temp.0')
|
994
|
+
assert_equal('JPEG', img.first.format)
|
995
|
+
|
996
|
+
# JPEG has two names.
|
997
|
+
@img.write('jpeg:temp.0') { self.format = 'JPEG' }
|
998
|
+
img = Magick::Image.read('temp.0')
|
999
|
+
assert_equal('JPEG', img.first.format)
|
1000
|
+
|
1001
|
+
@img.write('jpg:temp.0') { self.format = 'JPG' }
|
1002
|
+
img = Magick::Image.read('temp.0')
|
1003
|
+
assert_equal('JPEG', img.first.format)
|
1004
|
+
|
1005
|
+
@img.write('jpg:temp.0') { self.format = 'JPEG' }
|
1006
|
+
img = Magick::Image.read('temp.0')
|
1007
|
+
assert_equal('JPEG', img.first.format)
|
1008
|
+
|
1009
|
+
@img.write('jpeg:temp.0') { self.format = 'JPG' }
|
1010
|
+
img = Magick::Image.read('temp.0')
|
1011
|
+
assert_equal('JPEG', img.first.format)
|
1012
|
+
|
1013
|
+
assert_raise(RuntimeError) do
|
1014
|
+
@img.write('gif:temp.0') { self.format = 'JPEG' }
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
f = File.new('test.0', 'w')
|
1018
|
+
@img.write(f) { self.format = 'JPEG' }
|
1019
|
+
f.close
|
1020
|
+
img = Magick::Image.read('test.0')
|
1021
|
+
assert_equal('JPEG', img.first.format)
|
1022
|
+
FileUtils.rm('test.0')
|
1023
|
+
end
|
1024
1024
|
end
|
1025
1025
|
|
1026
1026
|
if __FILE__ == $PROGRAM_NAME
|