1#!/usr/bin/perl 2# 3# Copyright 1999-2021 ImageMagick Studio LLC, a non-profit organization 4# dedicated to making software imaging solutions freely available. 5# 6# You may not use this file except in compliance with the License. You may 7# obtain a copy of the License at 8# 9# https://imagemagick.org/script/license.php 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17# Test image filters. 18# 19BEGIN { $| = 1; $test=1, print "1..58\n"; } 20END {print "not ok 1\n" unless $loaded;} 21use Image::Magick; 22$loaded=1; 23 24require 't/subroutines.pl'; 25 26chdir 't' || die 'Cd failed'; 27use FileHandle; 28autoflush STDOUT 1; 29autoflush STDERR 1; 30 31$fuzz=int(0.05*(Image::Magick->new()->QuantumRange)); 32 33testFilterCompare('input.miff', q//, 'reference/filter/AdaptiveThreshold.miff', 'AdaptiveThreshold', q/'5x5+5%'/, 0.0, 0.0); 34++$test; 35 36testFilterCompare('input.miff', q//, 'reference/filter/Annotate.miff', 'Annotate', q/text=>'Magick',geometry=>'+0+20',font=>'Generic.ttf',fill=>'gold',gravity=>'North',pointsize=>14/, 0.05, 1.00); 37++$test; 38 39testFilterCompare('input.miff', q//, 'reference/filter/Blur.miff', 'Blur', q/'5x2'/, 0.007, 0.7); 40++$test; 41 42testFilterCompare('input.miff', q//, 'reference/filter/Border.miff', 'Border', q/geometry=>'6x6',color=>'gold'/, 0.0, 0.0); 43++$test; 44 45testFilterCompare('input.miff', q//, 'reference/filter/Channel.miff', 'Channel', q/channel=>'red'/, 0.2, 0.8); 46++$test; 47 48testFilterCompare('input.miff', q//, 'reference/filter/Chop.miff', 'Chop', q/geometry=>'80x80+5+10'/, 0.0, 0.0); 49++$test; 50 51testFilterCompare('input.miff', q//, 'reference/filter/Charcoal.miff', 'Charcoal', q/'0x1'/, 0.3, 1.01); 52++$test; 53 54testFilterCompare('input.miff', "fuzz=>$fuzz", 'reference/filter/ColorFloodfill.miff', 'ColorFloodfill', q/geometry=>"+25+45"/, 0.15, 1.0); 55++$test; 56 57testFilterCompare('input.miff', "fuzz=>$fuzz", 'reference/filter/Colorize.miff', 'Colorize', q/fill=>"red", blend=>"50%"/, 0.00001, 0.004); 58++$test; 59 60testFilterCompare('input.miff', q//, 'reference/filter/Contrast.miff', 'Contrast', q//, 0.00001, 0.004); 61++$test; 62 63testFilterCompare('input.miff', q//, 'reference/filter/Convolve.miff', 'Convolve', q/[0.0625, 0.0625, 0.0625, 0.0625, 0.5, 0.0625, 0.0625, 0.0625, 0.0625]/, 0.1, 0.7); 64++$test; 65 66testFilterCompare('input.miff', q//, 'reference/filter/Crop.miff', 'Crop', q/geometry=>'80x80+5+10'/, 0.0, 0.0); 67++$test; 68 69testFilterCompare('input.miff', q//, 'reference/filter/Set.miff', 'Set', q/page=>'0x0+0+0'/, 0.0, 0.0); 70++$test; 71 72testFilterCompare('input.miff', q//, 'reference/filter/Despeckle.miff', 'Despeckle', q//, 0.0, 0.0); 73++$test; 74 75testFilterCompare('input.miff', q//, 'reference/filter/Draw.miff', 'Draw', q/fill=>'none',stroke=>'gold',primitive=>'circle',points=>'60,90 60,120',strokewidth=>2/, 0.0, 0.0); 76++$test; 77 78testFilterCompare('input.miff', q//, 'reference/filter/Edge.miff', 'Edge', q//, 0.31, 1.01); 79++$test; 80 81testFilterCompare('input.miff', q//, 'reference/filter/Emboss.miff', 'Emboss', q/'0x1'/, 0.2, 1.0); 82++$test; 83 84testFilterCompare('input.miff', q//, 'reference/filter/Equalize.miff', 'Equalize', q//, 0.06, 0.5); 85++$test; 86 87testFilterCompare('input.miff', q//, 'reference/filter/Implode.miff', 'Implode', q/0.0/, 0.0, 0.0); 88++$test; 89 90testFilterCompare('input.miff', q//, 'reference/filter/Flip.miff', 'Flip', q//, 0.0, 0.0); 91++$test; 92 93testFilterCompare('input.miff', q//, 'reference/filter/Flop.miff', 'Flop', q//, 0.0, 0.0); 94++$test; 95 96testFilterCompare('input.miff', q//, 'reference/filter/Frame.miff', 'Frame', q/'15x15+3+3'/, 0.02, 0.5); 97++$test; 98 99testFilterCompare('input.miff', q//, 'reference/filter/Gamma.miff', 'Gamma', q/1.6/, 0.00001, 0.004); 100++$test; 101 102testFilterCompare('input.miff', q//, 'reference/filter/GaussianBlur.miff', 'GaussianBlur', q/'0.0x1.5'/, 0.07, 0.9); 103++$test; 104 105testFilterCompare('input.miff', q//, 'reference/filter/Implode.miff', 'Implode', q/0.0/, 0.0, 0.0); 106++$test; 107 108testFilterCompare('input.miff', q//, 'reference/filter/Level.miff', 'Level', q/'20%x'/, 0.00001, 0.004); 109++$test; 110 111testFilterCompare('input.miff', q//, 'reference/filter/Magnify.miff', 'Magnify', q//, 0.003, 0.3); 112++$test; 113 114testFilterCompare('input.miff', "fuzz=>$fuzz", 'reference/filter/MatteFloodfill.miff', 'MatteFloodfill', q/geometry=>"+25+45"/, 0.25, 1.0); 115++$test; 116 117testFilterCompare('input.miff', q//, 'reference/filter/MedianFilter.miff', 'MedianFilter', q//, 0.0, 0.0); 118++$test; 119 120testFilterCompare('input.miff', q//, 'reference/filter/Minify.miff', 'Minify', q//, 0.00001, 0.004); 121++$test; 122 123testFilterCompare('input.miff', q//, 'reference/filter/Modulate.miff', 'Modulate', q/brightness=>110,saturation=>110,hue=>110/, 0.05, 0.5); 124++$test; 125 126testFilterCompare('input.miff', q//, 'reference/filter/QuantizeMono.miff', 'Quantize', q/colors=>256/, 0.2, 0.7); 127++$test; 128 129testFilterCompare('input.miff', q//, 'reference/filter/MotionBlur.miff', 'MotionBlur', q/'0x13+10-10'/, 0.002, 0.04); 130++$test; 131 132testFilterCompare('input.miff', q//, 'reference/filter/Negate.miff', 'Negate', q//, 0.0, 0.0); 133++$test; 134 135testFilterCompare('input.miff', q//, 'reference/filter/Normalize.miff', 'Normalize', q//, 0.02, 0.2); 136++$test; 137 138testFilterCompare('input.miff', q//, 'reference/filter/OilPaint.miff', 'OilPaint', q//, 0.03, 1.0); 139++$test; 140 141testFilterCompare('input.miff', "fuzz=>$fuzz", 'reference/filter/Opaque.miff', 'Opaque', q/color=>"#e23834", fill=>"green"/, 0.0, 0.0); 142++$test; 143 144testFilterCompare('input.miff', q//, 'reference/filter/Quantize.miff', 'Quantize', q//, 0.2, 0.7); 145++$test; 146 147testFilterCompare('input.miff', q//, 'reference/filter/RadialBlur.miff', 'RadialBlur', q/10/, 0.004, 0.4); 148++$test; 149 150testFilterCompare('input.miff', q//, 'reference/filter/Raise.miff', 'Raise', q/'10x10'/, 0.00001, 0.004); 151++$test; 152 153testFilterCompare('input.miff', q//, 'reference/filter/ReduceNoise.miff', 'ReduceNoise', q//, 0.0, 0.0); 154++$test; 155 156testFilterCompare('input.miff', q//, 'reference/filter/Resize.miff', 'Resize', q/'60%'/, 0.00007, 0.07); 157++$test; 158 159testFilterCompare('input.miff', q//, 'reference/filter/Roll.miff', 'Roll', q/geometry=>'+20+10'/, 0.0, 0.0); 160++$test; 161 162testFilterCompare('input.miff', q//, 'reference/filter/Rotate.miff', 'Rotate', q/45/, 0.00004, 0.04); 163++$test; 164 165testFilterCompare('input.miff', q//, 'reference/filter/Sample.miff', 'Sample', q/'60%'/, 0.006, 0.6); 166++$test; 167 168testFilterCompare('input.miff', q//, 'reference/filter/Scale.miff', 'Scale', q/'60%'/, 0.00001, 0.004); 169++$test; 170 171testFilterCompare('input.miff', q//, 'reference/filter/Segment.miff', 'Segment', q//, 0.09, 0.9); 172++$test; 173 174testFilterCompare('input.miff', q//, 'reference/filter/Shade.miff', 'Shade', q/geometry=>'30x30',gray=>'true'/, 0.09, 0.9); 175++$test; 176 177testFilterCompare('input.miff', q//, 'reference/filter/Sharpen.miff', 'Sharpen', q/'5x2'/, 0.1, 1.001); 178++$test; 179 180testFilterCompare('input.miff', q//, 'reference/filter/Shave.miff', 'Shave', q/'10x10'/, 0.0, 0.0); 181++$test; 182 183testFilterCompare('input.miff', q//, 'reference/filter/Shear.miff', 'Shear', q/'-20x20'/, 0.00001, 0.004); 184++$test; 185 186testFilterCompare('input.miff', q//, 'reference/filter/SigmoidalContrast.miff', 'SigmoidalContrast', q/"3x50%"/, 0.00001, 0.004); 187++$test; 188 189testFilterCompare('input.miff', q//, 'reference/filter/Solarize.miff', 'Solarize', q//, 0.0, 0.0); 190++$test; 191 192testFilterCompare('input.miff', q//, 'reference/filter/Swirl.miff', 'Swirl', q/90/, 0.00001, 0.004); 193++$test; 194 195testFilterCompare('input.miff', q//, 'reference/filter/Threshold.miff', 'Threshold', q/90%/, 0.0, 0.0); 196++$test; 197 198testFilterCompare('input.miff', q//, 'reference/filter/Trim.miff', 'Trim', q//, 0.0, 0.0); 199++$test; 200 201testFilterCompare('input.miff', q//, 'reference/filter/UnsharpMask.miff', 'UnsharpMask', q/'5x2+1'/, 0.004, 0.4); 202++$test; 203 204testFilterCompare('input.miff', q//, 'reference/filter/Wave.miff', 'Wave', q/'25x150'/, 0.00001, 0.004); 205++$test; 206 2071; 208