diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/bg.gif b/htdocs/class/libraries/vendor/smottt/wideimage/demo/bg.gif new file mode 100644 index 000000000..1ff803b3e Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/bg.gif differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demo_screen.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demo_screen.php new file mode 100644 index 000000000..44127ddee --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demo_screen.php @@ -0,0 +1,66 @@ + +
+ +
+ +fields as $field) + $field->render(); +?> +
+ + Read the API documentation for this operation. + + +
+render(); + echo "
\n"; + echo ' Palette options (only for png8 and gif output):
'; + $top_form['ncolors']->render(); + echo "
\n"; + $top_form['dither']->render(); + $top_form['match_palette']->render(); +?> +
+
+
+ +text(); +?> + + +isDot() && strpos($file->getFilename(), '.') !== 0) + $images[] = $file->getFilename(); + + asort($images); + foreach ($images as $image_file) + { + echo '
'; + echo ''; + $img_url = 'image.php?image=' . $image_file . '&output=' . $top_form['output']->value . + '&colors=' . $top_form['ncolors']->value . '&dither=' . $top_form['dither']->value . + '&match_palette=' . $top_form['match_palette']->value . '&demo=' . $activeDemo->name; + foreach ($activeDemo->fields as $field) + $img_url .= '&' . $field->getURLValue(); + + echo ' '; + echo ''; + echo ''; + echo ''; + echo "
\n"; + } +?> +
+ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/addNoise.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/addNoise.php new file mode 100644 index 000000000..d1b485f0d --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/addNoise.php @@ -0,0 +1,19 @@ +addField(new IntField('amount', 300)); + $this->addField(new SelectField('type', array('salt&pepper','mono','color'), 'mono')); + } + + function execute($image, $request) + { + return $image->addNoise($this->fields['amount']->value, $this->fields['type']->value); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/applyConvolution.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/applyConvolution.php new file mode 100644 index 000000000..10e1450d8 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/applyConvolution.php @@ -0,0 +1,45 @@ +addField(new Field('matrix', '2 0 0, 0 -1 0, 0 0 -1', '3x3 float matrix; separate rows with a comma, and columns with a space')); + $this->addField(new FloatField('div', 1)); + $this->addField(new FloatField('offset', 220)); + } + + function execute($image, $request) + { + $mstr = $this->fval('matrix'); + $rows = explode(',', $mstr); + + $matrix = array(); + foreach ($this->base_matrix as $idx => $base_row) + { + $build_row = array(); + if (isset($rows[$idx])) + { + $row = trim($rows[$idx]); + $cols = explode(' ', $row); + for ($c = 0; $c < 3; $c++) + if (isset($cols[$c])) + $build_row[] = floatval(trim($cols[$c])); + else + $build_row[] = $base_row[$c]; + } + else + $build_row = $base_row; + + $matrix[] = $build_row; + } + + return $image->applyConvolution($matrix, $this->fval('div'), $this->fval('offset')); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/applyFilter.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/applyFilter.php new file mode 100644 index 000000000..48c636c45 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/applyFilter.php @@ -0,0 +1,39 @@ +addField(new SelectField('filter', array( + 'IMG_FILTER_NEGATE', + 'IMG_FILTER_GRAYSCALE', + 'IMG_FILTER_BRIGHTNESS', + 'IMG_FILTER_CONTRAST', + 'IMG_FILTER_COLORIZE', + 'IMG_FILTER_EDGEDETECT', + 'IMG_FILTER_EMBOSS', + 'IMG_FILTER_GAUSSIAN_BLUR', + 'IMG_FILTER_SELECTIVE_BLUR', + 'IMG_FILTER_MEAN_REMOVAL', + 'IMG_FILTER_SMOOTH' + )) + ); + $this->addField(new IntField('arg1', null)); + $this->addField(new IntField('arg2', null)); + $this->addField(new IntField('arg3', null)); + } + + function execute($image) + { + $filter = constant($this->fields['filter']->value); + $arg1 = $this->fields['arg1']->value; + $arg2 = $this->fields['arg2']->value; + $arg3 = $this->fields['arg3']->value; + + return $image->applyFilter($filter, $arg1, $arg2, $arg3); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/applyMask.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/applyMask.php new file mode 100644 index 000000000..15e5a9a19 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/applyMask.php @@ -0,0 +1,32 @@ +addField(new FileSelectField('mask', 'masks')); + $this->addField(new CoordinateField('left', 10)); + $this->addField(new CoordinateField('top', '30%')); + + if (!$this->request->get('mask')) + $this->request->set('mask', 'mask-circle.gif'); + } + + function execute($image) + { + $mask = \WideImage\WideImage::load(DEMO_PATH . 'masks/' . $this->fields['mask']->value); + $left = $this->fields['left']->value; + $top = $this->fields['top']->value; + + return $image->applyMask($mask, $left, $top); + } + + function getFormat() + { + return 'png'; + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/asGrayscale.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/asGrayscale.php new file mode 100644 index 000000000..b58c855ae --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/asGrayscale.php @@ -0,0 +1,13 @@ +asGrayscale(); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/asNegative.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/asNegative.php new file mode 100644 index 000000000..0112f6b04 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/asNegative.php @@ -0,0 +1,13 @@ +asNegative(); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/autoCrop.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/autoCrop.php new file mode 100644 index 000000000..7adf6b76b --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/autoCrop.php @@ -0,0 +1,26 @@ +addField(new IntField('margin', 0)); + $this->addField(new IntField('rgb_threshold', 0)); + $this->addField(new IntField('pixel_cutoff', 1)); + $this->addField(new IntField('base_color', null, 'Index of the color')); + } + + function execute($image, $request) + { + $margin = $this->fields['margin']->value; + $rgb_threshold = $this->fields['rgb_threshold']->value; + $pixel_cutoff = $this->fields['pixel_cutoff']->value; + $base_color = $this->fields['base_color']->value; + + return $image->autoCrop($margin, $rgb_threshold, $pixel_cutoff, $base_color); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/correctGamma.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/correctGamma.php new file mode 100644 index 000000000..4c3f85562 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/correctGamma.php @@ -0,0 +1,19 @@ +addField(new FloatField('in_gamma', 1.1)); + $this->addField(new FloatField('out_gamma', 3.7)); + } + + function execute($image, $request) + { + return $image->correctGamma($this->fval('in_gamma'), $this->fval('out_gamma')); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/crop.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/crop.php new file mode 100644 index 000000000..9dba09995 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/crop.php @@ -0,0 +1,26 @@ +addField(new CoordinateField('left', 10)); + $this->addField(new CoordinateField('top', 20)); + $this->addField(new CoordinateField('width', 120)); + $this->addField(new CoordinateField('height', 60)); + } + + function execute($image, $request) + { + $left = $this->fields['left']->value; + $top = $this->fields['top']->value; + $width = $this->fields['width']->value; + $height = $this->fields['height']->value; + + return $image->crop($left, $top, $width, $height); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/flip.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/flip.php new file mode 100644 index 000000000..0e738f64f --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/flip.php @@ -0,0 +1,13 @@ +flip(); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/getCanvas.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/getCanvas.php new file mode 100644 index 000000000..296668c4e --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/getCanvas.php @@ -0,0 +1,63 @@ +addField(new Field('text', 'Hello world!')); + $this->addField(new CoordinateField('x', 'middle')); + $this->addField(new CoordinateField('y', 'bottom-5')); + $this->addField(new IntField('angle', 5)); + $this->addField(new FileSelectField('font', 'fonts', array('show' => false, 'pattern' => '/(.*)\.ttf$/', 'default' => 'VeraSe.ttf'))); + $this->addField(new IntField('size', 18)); + } + + function execute($image, $request) + { + $text = $this->fields['text']->value; + $x = $this->fields['x']->value; + $y = $this->fields['y']->value; + $angle = $this->fields['angle']->value; + $font = $this->fields['font']->value; + $font_size = $this->fields['size']->value; + + $canvas = $image->getCanvas(); + + $canvas->filledRectangle(10, 10, 80, 40, $image->allocateColor(255, 127, 255)); + $canvas->line(60, 80, 30, 100, $image->allocateColor(255, 0, 0)); + + $font_file = DEMO_PATH . 'fonts/' . $font; + + $canvas->useFont($font_file, $font_size, $image->allocateColor(0, 0, 0)); + $canvas->writeText("$x+1", "$y+1", $text, $angle); + + $canvas->useFont($font_file, $font_size, $image->allocateColor(200, 220, 255)); + $canvas->writeText($x, $y, $text, $angle); + + return $image; + } + + function et($name) + { + return htmlentities($this->fval($name)); + } + + function text() + { + echo "This demo executes: +
+	\$canvas->filledRectangle(10, 10, 80, 40, \$img->allocateColor(255, 127, 255));
+	\$canvas->line(60, 80, 30, 100, \$img->allocateColor(255, 0, 0));
+	
+	\$canvas->useFont('{$this->et('font')}', '{$this->et('size')}', \$image->allocateColor(0, 0, 0));
+	\$canvas->writeText('{$this->et('x')}+1', '{$this->et('y')}+1', '{$this->et('text')}', {$this->et('angle')});
+	
+	\$canvas->useFont('{$this->et('font')}', '{$this->et('size')}', \$image->allocateColor(200, 220, 255));
+	\$canvas->writeText('{$this->et('x')}', '{$this->et('y')}', '{$this->et('text')}', {$this->et('angle')});
+	
"; + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/getChannels.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/getChannels.php new file mode 100644 index 000000000..fb1024e6d --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/getChannels.php @@ -0,0 +1,28 @@ +addField(new CheckboxField('red', true)); + $this->addField(new CheckboxField('green', false)); + $this->addField(new CheckboxField('blue', true)); + $this->addField(new CheckboxField('alpha', false)); + } + + function execute($img, $request) + { + $on = array(); + foreach ($this->channels as $name) + if ($this->fields[$name]->value) + $on[] = $name; + + return $img->getChannels($on); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/getMask.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/getMask.php new file mode 100644 index 000000000..20051a902 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/getMask.php @@ -0,0 +1,13 @@ +getMask(); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/merge.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/merge.php new file mode 100644 index 000000000..b74114063 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/merge.php @@ -0,0 +1,31 @@ +addField(new FileSelectField('overlay', 'images', array('default' => '6-logo.gif'))); + $this->addField(new CoordinateField('left', 'right-10')); + $this->addField(new CoordinateField('top', 'bottom-15%')); + $this->addField(new IntField('opacity', 50)); + } + + function execute($image, $request) + { + $overlay = \WideImage\WideImage::load(DEMO_PATH . 'images/' . $this->fields['overlay']->value); + $left = $this->fields['left']->value; + $top = $this->fields['top']->value; + $opacity = $this->fields['opacity']->value; + + return $image->merge($overlay, $left, $top, $opacity); + } + + function text() + { + echo "For alpha images, set opacity=100, otherwise alpha channel won't work."; + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/mirror.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/mirror.php new file mode 100644 index 000000000..40436828a --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/mirror.php @@ -0,0 +1,13 @@ +mirror(); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/resize.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/resize.php new file mode 100644 index 000000000..8e7366087 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/resize.php @@ -0,0 +1,26 @@ +addField(new CoordinateField('width', 120)); + $this->addField(new CoordinateField('height', null)); + $this->addField(new SelectField('fit', array('inside', 'fill', 'outside'))); + $this->addField(new SelectField('scale', array('any', 'down', 'up'))); + } + + function execute($image, $request) + { + $width = $this->fields['width']->value; + $height = $this->fields['height']->value; + $fit = $this->fields['fit']->value; + $scale = $this->fields['scale']->value; + + return $image->resize($width, $height, $fit, $scale); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/resizeCanvas.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/resizeCanvas.php new file mode 100644 index 000000000..316dcdccc --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/resizeCanvas.php @@ -0,0 +1,32 @@ +addField(new CoordinateField('width', '100%+30')); + $this->addField(new CoordinateField('height', 200)); + $this->addField(new CoordinateField('left', '2')); + $this->addField(new CoordinateField('top', 'bottom-10')); + $this->addField(new ColorField('color', 'ffffff')); + $this->addField(new SelectField('scale', array('any', 'down', 'up'), 'any')); + $this->addField(new CheckboxField('merge', false, "Merge or copy over")); + } + + function execute($image, $request) + { + $width = $this->fields['width']->value; + $height = $this->fields['height']->value; + $left = $this->fields['left']->value; + $top = $this->fields['top']->value; + $color = $this->fields['color']->value; + $scale = $this->fields['scale']->value; + $merge = $this->fields['merge']->value; + + return $image->resizeCanvas($width, $height, $left, $top, $color ? hexdec($color) : null, $scale, $merge); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/rotate.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/rotate.php new file mode 100644 index 000000000..55c169c22 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/rotate.php @@ -0,0 +1,22 @@ +addField(new AngleField('angle', 25)); + $this->addField(new ColorField('color', '')); + } + + function execute($image, $request) + { + $angle = $this->fields['angle']->value; + $color = $this->fields['color']->value; + + return $image->rotate($angle, $color ? hexdec($color) : null); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/roundCorners.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/roundCorners.php new file mode 100644 index 000000000..285e3cbc2 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/roundCorners.php @@ -0,0 +1,42 @@ +addField(new IntField('radius', 30)); + $this->addField(new ColorField('color', 'ffffff')); + $this->addField(new IntField('smoothness', 2)); + + $this->addField(new CheckboxField('top-left', true)); + $this->addField(new CheckboxField('top-right', true)); + $this->addField(new CheckboxField('bottom-right', true)); + $this->addField(new CheckboxField('bottom-left', true)); + } + + function execute($image, $request) + { + $color = $this->fields['color']->value; + $radius = $this->fields['radius']->value; + $smoothness = $this->fields['smoothness']->value; + + $corners = 0; + if ($this->fval('top-left')) + $corners += \WideImage\WideImage::SIDE_TOP_LEFT; + + if ($this->fval('top-right')) + $corners += \WideImage\WideImage::SIDE_TOP_RIGHT; + + if ($this->fval('bottom-right')) + $corners += \WideImage\WideImage::SIDE_BOTTOM_RIGHT; + + if ($this->fval('bottom-left')) + $corners += \WideImage\WideImage::SIDE_BOTTOM_LEFT; + + return $image->roundCorners($radius, $color ? hexdec($color) : null, $smoothness, $corners); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/unsharp.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/unsharp.php new file mode 100644 index 000000000..1b2042413 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/unsharp.php @@ -0,0 +1,20 @@ +addField(new IntField('amount', 300)); + $this->addField(new IntField('radius', 3)); + $this->addField(new IntField('threshold', 2)); + } + + function execute($image, $request) + { + return $image->unsharp($this->fields['amount']->value, $this->fields['radius']->value, $this->fields['threshold']->value); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/font.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/font.php new file mode 100644 index 000000000..a7ed94e90 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/font.php @@ -0,0 +1,99 @@ +getCanvas(); +$canvas->useFont('fonts/Vera.ttf', 36, $img->allocateColor(255, 0, 0)); +$canvas->writeText('left', 'top', 'abc', 0); +$canvas->writeText('right', 'top', 'def', 15); +$canvas->writeText('right', 'bottom', 'ghi', 30); +$canvas->writeText('left', 'bottom', 'jkl', 45); +$canvas->writeText('center', 'center', 'mno', 60); +$img->output('png'); +exit; + +// Create a 300x150 image +$im = imagecreatetruecolor(600, 350); +$black = imagecolorallocate($im, 0, 0, 0); +$bgcolor = imagecolorallocate($im, 255, 255, 0); + +// Set the background to be white +imagefilledrectangle($im, 0, 0, imagesx($im), imagesy($im), $bgcolor); + +// Path to our font file +$font = './fonts/Vera.ttf'; + +$angle = 340; +$font_size = 20; +$text = 'jW| asdkasdlk alk,.,wedwer|w[r=?'; +$text = '#j'; + +// First we create our bounding box +$bbox = imageftbbox($font_size, $angle, $font, $text); + + +function normalize_bbox($bbox) +{ + return array( + 'up-left' => array('x' => $bbox[6], 'y' => $bbox[7]), + 'up-right' => array('x' => $bbox[4], 'y' => $bbox[5]), + 'down-left' => array('x' => $bbox[0], 'y' => $bbox[1]), + 'down-right' => array('x' => $bbox[2], 'y' => $bbox[3]), + ); +} + +function outer_box($box) +{ + return array( + 'left' => min($box['up-left']['x'], $box['up-right']['x'], $box['down-left']['x'], $box['down-right']['x']), + 'top' => min($box['up-left']['y'], $box['up-right']['y'], $box['down-left']['y'], $box['down-right']['y']), + 'right' => max($box['up-left']['x'], $box['up-right']['x'], $box['down-left']['x'], $box['down-right']['x']), + 'bottom' => max($box['up-left']['y'], $box['up-right']['y'], $box['down-left']['y'], $box['down-right']['y']) + ); +} + +$box = normalize_bbox($bbox); + +// This is our cordinates for X and Y +#$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5; +#$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5; +#$x = 300; +#$y = 175; + +$obox = outer_box(normalize_bbox(imageftbbox($font_size, $angle, $font, ''))); +$obox = outer_box(normalize_bbox(imageftbbox($font_size, $angle, $font, $text))); + +#$x = imagesx($im) - $obox['right'] - 1; +#$y = imagesy($im) - $obox['bottom'] - 1; +$x = 0; +$y = 0; + +$gc = imagecolorallocate($im, 255, 200, 200); +imageline($im, imagesx($im) / 2, 0, imagesx($im) / 2, imagesy($im), $gc); +imageline($im, 0, imagesy($im) / 2, imagesx($im), imagesy($im) / 2, $gc); + + +imagefttext($im, $font_size, $angle, $x, $y, $black, $font, $text); +#imagefttext($im, $font_size, $angle, $x, $y, $black, $font, 'aj'); + +$c = imagecolorallocate($im, 0, 255, 0); +imageline($im, $box['up-left']['x'] + $x, $box['up-left']['y'] + $y, $box['up-right']['x'] + $x, $box['up-right']['y'] + $y, $c); +imageline($im, $box['up-right']['x'] + $x, $box['up-right']['y'] + $y, $box['down-right']['x'] + $x, $box['down-right']['y'] + $y, $c); +imageline($im, $box['down-right']['x'] + $x, $box['down-right']['y'] + $y, $box['down-left']['x'] + $x, $box['down-left']['y'] + $y, $c); +imageline($im, $box['down-left']['x'] + $x, $box['down-left']['y'] + $y, $box['up-left']['x'] + $x, $box['up-left']['y'] + $y, $c); + +$c = imagecolorallocate($im, 0, 127, 255); +$obox = outer_box($box); +imageline($im, $obox['left'] + $x, $obox['top'] + $y, $obox['right'] + $x, $obox['top'] + $y, $c); +imageline($im, $obox['right'] + $x, $obox['top'] + $y, $obox['right'] + $x, $obox['bottom'] + $y, $c); +imageline($im, $obox['right'] + $x, $obox['bottom'] + $y, $obox['left'] + $x, $obox['bottom'] + $y, $c); +imageline($im, $obox['left'] + $x, $obox['bottom'] + $y, $obox['left'] + $x, $obox['top'] + $y, $c); + +imagefilledellipse($im, $x, $y, 3, 3, imagecolorallocate($im, 255, 0, 0)); + + +// Output to browser +header('Content-type: image/png'); + +imagepng($im); +imagedestroy($im); diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/COPYRIGHT.TXT b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/COPYRIGHT.TXT new file mode 100644 index 000000000..e651be1c4 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/COPYRIGHT.TXT @@ -0,0 +1,124 @@ +Bitstream Vera Fonts Copyright + +The fonts have a generous copyright, allowing derivative works (as +long as "Bitstream" or "Vera" are not in the names), and full +redistribution (so long as they are not *sold* by themselves). They +can be be bundled, redistributed and sold with any software. + +The fonts are distributed under the following copyright: + +Copyright +========= + +Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream +Vera is a trademark of Bitstream, Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the fonts accompanying this license ("Fonts") and associated +documentation files (the "Font Software"), to reproduce and distribute +the Font Software, including without limitation the rights to use, +copy, merge, publish, distribute, and/or sell copies of the Font +Software, and to permit persons to whom the Font Software is furnished +to do so, subject to the following conditions: + +The above copyright and trademark notices and this permission notice +shall be included in all copies of one or more of the Font Software +typefaces. + +The Font Software may be modified, altered, or added to, and in +particular the designs of glyphs or characters in the Fonts may be +modified and additional glyphs or characters may be added to the +Fonts, only if the fonts are renamed to names not containing either +the words "Bitstream" or the word "Vera". + +This License becomes null and void to the extent applicable to Fonts +or Font Software that has been modified and is distributed under the +"Bitstream Vera" names. + +The Font Software may be sold as part of a larger software package but +no copy of one or more of the Font Software typefaces may be sold by +itself. + +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL +BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, +OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT +SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. + +Except as contained in this notice, the names of Gnome, the Gnome +Foundation, and Bitstream Inc., shall not be used in advertising or +otherwise to promote the sale, use or other dealings in this Font +Software without prior written authorization from the Gnome Foundation +or Bitstream Inc., respectively. For further information, contact: +fonts at gnome dot org. + +Copyright FAQ +============= + + 1. I don't understand the resale restriction... What gives? + + Bitstream is giving away these fonts, but wishes to ensure its + competitors can't just drop the fonts as is into a font sale system + and sell them as is. It seems fair that if Bitstream can't make money + from the Bitstream Vera fonts, their competitors should not be able to + do so either. You can sell the fonts as part of any software package, + however. + + 2. I want to package these fonts separately for distribution and + sale as part of a larger software package or system. Can I do so? + + Yes. A RPM or Debian package is a "larger software package" to begin + with, and you aren't selling them independently by themselves. + See 1. above. + + 3. Are derivative works allowed? + Yes! + + 4. Can I change or add to the font(s)? + Yes, but you must change the name(s) of the font(s). + + 5. Under what terms are derivative works allowed? + + You must change the name(s) of the fonts. This is to ensure the + quality of the fonts, both to protect Bitstream and Gnome. We want to + ensure that if an application has opened a font specifically of these + names, it gets what it expects (though of course, using fontconfig, + substitutions could still could have occurred during font + opening). You must include the Bitstream copyright. Additional + copyrights can be added, as per copyright law. Happy Font Hacking! + + 6. If I have improvements for Bitstream Vera, is it possible they might get + adopted in future versions? + + Yes. The contract between the Gnome Foundation and Bitstream has + provisions for working with Bitstream to ensure quality additions to + the Bitstream Vera font family. Please contact us if you have such + additions. Note, that in general, we will want such additions for the + entire family, not just a single font, and that you'll have to keep + both Gnome and Jim Lyles, Vera's designer, happy! To make sense to add + glyphs to the font, they must be stylistically in keeping with Vera's + design. Vera cannot become a "ransom note" font. Jim Lyles will be + providing a document describing the design elements used in Vera, as a + guide and aid for people interested in contributing to Vera. + + 7. I want to sell a software package that uses these fonts: Can I do so? + + Sure. Bundle the fonts with your software and sell your software + with the fonts. That is the intent of the copyright. + + 8. If applications have built the names "Bitstream Vera" into them, + can I override this somehow to use fonts of my choosing? + + This depends on exact details of the software. Most open source + systems and software (e.g., Gnome, KDE, etc.) are now converting to + use fontconfig (see www.fontconfig.org) to handle font configuration, + selection and substitution; it has provisions for overriding font + names and subsituting alternatives. An example is provided by the + supplied local.conf file, which chooses the family Bitstream Vera for + "sans", "serif" and "monospace". Other software (e.g., the XFree86 + core server) has other mechanisms for font substitution. + diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/README.TXT b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/README.TXT new file mode 100644 index 000000000..0f71795a7 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/README.TXT @@ -0,0 +1,11 @@ +Contained herin is the Bitstream Vera font family. + +The Copyright information is found in the COPYRIGHT.TXT file (along +with being incoporated into the fonts themselves). + +The releases notes are found in the file "RELEASENOTES.TXT". + +We hope you enjoy Vera! + + Bitstream, Inc. + The Gnome Project diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/RELEASENOTES.TXT b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/RELEASENOTES.TXT new file mode 100644 index 000000000..270bc0d40 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/RELEASENOTES.TXT @@ -0,0 +1,162 @@ +Bitstream Vera Fonts - April 16, 2003 +===================================== + +The version number of these fonts is 1.10 to distinguish them from the +beta test fonts. + +Note that the Vera copyright is incorporated in the fonts themselves. +The License field in the fonts contains the copyright license as it +appears below. The TrueType copyright field is not large enough to +contain the full license, so the license is incorporated (as you might +think if you thought about it) into the license field, which +unfortunately can be obscure to find. (In pfaedit, see: Element->Font +Info->TTFNames->License). + +Our apologies for it taking longer to complete the fonts than planned. +Beta testers requested a tighter line spacing (less leading) and Jim +Lyles redesigned Vera's accents to bring its line spacing to more +typical of other fonts. This took additional time and effort. Our +thanks to Jim for this effort above and beyond the call of duty. + +There are four monospace and sans faces (normal, oblique, bold, bold +oblique) and two serif faces (normal and bold). Fontconfig/Xft2 (see +www.fontconfig.org) can artificially oblique the serif faces for you: +this loses hinting and distorts the faces slightly, but is visibly +different than normal and bold, and reasonably pleasing. + +On systems with fontconfig 2.0 or 2.1 installed, making your sans, +serif and monospace fonts default to these fonts is very easy. Just +drop the file local.conf into your /etc/fonts directory. This will +make the Bitstream fonts your default fonts for all applications using +fontconfig (if sans, serif, or monospace names are used, as they often +are as default values in many desktops). The XML in local.conf may +need modification to enable subpixel decimation, if appropriate, +however, the commented out phrase does so for XFree86 4.3, in the case +that the server does not have sufficient information to identify the +use of a flat panel. Fontconfig 2.2 adds Vera to the list of font +families and will, by default use it as the default sans, serif and +monospace fonts. + +During the testing of the final Vera fonts, we learned that screen +fonts in general are only typically hinted to work correctly at +integer pixel sizes. Vera is coded internally for integer sizes only. +We need to investigate further to see if there are commonly used fonts +that are hinted to be rounded but are not rounded to integer sizes due +to oversights in their coding. + +Most fonts work best at 8 pixels and below if anti-aliased only, as +the amount of work required to hint well at smaller and smaller sizes +becomes astronomical. GASP tables are typically used to control +whether hinting is used or not, but Freetype/Xft does not currently +support GASP tables (which are present in Vera). + +To mitigate this problem, both for Vera and other fonts, there will be +(very shortly) a new fontconfig 2.2 release that will, by default not +apply hints if the size is below 8 pixels. if you should have a font +that in fact has been hinted more agressively, you can use fontconfig +to note this exception. We believe this should improve many hinted +fonts in addition to Vera, though implemeting GASP support is likely +the right long term solution. + +Font rendering in Gnome or KDE is the combination of algorithms in +Xft2 and Freetype, along with hinting in the fonts themselves. It is +vital to have sufficient information to disentangle problems that you +may observe. + +Note that having your font rendering system set up correctly is vital +to proper judgement of problems of the fonts: + + * Freetype may or may not be configured to in ways that may + implement execution of possibly patented (in some parts of the world) + TrueType hinting algorithms, particularly at small sizes. Best + results are obtained while using these algorithms. + + * The freetype autohinter (used when the possibly patented + algorithms are not used) continues to improve with each release. If + you are using the autohinter, please ensure you are using an up to + date version of freetype before reporting problems. + + * Please identify what version of freetype you are using in any + bug reports, and how your freetype is configured. + + * Make sure you are not using the freetype version included in + XFree86 4.3, as it has bugs that significantly degrade most fonts, + including Vera. if you build XFree86 4.3 from source yourself, you may + have installed this broken version without intending it (as I + did). Vera was verified with the recently released Freetype 2.1.4. On + many systems, 'ldd" can be used to see which freetype shared library + is actually being used. + + * Xft/X Render does not (yet) implement gamma correction. This + causes significant problems rendering white text on a black background + (causing partial pixels to be insufficiently shaded) if the gamma of + your monitor has not been compensated for, and minor problems with + black text on a while background. The program "xgamma" can be used to + set a gamma correction value in the X server's color pallette. Most + monitors have a gamma near 2. + + * Note that the Vera family uses minimal delta hinting. Your + results on other systems when not used anti-aliased may not be + entirely satisfying. We are primarily interested in reports of + problems on open source systems implementing Xft2/fontconfig/freetype + (which implements antialiasing and hinting adjustements, and + sophisticated subpixel decimation on flatpanels). Also, the + algorithms used by Xft2 adjust the hints to integer widths and the + results are crisper on open source systems than on Windows or + MacIntosh. + + * Your fontconfig may (probably does) predate the release of + fontconfig 2.2, and you may see artifacts not present when the font is + used at very small sizes with hinting enabled. "vc-list -V" can be + used to see what version you have installed. + +We believe and hope that these fonts will resolve the problems +reported during beta test. The largest change is the reduction of +leading (interline spacing), which had annoyed a number of people, and +reduced Vera's utility for some applcations. The Vera monospace font +should also now make '0' and 'O' and '1' and 'l' more clearly +distinguishable. + +The version of these fonts is version 1.10. Fontconfig should be +choosing the new version of the fonts if both the released fonts and +beta test fonts are installed (though please discard them: they have +names of form tt20[1-12]gn.ttf). Note that older versions of +fontconfig sometimes did not rebuild their cache correctly when new +fonts are installed: please upgrade to fontconfig 2.2. "fc-cache -f" +can be used to force rebuilding fontconfig's cache files. + +If you note problems, please send them to fonts at gnome dot org, with +exactly which face and size and unicode point you observe the problem +at. The xfd utility from XFree86 CVS may be useful for this (e.g. "xfd +-fa sans"). A possibly more useful program to examine fonts at a +variety of sizes is the "waterfall" program found in Keith Packard's +CVS. + + $ cvs -d :pserver:anoncvs@keithp.com:/local/src/CVS login + Logging in to :pserver:anoncvs@keithp.com:2401/local/src/CVS + CVS password: + $ cvs -d :pserver:anoncvs@keithp.com:/local/src/CVS co waterfall + $ cd waterfall + $ xmkmf -a + $ make + # make install + # make install.man + +Again, please make sure you are running an up-to-date freetype, and +that you are only examining integer sizes. + +Reporting Problems +================== + +Please send problem reports to fonts at gnome org, with the following +information: + + 1. Version of Freetype, Xft2 and fontconfig + 2. Whether TT hinting is being used, or the autohinter + 3. Application being used + 4. Character/Unicode code point that has problems (if applicable) + 5. Version of which operating system + 6. Please include a screenshot, when possible. + +Please check the fonts list archives before reporting problems to cut +down on duplication. diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/Vera.ttf b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/Vera.ttf new file mode 100644 index 000000000..58cd6b5e6 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/Vera.ttf differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraBI.ttf b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraBI.ttf new file mode 100644 index 000000000..b55eee397 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraBI.ttf differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraBd.ttf b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraBd.ttf new file mode 100644 index 000000000..51d6111d7 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraBd.ttf differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraIt.ttf b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraIt.ttf new file mode 100644 index 000000000..cc23c9efd Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraIt.ttf differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMoBI.ttf b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMoBI.ttf new file mode 100644 index 000000000..8624542ed Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMoBI.ttf differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMoBd.ttf b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMoBd.ttf new file mode 100644 index 000000000..9be6547ed Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMoBd.ttf differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMoIt.ttf b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMoIt.ttf new file mode 100644 index 000000000..240492485 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMoIt.ttf differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMono.ttf b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMono.ttf new file mode 100644 index 000000000..139f0b431 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraMono.ttf differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraSe.ttf b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraSe.ttf new file mode 100644 index 000000000..4b4ecc666 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraSe.ttf differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraSeBd.ttf b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraSeBd.ttf new file mode 100644 index 000000000..672bf761f Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/VeraSeBd.ttf differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/local.conf b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/local.conf new file mode 100644 index 000000000..0b8e3a2ee --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/fonts/local.conf @@ -0,0 +1,32 @@ + + + + + + + + serif + + Bitstream Vera Serif + + + + sans-serif + + Bitstream Vera Sans + + + + monospace + + Bitstream Vera Sans Mono + + + diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/AngleField.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/AngleField.php new file mode 100644 index 000000000..a30dbf5bf --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/AngleField.php @@ -0,0 +1,11 @@ +value = $request->get($this->name, $this->default ? '1' : null) === '1'; + } + + function renderBody($name, $id) + { + if ($this->value) + $chk = 'checked="checked"'; + else + $chk = ''; + + echo ''; + echo ''; + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/CheckboxSetField.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/CheckboxSetField.php new file mode 100644 index 000000000..4e0c2b740 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/CheckboxSetField.php @@ -0,0 +1,50 @@ +name = $name; + $this->options = $options; + } + + function init($request) + { + $this->value = array(); + if (is_array($request->get($this->name))) + foreach ($request->get($this->name) as $val) + if (in_array($val, $this->options)) + $this->value[] = $val; + } + + function render() + { + $request = $this->request; + foreach ($this->options as $option) + { + if (is_array($request->get($this->name)) && in_array($option, $request->get($this->name))) + $chk = 'checked="checked"'; + else + $chk = ''; + + $name = $this->name . '[]'; + $id = $this->name . '_' . $option; + echo ''; + echo ' '; + } + } + + function getURLValue() + { + $v = ''; + foreach ($this->value as $value) + $v .= $this->name . '[]=' . $value . '&'; + return $v; + } + } + \ No newline at end of file diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/ColorField.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/ColorField.php new file mode 100644 index 000000000..e356520c8 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/ColorField.php @@ -0,0 +1,25 @@ +getColor($this->name, $this->default); + if ($c === '') + $this->value = null; + else + $this->value = str_pad(dechex(hexdec($c)), 6, '0', STR_PAD_LEFT); + } + + function getRenderValue() + { + return $this->value; + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/CoordinateField.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/CoordinateField.php new file mode 100644 index 000000000..4f8a9c321 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/CoordinateField.php @@ -0,0 +1,18 @@ +value = $request->getCoordinate($this->name, $this->default); + if ($this->value > 1000) + $this->value = 1000; + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/Demo.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/Demo.php new file mode 100644 index 000000000..3c317b2a3 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/Demo.php @@ -0,0 +1,63 @@ +name = $name; + } + + function init() + { + } + + static function create($name) + { + $file = DEMO_PATH . '/demos/' . $name . '.php'; + if (!file_exists($file)) + throw new Exception("Invalid demo: {$name}"); + include $file; + $className = 'Demo_' . $name; + $demo = new $className($name); + $demo->request = Request::getInstance(); + $demo->init(); + foreach ($demo->fields as $field) + { + $field->request = Request::getInstance(); + $field->init(Request::getInstance()); + } + return $demo; + } + + function getFormat() + { + return 'as input'; + } + + function addField($field) + { + $this->fields[$field->name] = $field; + } + + function __toString() + { + return $this->name; + } + + function text() + { + } + + function fval($name) + { + return $this->fields[$name]->value; + } + } + \ No newline at end of file diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/Field.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/Field.php new file mode 100644 index 000000000..b15c8909a --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/Field.php @@ -0,0 +1,52 @@ +name = $name; + $this->default = $default; + + if ($hint == '') + $hint = $name; + + $this->hint = $hint; + } + + function init($request) + { + $this->value = $request->get($this->name, $this->default); + } + + function render() + { + $id = htmlentities($this->name); + echo ' '; + } + + function renderBody($name, $id) + { + echo ''; + } + + function getRenderValue() + { + return $this->value; + } + + function getUrlValue() + { + return urlencode($this->name) . '=' . urlencode($this->value); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/FileSelectField.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/FileSelectField.php new file mode 100644 index 000000000..ab8e30364 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/FileSelectField.php @@ -0,0 +1,83 @@ +name = $name; + $this->path = $path; + $this->options = $options; + + if (!isset($options['show'])) + $this->options['show'] = true; + + if (!isset($options['pattern'])) + $this->options['pattern'] = '/(.*)/'; + } + + function init($request) + { + $this->value = null; + $di = new DirectoryIterator(DEMO_PATH . $this->path); + foreach ($di as $file) + if (!$file->isDot() && strpos($file->getFilename(), '.') !== 0 && preg_match($this->options['pattern'], $file->getFilename())) + { + $this->files[] = $file->getFilename(); + if ($this->value === null && isset($this->options['default']) && $this->options['default'] == $file->getFilename()) + $this->value = $this->options['default']; + + if ($this->request->get($this->name) == $file->getFilename()) + $this->value = $file->getFilename(); + } + + sort($this->files); + + if (!$this->value && count($this->files) > 0) + $this->value = $this->files[0]; + } + + function renderBody($name, $id) + { + if ($this->options['show']) + { + $onch = "document.getElementById('sel_{$id}').src = '{$this->path}/' + this.options[this.selectedIndex].value;"; + } + else + $onch = ''; + + echo ''; + + if ($this->options['show'] && $selected_file) + { + echo '
'; + echo ' '; + echo "               "; + echo '
'; + } + } + + function getURLValue() + { + return $this->name . '=' . $this->value; + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/FloatField.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/FloatField.php new file mode 100644 index 000000000..a9c313492 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/FloatField.php @@ -0,0 +1,16 @@ +value = $request->getFloat($this->name, $this->default); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/FormatSelectField.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/FormatSelectField.php new file mode 100644 index 000000000..b730fdf0c --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/FormatSelectField.php @@ -0,0 +1,11 @@ +value = $request->getInt($this->name, $this->default); + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/Request.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/Request.php new file mode 100644 index 000000000..10366c480 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/Request.php @@ -0,0 +1,135 @@ +vars = $_GET; + + /* + // have to rely on parsing QUERY_STRING, thanks to PHP + // http://bugs.php.net/bug.php?id=39078 + // http://bugs.php.net/bug.php?id=45149 + $all_vars = explode('&', $_SERVER['QUERY_STRING']); + foreach ($all_vars as $keyval) + { + if (strlen($keyval) == 0) + continue; + + if (strpos($keyval, '=') === false) + { + $key = $keyval; + $value = true; + } + else + { + list($key, $value) = explode('=', $keyval); + #$value = str_replace('%2B', '[[PLUS]]', $value); + $value = urldecode($value); + #$value = str_replace('[[PLUS]]', '+', $value); + } + $this->vars[$key] = $value; + } + */ + } + + function get($key, $default = null) + { + if (isset($this->vars[$key])) + return $this->vars[$key]; + else + return $default; + } + + function set($key, $value) + { + $this->vars[$key] = $value; + } + + function getInt($key, $default = 0) + { + $value = self::get($key); + if (strlen($value) > 0) + return intval($value); + else + return $default; + } + + function getFloat($key, $default = 0) + { + $value = self::get($key); + if (strlen($value) > 0) + return floatval($value); + else + return $default; + } + + function getCoordinate($key, $default = 0) + { + $v = self::get($key); + if (strlen($v) > 0 && \WideImage\Coordinate::parse($v) !== null) + return self::get($key); + else + return $default; + } + + function getOption($key, $valid = array(), $default = null) + { + $value = self::get($key); + if ($value !== null && in_array($value, $valid)) + return strval($value); + else + return $default; + } + + function getColor($key, $default = '000000') + { + $value = self::get($key); + if (substr($value, 0, 1) == '#') + $value = substr($value, 1); + + if ($value === '' || preg_match('~^[0-9a-f]{1,6}$~i', $value)) + return $value; + else + return $default; + } + + function getRegex($key, $regex, $default = null) + { + $value = self::get($key); + if ($value !== null && preg_match($regex, $value)) + return $value; + else + return $default; + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/SelectField.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/SelectField.php new file mode 100644 index 000000000..e0520292e --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/SelectField.php @@ -0,0 +1,42 @@ +name = $name; + $this->options = $options; + if ($default === null) + $this->default = $options[0]; + else + $this->default = $default; + } + + function init($request) + { + $this->value = $this->default; + $v = str_replace('+', ' ', $request->get($this->name)); + if (in_array($v, $this->options)) + $this->value = $v; + } + + function renderBody($name, $id) + { + echo ''; + } + } diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/common.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/common.php new file mode 100644 index 000000000..1f326688b --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/helpers/common.php @@ -0,0 +1,37 @@ +get('demo')); + $image = \WideImage\WideImage::load('images/' . $request->get('image')); + + $result = $demo->execute($image, $request); + + $output = new FormatSelectField('output'); + $output->init(Request::getInstance()); + + if ($output->value == 'preset for demo') + $format = $demo->getFormat(); + else + $format = $output->value; + + if ($format === 'as input') + $format = substr($request->get('image'), -3); + + $output = 24; + if ($format == 'png8') + { + $output = 8; + $format = 'png'; + } + elseif ($format == 'png24') + $format = 'png'; + elseif ($format == 'gif') + $output = 8; + + if ($output == 8) + { + $ncolors = new IntField('colors', 255); + $ncolors->init(Request::getInstance()); + + $dither = new CheckboxField('dither', true); + $dither->init(Request::getInstance()); + + $match_palette = new CheckboxField('match_palette', true); + $match_palette->init(Request::getInstance()); + + $result = $result->asPalette($ncolors->value, $dither->value, $match_palette->value); + } + + $result->output($format); + \ No newline at end of file diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/1-rainbow.png b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/1-rainbow.png new file mode 100644 index 000000000..e57d0d2d2 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/1-rainbow.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/2-blue-alpha.png b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/2-blue-alpha.png new file mode 100644 index 000000000..6c31be7a7 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/2-blue-alpha.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/3-smiley.gif b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/3-smiley.gif new file mode 100644 index 000000000..db5c8981f Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/3-smiley.gif differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/4-color-hole.gif b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/4-color-hole.gif new file mode 100644 index 000000000..2170523fb Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/4-color-hole.gif differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/5-circle.png b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/5-circle.png new file mode 100644 index 000000000..096039014 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/5-circle.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/6-logo.gif b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/6-logo.gif new file mode 100644 index 000000000..8c5454b26 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/6-logo.gif differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/7-overlay.png b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/7-overlay.png new file mode 100644 index 000000000..abb310abd Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/7-overlay.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/bg03.bmp b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/bg03.bmp new file mode 100644 index 000000000..7643c37d8 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/bg03.bmp differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/fgnl.jpg b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/fgnl.jpg new file mode 100644 index 000000000..9f0c23e98 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/images/fgnl.jpg differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/index.php b/htdocs/class/libraries/vendor/smottt/wideimage/demo/index.php new file mode 100644 index 000000000..124d61105 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/demo/index.php @@ -0,0 +1,173 @@ +getFilename(), -4) == '.php') + $demos[] = Demo::create(substr($file->getFilename(), 0, -4)); + + usort($demos, 'cmp_demos'); + + function cmp_demos($d1, $d2) + { + if ($d1->order === $d2->order) + return 0; + + return ($d1->order < $d2->order ? -1 : 1); + } + + if (isset($_GET['demo'])) + $activeDemoName = $_GET['demo']; + else + $activeDemoName = null; + + $activeDemo = null; + foreach ($demos as $demo) + if ($demo->name == $activeDemoName) + { + $activeDemo = $demo; + break; + } + + if (!$activeDemo) + $activeDemoName = null; + +?> + + + WideImage -<?php if ($activeDemo) echo " " . $activeDemo->name; ?> demo + + + + + + + +
+ +
+ + diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-circle.gif b/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-circle.gif new file mode 100644 index 000000000..98d07302f Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-circle.gif differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-circle.png b/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-circle.png new file mode 100644 index 000000000..096039014 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-circle.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-diagonal.gif b/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-diagonal.gif new file mode 100644 index 000000000..f6ba14849 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-diagonal.gif differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-smiley.gif b/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-smiley.gif new file mode 100644 index 000000000..db5c8981f Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/demo/masks/mask-smiley.gif differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/CanvasTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/CanvasTest.php new file mode 100644 index 000000000..7341fe4da --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/CanvasTest.php @@ -0,0 +1,50 @@ +getCanvas(); + $this->assertInstanceOf('WideImage\\Canvas', $canvas1); + + $canvas2 = $img->getCanvas(); + $this->assertSame($canvas1, $canvas2); + } + + public function testMagicCallDrawRectangle() + { + $img = WideImage::createTrueColorImage(10, 10); + $canvas = $img->getCanvas(); + $canvas->filledRectangle(1, 1, 5, 5, $img->allocateColorAlpha(255, 0, 0, 64)); + $this->assertRGBAt($img, 3, 3, array('red' => 255, 'green' => 0, 'blue' => 0, 'alpha' => 64)); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/CoordinateTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/CoordinateTest.php new file mode 100644 index 000000000..67ba1efe9 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/CoordinateTest.php @@ -0,0 +1,110 @@ +assertSame(400, Coordinate::evaluate('+200%', 200)); + $this->assertSame(-1, Coordinate::evaluate('-1', 200)); + $this->assertSame(10, Coordinate::evaluate('+10', 200)); + $this->assertSame(40, Coordinate::evaluate('+20%', 200)); + $this->assertSame(-11, Coordinate::evaluate('-11.23', 200)); + $this->assertSame(-30, Coordinate::evaluate('-15%', 200)); + } + + public function testFix() + { + $this->assertSame(10, Coordinate::fix('10%', 100)); + $this->assertSame(10, Coordinate::fix('10', 100)); + + $this->assertSame(-10, Coordinate::fix('-10%', 100)); + $this->assertSame(-1, Coordinate::fix('-1', 100)); + $this->assertSame(-50, Coordinate::fix('-50%', 100)); + $this->assertSame(-100, Coordinate::fix('-100%', 100)); + $this->assertSame(-1, Coordinate::fix('-5%', 20)); + + $this->assertSame(300, Coordinate::fix('150.12%', 200)); + $this->assertSame(150, Coordinate::fix('150', 200)); + + $this->assertSame(100, Coordinate::fix('100%-50%', 200)); + $this->assertSame(200, Coordinate::fix('100%', 200)); + + $this->assertSame(130, Coordinate::fix('50% -20', 300)); + $this->assertSame(12, Coordinate::fix(' 12 - 0', 300)); + + $this->assertSame(15, Coordinate::fix('50%', 30)); + $this->assertSame(15, Coordinate::fix('50%-0', 30)); + $this->assertSame(15, Coordinate::fix('50%+0', 30)); + $this->assertSame(0, Coordinate::fix(' - 50% + 50%', 30)); + $this->assertSame(30, Coordinate::fix(' 50% + 49.6666%', 30)); + } + + public function testAlign() + { + $this->assertSame(0, Coordinate::fix('left', 300, 120)); + $this->assertSame(90, Coordinate::fix('center', 300, 120)); + $this->assertSame(180, Coordinate::fix('right', 300, 120)); + $this->assertSame(0, Coordinate::fix('top', 300, 120)); + $this->assertSame(90, Coordinate::fix('middle', 300, 120)); + $this->assertSame(180, Coordinate::fix('bottom', 300, 120)); + + $this->assertSame(200, Coordinate::fix('bottom+20', 300, 120)); + $this->assertSame(178, Coordinate::fix('-2 + right', 300, 120)); + $this->assertSame(90, Coordinate::fix('right - center', 300, 120)); + } + + public function testAlignWithoutSecondaryCoordinate() + { + $this->assertSame(0, Coordinate::fix('left', 300)); + $this->assertSame(150, Coordinate::fix('center', 300)); + $this->assertSame(300, Coordinate::fix('right', 300)); + $this->assertSame(0, Coordinate::fix('top', 300)); + $this->assertSame(150, Coordinate::fix('middle', 300)); + $this->assertSame(300, Coordinate::fix('bottom', 300)); + + $this->assertSame(320, Coordinate::fix('bottom+20', 300)); + $this->assertSame(280, Coordinate::fix('-20 + right', 300)); + $this->assertSame(150, Coordinate::fix('right - center', 300)); + } + + public function testMultipleOperands() + { + $this->assertSame(6, Coordinate::fix('100%-100+1 + 5', 100)); + $this->assertSame(1, Coordinate::fix('right +1- 100 - 50%', 200)); + $this->assertSame(200, Coordinate::fix('-right+right +100%', 200)); + $this->assertSame(90, Coordinate::fix('100--++++-10', 200)); + } + + /** + * @expectedException WideImage\Exception\InvalidCoordinateException + */ + public function testInvalidSyntaxEndsWithOperator() + { + Coordinate::fix('5+2+', 10); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/ImageTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/ImageTest.php new file mode 100644 index 000000000..6277dc822 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/ImageTest.php @@ -0,0 +1,211 @@ +headers[$name] = $data; + } +} + +/** + * @package Tests + */ +class TestableImage extends TrueColorImage +{ + public $headers = array(); + + public function __destruct() {} + + public function writeHeader($name, $data) + { + $this->headers[$name] = $data; + } +} + +/** + * @package Tests + */ +class ImageTest extends WideImage_TestCase +{ + public function testFactories() + { + $this->assertTrue(WideImage::createTrueColorImage(100, 100) instanceof TrueColorImage); + $this->assertTrue(WideImage::createPaletteImage(100, 100) instanceof PaletteImage); + } + + public function testDestructorUponUnset() + { + $img = TrueColorImage::create(10, 10); + $handle = $img->getHandle(); + + $this->assertTrue(WideImage::isValidImageHandle($handle)); + + unset($img); + + $this->assertFalse(WideImage::isValidImageHandle($handle)); + } + + public function testDestructorUponNull() + { + $img = TrueColorImage::create(10, 10); + $handle = $img->getHandle(); + + $this->assertTrue(WideImage::isValidImageHandle($handle)); + + $img = null; + + $this->assertFalse(WideImage::isValidImageHandle($handle)); + } + + public function testAutoDestruct() + { + $img = TrueColorImage::create(10, 10); + $handle = $img->getHandle(); + + unset($img); + + $this->assertFalse(WideImage::isValidImageHandle($handle)); + } + + public function testAutoDestructWithRelease() + { + $img = TrueColorImage::create(10, 10); + $handle = $img->getHandle(); + + $img->releaseHandle(); + unset($img); + + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + } + + public function testCustomOpMagic() + { + $img = TrueColorImage::create(10, 10); + $result = $img->customOp(123, 'abc'); + $this->assertTrue($result instanceof Image); + $this->assertSame(CustomOp::$args[0], $img); + $this->assertSame(CustomOp::$args[1], 123); + $this->assertSame(CustomOp::$args[2], 'abc'); + } + + public function testCustomOpCaseInsensitive() + { + $img = TrueColorImage::create(10, 10); + $result = $img->CUSTomOP(123, 'abc'); + $this->assertTrue($result instanceof Image); + $this->assertSame(CustomOp::$args[0], $img); + $this->assertSame(CustomOp::$args[1], 123); + $this->assertSame(CustomOp::$args[2], 'abc'); + } + + public function testInternalOpCaseInsensitive() + { + $img = TrueColorImage::create(10, 10); + $result = $img->AUTOcrop(); + $this->assertTrue($result instanceof Image); + } + + public function testOutput() + { + $tmp = WideImage::load(IMG_PATH . 'fgnl.jpg'); + $img = new ImageForOutput($tmp->getHandle()); + + ob_start(); + $img->output('png'); + $data = ob_get_clean(); + + $this->assertEquals(array('Content-length' => strlen($data), 'Content-type' => 'image/png'), $img->headers); + } + + /** + * @group bug + */ + public function testOutputJPG() + { + $tmp = WideImage::load(IMG_PATH . 'fgnl.jpg'); + $img = new ImageForOutput($tmp->getHandle()); + ob_start(); + $img->output('jpg'); + $data = ob_get_clean(); + $this->assertEquals(array('Content-length' => strlen($data), 'Content-type' => 'image/jpg'), $img->headers); + + $tmp = WideImage::load(IMG_PATH . 'fgnl.jpg'); + $img = new ImageForOutput($tmp->getHandle()); + ob_start(); + $img->output('jpeg'); + $data = ob_get_clean(); + $this->assertEquals(array('Content-length' => strlen($data), 'Content-type' => 'image/jpg'), $img->headers); + } + + public function testCanvasInstance() + { + $img = WideImage::load(IMG_PATH . 'fgnl.jpg'); + $canvas1 = $img->getCanvas(); + $this->assertTrue($canvas1 instanceof Canvas); + $canvas2 = $img->getCanvas(); + $this->assertTrue($canvas1 === $canvas2); + } + + public function testSerializeTrueColorImage() + { + $img = WideImage::load(IMG_PATH . 'fgnl.jpg'); + $img2 = unserialize(serialize($img)); + $this->assertEquals(get_class($img2), get_class($img)); + $this->assertTrue($img2->isTrueColor()); + $this->assertTrue($img2->isValid()); + $this->assertFalse($img2->isTransparent()); + $this->assertEquals($img->getWidth(), $img2->getWidth()); + $this->assertEquals($img->getHeight(), $img2->getHeight()); + } + + public function testSerializePaletteImage() + { + $img = WideImage::load(IMG_PATH . '100x100-color-hole.gif'); + $img2 = unserialize(serialize($img)); + $this->assertEquals(get_class($img2), get_class($img)); + $this->assertFalse($img2->isTrueColor()); + $this->assertTrue($img2->isValid()); + $this->assertTrue($img2->isTransparent()); + $this->assertEquals($img->getWidth(), $img2->getWidth()); + $this->assertEquals($img->getHeight(), $img2->getHeight()); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/BMPTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/BMPTest.php new file mode 100644 index 000000000..b37fb5da4 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/BMPTest.php @@ -0,0 +1,98 @@ +mapper = MapperFactory::selectMapper(null, 'bmp'); + } + + public function teardown() + { + $this->mapper = null; + } + + public function imageProvider() + { + return array( + array(IMG_PATH . 'fgnl.bmp', 174, 287), + array(IMG_PATH . 'bmp' . DIRECTORY_SEPARATOR . 'favicon.ico', 30, 30) + ); + } + + /** + * @dataProvider imageProvider + */ + public function testLoad($image, $width, $height) + { + $handle = $this->mapper->load($image); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + $this->assertEquals($width, imagesx($handle)); + $this->assertEquals($height, imagesy($handle)); + imagedestroy($handle); + } + + public function testSaveToString() + { + $handle = de77\BMP::imagecreatefrombmp(IMG_PATH . 'fgnl.bmp'); + ob_start(); + $this->mapper->save($handle); + $string = ob_get_clean(); + $this->assertTrue(strlen($string) > 0); + imagedestroy($handle); + + // string contains valid image data + $handle = $this->mapper->loadFromString($string); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + } + + public function testSaveToFile() + { + $handle = imagecreatefromgif(IMG_PATH . '100x100-color-hole.gif'); + $this->mapper->save($handle, IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.bmp'); + $this->assertTrue(filesize(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.bmp') > 0); + imagedestroy($handle); + + // file is a valid image + $handle = $this->mapper->load(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.bmp'); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + + unlink(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.bmp'); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/FOO.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/FOO.php new file mode 100644 index 000000000..58da41d1a --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/FOO.php @@ -0,0 +1,43 @@ +mapper = MapperFactory::selectMapper(null, 'gd2'); + } + + public function teardown() + { + $this->mapper = null; + + if (file_exists(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gd2')) { + unlink(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gd2'); + } + } + + public function testSaveToString() + { + $handle = imagecreatefromgif(IMG_PATH . '100x100-color-hole.gif'); + ob_start(); + $this->mapper->save($handle); + $string = ob_get_clean(); + $this->assertTrue(strlen($string) > 0); + imagedestroy($handle); + + // string contains valid image data + $handle = imagecreatefromstring($string); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + } + + public function testSaveToFile() + { + $handle = imagecreatefromgif(IMG_PATH . '100x100-color-hole.gif'); + $this->mapper->save($handle, IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gd2'); + $this->assertTrue(filesize(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gd2') > 0); + imagedestroy($handle); + + // file is a valid image + $handle = imagecreatefromgd2(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gd2'); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/GDTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/GDTest.php new file mode 100644 index 000000000..4f3b06fc1 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/GDTest.php @@ -0,0 +1,64 @@ +mapper = MapperFactory::selectMapper(null, 'gd'); + } + + public function teardown() + { + $this->mapper = null; + + if (file_exists(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gd')) { + unlink(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gd'); + } + } + + public function testSaveAndLoad() + { + $handle = imagecreatefromgif(IMG_PATH . '100x100-color-hole.gif'); + $this->mapper->save($handle, IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gd'); + $this->assertTrue(filesize(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gd') > 0); + imagedestroy($handle); + + // file is a valid image + $handle = $this->mapper->load(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gd'); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/GIFTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/GIFTest.php new file mode 100644 index 000000000..9b841240d --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/GIFTest.php @@ -0,0 +1,88 @@ +mapper = MapperFactory::selectMapper(null, 'gif'); + } + + public function teardown() + { + $this->mapper = null; + + if (file_exists(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gif')) { + unlink(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gif'); + } + } + + public function testLoad() + { + $handle = $this->mapper->load(IMG_PATH . '100x100-color-hole.gif'); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + $this->assertEquals(100, imagesx($handle)); + $this->assertEquals(100, imagesy($handle)); + imagedestroy($handle); + } + + public function testSaveToString() + { + $handle = imagecreatefromgif(IMG_PATH . '100x100-color-hole.gif'); + ob_start(); + $this->mapper->save($handle); + $string = ob_get_clean(); + $this->assertTrue(strlen($string) > 0); + imagedestroy($handle); + + // string contains valid image data + $handle = imagecreatefromstring($string); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + } + + public function testSaveToFile() + { + $handle = imagecreatefromgif(IMG_PATH . '100x100-color-hole.gif'); + $this->mapper->save($handle, IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gif'); + $this->assertTrue(filesize(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gif') > 0); + imagedestroy($handle); + + // file is a valid image + $handle = imagecreatefromgif(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.gif'); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/JPEGTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/JPEGTest.php new file mode 100644 index 000000000..b85ea866d --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/JPEGTest.php @@ -0,0 +1,103 @@ +mapper = MapperFactory::selectMapper(null, 'jpg'); + } + + public function teardown() + { + $this->mapper = null; + + if (file_exists(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.jpg')) { + unlink(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.jpg'); + } + } + + public function testLoad() + { + $handle = $this->mapper->load(IMG_PATH . 'fgnl.jpg'); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + $this->assertEquals(174, imagesx($handle)); + $this->assertEquals(287, imagesy($handle)); + imagedestroy($handle); + } + + public function testSaveToString() + { + $handle = imagecreatefromjpeg(IMG_PATH . 'fgnl.jpg'); + ob_start(); + $this->mapper->save($handle); + $string = ob_get_clean(); + $this->assertTrue(strlen($string) > 0); + imagedestroy($handle); + + // string contains valid image data + $handle = imagecreatefromstring($string); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + } + + public function testSaveToFile() + { + $handle = imagecreatefromjpeg(IMG_PATH . 'fgnl.jpg'); + $this->mapper->save($handle, IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.jpg'); + $this->assertTrue(filesize(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.jpg') > 0); + imagedestroy($handle); + + // file is a valid image + $handle = imagecreatefromjpeg(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.jpg'); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + } + + public function testQuality() + { + $handle = imagecreatefromjpeg(IMG_PATH . 'fgnl.jpg'); + + ob_start(); + $this->mapper->save($handle, null, 100); + $hq = ob_get_clean(); + + ob_start(); + $this->mapper->save($handle, null, 10); + $lq = ob_get_clean(); + + $this->assertTrue(strlen($hq) > 0); + $this->assertTrue(strlen($lq) > 0); + $this->assertTrue(strlen($hq) > strlen($lq)); + imagedestroy($handle); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/PNGTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/PNGTest.php new file mode 100644 index 000000000..a2d82830d --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/PNGTest.php @@ -0,0 +1,98 @@ +mapper = MapperFactory::selectMapper(null, 'png'); + } + + public function teardown() + { + $this->mapper = null; + + if (file_exists(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.png')) { + unlink(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.png'); + } + } + + public function testLoad() + { + $handle = $this->mapper->load(IMG_PATH . '100x100-color-hole.png'); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + $this->assertEquals(100, imagesx($handle)); + $this->assertEquals(100, imagesy($handle)); + imagedestroy($handle); + } + + public function testSaveToString() + { + $handle = imagecreatefrompng(IMG_PATH . '100x100-color-hole.png'); + ob_start(); + $this->mapper->save($handle); + $string = ob_get_clean(); + $this->assertTrue(strlen($string) > 0); + imagedestroy($handle); + + // string contains valid image data + $handle = imagecreatefromstring($string); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + } + + public function testSaveToFile() + { + $handle = imagecreatefrompng(IMG_PATH . '100x100-color-hole.png'); + $this->mapper->save($handle, IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.png'); + $this->assertTrue(filesize(IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.png') > 0); + imagedestroy($handle); + + // file is a valid image + $handle = imagecreatefrompng(IMG_PATH . 'temp/test.png'); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + imagedestroy($handle); + } + + public function testSaveCompression() + { + $handle = $this->mapper->load(IMG_PATH . '100x100-rainbow.png'); + $file1 = IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test-comp-0.png'; + $file2 = IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test-comp-9.png'; + $this->mapper->save($handle, $file1, 0); + $this->mapper->save($handle, $file2, 9); + $this->assertTrue(filesize($file1) > filesize($file2)); + + unlink($file1); + unlink($file2); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/TGATest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/TGATest.php new file mode 100644 index 000000000..5b7da68b6 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Mapper/TGATest.php @@ -0,0 +1,82 @@ +mapper = MapperFactory::selectMapper(null, 'tga'); + } + + public function teardown() + { + $this->mapper = null; + } + + public function testLoad() + { + $handle = $this->mapper->load(IMG_PATH . 'splat.tga'); + $this->assertTrue(WideImage::isValidImageHandle($handle)); + $this->assertEquals(100, imagesx($handle)); + $this->assertEquals(100, imagesy($handle)); + imagedestroy($handle); + } + + public function testLoadEmptyFile() + { + $handle = $this->mapper->load(IMG_PATH . 'empty.tga'); + $this->assertFalse($handle); + } + + /** + * @expectedException WideImage\Exception\Exception + */ + public function testSaveToStringNotSupported() + { + $handle = de77\BMP::imagecreatefrombmp(IMG_PATH . 'splat.tga'); + $this->mapper->save($handle); + } + + /** + * @expectedException WideImage\Exception\Exception + */ + public function testSaveToFileNotSupported() + { + $handle = imagecreatefromgif(IMG_PATH . '100x100-color-hole.gif'); + $this->mapper->save($handle, IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'test.bmp'); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/MapperFactoryTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/MapperFactoryTest.php new file mode 100644 index 000000000..4303aeefb --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/MapperFactoryTest.php @@ -0,0 +1,55 @@ +assertInstanceOf("WideImage\\Mapper\\PNG", $mapper); + } + + public function testMapperGIFByURI() + { + $mapper = MapperFactory::selectMapper('uri.gif'); + $this->assertInstanceOf("WideImage\\Mapper\\GIF", $mapper); + } + + public function testMapperJPGByURI() + { + $mapper = MapperFactory::selectMapper('uri.jpg'); + $this->assertInstanceOf("WideImage\\Mapper\\JPEG", $mapper); + } + + public function testMapperBMPByURI() + { + $mapper = MapperFactory::selectMapper('uri.bmp'); + $this->assertInstanceOf("WideImage\\Mapper\\BMP", $mapper); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ApplyConvolutionTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ApplyConvolutionTest.php new file mode 100644 index 000000000..d817124d1 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ApplyConvolutionTest.php @@ -0,0 +1,45 @@ +applyConvolution(array(array(2, 0, 0), array(0, -1, 0), array(0, 0, -1)), 1, 220); + + $this->assertTrue($result instanceof TrueColorImage); + $this->assertTrue($result->isTransparent()); + + $this->assertEquals(100, $result->getWidth()); + $this->assertEquals(100, $result->getHeight()); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ApplyFilterTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ApplyFilterTest.php new file mode 100644 index 000000000..ef68cba50 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ApplyFilterTest.php @@ -0,0 +1,45 @@ +applyFilter(IMG_FILTER_EDGEDETECT); + + $this->assertTrue($result instanceof TrueColorImage); + $this->assertTrue($result->isTransparent()); + + $this->assertEquals(100, $result->getWidth()); + $this->assertEquals(100, $result->getHeight()); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ApplyMaskTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ApplyMaskTest.php new file mode 100644 index 000000000..1c1ee69ad --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ApplyMaskTest.php @@ -0,0 +1,49 @@ +applyMask($mask); + $this->assertTrue($result instanceof TrueColorImage); + $this->assertTrue($result->isTransparent()); + + $this->assertEquals(100, $result->getWidth()); + $this->assertEquals(100, $result->getHeight()); + + $this->assertRGBNear($result->getRGBAt(10, 10), 255, 255, 255); + $this->assertRGBNear($result->getRGBAt(30, 10), 255, 255, 0, 64); + $this->assertRGBNear($result->getRGBAt(60, 10), 0, 0, 255, 0); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/AsGrayscaleTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/AsGrayscaleTest.php new file mode 100644 index 000000000..7d1d53425 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/AsGrayscaleTest.php @@ -0,0 +1,89 @@ +skipUnless(function_exists('imagefilter')); + } + + public function testTransparentGIF() + { + $img = WideImage::load(IMG_PATH . '100x100-color-hole.gif'); + + $gray = $img->asGrayscale(); + $this->assertTrue($gray instanceof PaletteImage); + + $this->assertEquals(100, $gray->getWidth()); + $this->assertEquals(100, $gray->getHeight()); + + $this->assertRGBNear($gray->getRGBAt(10, 10), 227, 227, 227); + $this->assertRGBNear($gray->getRGBAt(90, 10), 28, 28, 28); + $this->assertRGBNear($gray->getRGBAt(90, 90), 150, 150, 150); + $this->assertRGBNear($gray->getRGBAt(10, 90), 76, 76, 76); + + // preserves transparency + $this->assertTrue($gray->isTransparent()); + $this->assertEquals($gray->getColorAt(50, 50), $gray->getTransparentColor()); + } + + public function testTransparentLogoGIF() + { + $img = $this->load('logo.gif'); + $this->assertTransparentColorAt($img, 1, 1); + + $res = $img->asGrayscale(); + $this->assertDimensions($res, 150, 23); + $this->assertInstanceOf("WideImage\\PaletteImage", $res); + + // preserves transparency + $this->assertTrue($res->isTransparent()); + $this->assertTransparentColorAt($res, 1, 1); + } + + public function testPNGAlpha() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + + $gray = $img->asGrayscale(); + $this->assertTrue($gray instanceof TrueColorImage); + $this->assertEquals(100, $gray->getWidth()); + $this->assertEquals(100, $gray->getHeight()); + + $this->assertRGBNear($gray->getRGBAt(25, 25), 29, 29, 29, 32); + $this->assertRGBNear($gray->getRGBAt(75, 25), 29, 29, 29, 64); + $this->assertRGBNear($gray->getRGBAt(75, 75), 29, 29, 29, 96); + $this->assertRGBNear($gray->getRGBAt(25, 75), 0, 0, 0, 127); + + $this->assertFalse($gray->isTransparent()); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/AsNegativeTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/AsNegativeTest.php new file mode 100644 index 000000000..f4f71857a --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/AsNegativeTest.php @@ -0,0 +1,85 @@ +skipUnless(function_exists('imagefilter')); + } + + public function testTransparentGIF() + { + $img = $this->load('100x100-color-hole.gif'); + + $res = $img->asNegative(); + + $this->assertDimensions($res, 100, 100); + $this->assertInstanceOf("WideImage\\PaletteImage", $res); + + $this->assertRGBNear($res->getRGBAt(10, 10), 0, 0, 255); + $this->assertRGBNear($res->getRGBAt(90, 10), 255, 255, 0); + $this->assertRGBNear($res->getRGBAt(90, 90), 255, 0, 255); + $this->assertRGBNear($res->getRGBAt(10, 90), 0, 255, 255); + + // preserves transparency + $this->assertTrue($res->isTransparent()); + $this->assertTransparentColorAt($res, 50, 50); + } + + public function testTransparentLogoGIF() + { + $img = $this->load('logo.gif'); + $this->assertTransparentColorAt($img, 1, 1); + + $res = $img->asNegative(); + $this->assertDimensions($res, 150, 23); + $this->assertInstanceOf("WideImage\\PaletteImage", $res); + + // preserves transparency + $this->assertTrue($res->isTransparent()); + $this->assertTransparentColorAt($res, 1, 1); + } + + public function testPNGAlpha() + { + $img = $this->load('100x100-blue-alpha.png'); + + $res = $img->asNegative(); + + $this->assertDimensions($res, 100, 100); + $this->assertInstanceOf("WideImage\\TrueColorImage", $res); + + $this->assertRGBNear($res->getRGBAt(25, 25), 255, 255, 0, 32); + $this->assertRGBNear($res->getRGBAt(75, 25), 255, 255, 0, 64); + $this->assertRGBNear($res->getRGBAt(75, 75), 255, 255, 0, 96); + $this->assertRGBNear($res->getRGBAt(25, 75), 255, 255, 255, 127); + + $this->assertFalse($res->isTransparent()); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/AutoCrop.test.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/AutoCrop.test.php new file mode 100644 index 000000000..0d0502878 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/AutoCrop.test.php @@ -0,0 +1,56 @@ +autocrop(); + $this->assertTrue($cropped instanceof TrueColorImage); + $this->assertEquals(71, $cropped->getWidth()); + $this->assertEquals(70, $cropped->getHeight()); + + $this->assertRGBNear($cropped->getRGBAt(10, 10), 255, 0, 0); + } + + public function testAutocropHalfImageBug() + { + $img = WideImage::load(IMG_PATH . '100x100-red-spot-half-cut.png'); + + $cropped = $img->autocrop(); + $this->assertTrue($cropped instanceof TrueColorImage); + $this->assertEquals(22, $cropped->getWidth()); + $this->assertEquals(23, $cropped->getHeight()); + + $this->assertRGBNear($cropped->getRGBAt(10, 10), 255, 0, 0); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/CorrectGammaTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/CorrectGammaTest.php new file mode 100644 index 000000000..06d6eb134 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/CorrectGammaTest.php @@ -0,0 +1,45 @@ +correctGamma(1, 2); + + $this->assertTrue($result instanceof PaletteImage); + $this->assertTrue($result->isTransparent()); + + $this->assertEquals(100, $result->getWidth()); + $this->assertEquals(100, $result->getHeight()); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/CropTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/CropTest.php new file mode 100644 index 000000000..8e382402f --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/CropTest.php @@ -0,0 +1,113 @@ +crop('10%', 15, 50, '40%'); + + $this->assertTrue($cropped instanceof PaletteImage); + $this->assertTrue($cropped->isTransparent()); + $this->assertEquals(50, $cropped->getWidth()); + $this->assertEquals(40, $cropped->getHeight()); + + $this->assertRGBNear($cropped->getRGBAt(39, 9), 255, 255, 0); + $this->assertRGBNear($cropped->getRGBAt(40, 9), 0, 0, 255); + $this->assertRGBNear($cropped->getRGBAt(14, 35), 255, 0, 0); + $this->assertRGBNear($cropped->getRGBAt(16, 11), $cropped->getTransparentColorRGB()); + } + + public function testCropPNGAlpha() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + + $cropped = $img->crop(10, 10, 50, 50); + + $this->assertTrue($cropped instanceof TrueColorImage); + $this->assertFalse($cropped->isTransparent()); + $this->assertEquals(50, $cropped->getWidth()); + $this->assertEquals(50, $cropped->getHeight()); + + $this->assertRGBNear($cropped->getRGBAt(39, 39), 0, 0, 255, 32); + $this->assertRGBNear($cropped->getRGBAt(40, 40), 0, 0, 255, 96); + } + + public function testCropHasCorrectSize() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + + $cropped = $img->crop(10, 10, 10, 10); + $this->assertEquals(10, $cropped->getWidth()); + $this->assertEquals(10, $cropped->getHeight()); + + $cropped = $img->crop(10, 20, 100, 200); + $this->assertEquals(90, $cropped->getWidth()); + $this->assertEquals(80, $cropped->getHeight()); + } + + public function testCropIsNormalized() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + + $cropped = $img->crop(-10, -20, 100, 100); + $this->assertEquals(90, $cropped->getWidth()); + $this->assertEquals(80, $cropped->getHeight()); + + $cropped = $img->crop(10, 20, 140, 170); + $this->assertEquals(90, $cropped->getWidth()); + $this->assertEquals(80, $cropped->getHeight()); + + $cropped = $img->crop(-10, -20, 140, 170); + $this->assertEquals(100, $cropped->getWidth()); + $this->assertEquals(100, $cropped->getHeight()); + } + + /** + * @expectedException WideImage\Exception\Exception + */ + public function testCropCutsAreaOutsideBoundaries() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + $cropped = $img->crop(120, 100, 1, 2); + } + + /** + * @expectedException WideImage\Exception\Exception + */ + public function testCropCutsAreaNegativePosition() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + $cropped = $img->crop(-150, -200, 50, 50); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/CustomOp.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/CustomOp.php new file mode 100644 index 000000000..6e24d1c8d --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/CustomOp.php @@ -0,0 +1,18 @@ +copy(); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/FlipTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/FlipTest.php new file mode 100644 index 000000000..d68074e9c --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/FlipTest.php @@ -0,0 +1,57 @@ +assertRGBEqual($img->getRGBAt(5, 5), 255, 255, 0); + $this->assertRGBEqual($img->getRGBAt(95, 5), 0, 0, 255); + $this->assertRGBEqual($img->getRGBAt(95, 95), 0, 255, 0); + $this->assertRGBEqual($img->getRGBAt(5, 95), 255, 0, 0); + + $new = $img->flip(); + + $this->assertTrue($new instanceof PaletteImage); + + $this->assertEquals(100, $new->getWidth()); + $this->assertEquals(100, $new->getHeight()); + + $this->assertRGBEqual($new->getRGBAt(5, 95), 255, 255, 0); + $this->assertRGBEqual($new->getRGBAt(95, 95), 0, 0, 255); + $this->assertRGBEqual($new->getRGBAt(95, 5), 0, 255, 0); + $this->assertRGBEqual($new->getRGBAt(5, 5), 255, 0, 0); + + $this->assertTrue($new->isTransparent()); + $this->assertRGBEqual($new->getRGBAt(50, 50), $img->getTransparentColorRGB()); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/GetChannelsTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/GetChannelsTest.php new file mode 100644 index 000000000..8e500d0e6 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/GetChannelsTest.php @@ -0,0 +1,130 @@ +getChannels('red', 'alpha'); + $this->assertTrue($copy instanceof PaletteImage); + $this->assertTrue($copy->isValid()); + $this->assertFalse($copy->isTrueColor()); + $this->assertTrue($copy->isTransparent()); + + $this->assertRGBEqual($copy->getRGBAt(15, 15), 255, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 15), 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(15, 85), 255, 0, 0); + $this->assertEquals($copy->getTransparentColor(), $copy->getColorAt(50, 50)); + + $copy = $img->getChannels('red'); + $this->assertTrue($copy instanceof PaletteImage); + $this->assertTrue($copy->isValid()); + $this->assertFalse($copy->isTrueColor()); + $this->assertTrue($copy->isTransparent()); + + $this->assertRGBEqual($copy->getRGBAt(15, 15), 255, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 15), 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(15, 85), 255, 0, 0); + $this->assertEquals($copy->getTransparentColor(), $copy->getColorAt(50, 50)); + + $copy = $img->getChannels('green'); + $this->assertTrue($copy instanceof PaletteImage); + $this->assertTrue($copy->isValid()); + $this->assertFalse($copy->isTrueColor()); + $this->assertTrue($copy->isTransparent()); + + $this->assertRGBEqual($copy->getRGBAt(15, 15), 0, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 15), 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 0, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(15, 85), 0, 0, 0); + $this->assertEquals($copy->getTransparentColor(), $copy->getColorAt(50, 50)); + } + + public function testCopySingleChannel() + { + $img = WideImage::load(IMG_PATH . '100x100-rgbyg.png'); + + $copy = $img->getChannels('red'); + $this->assertFalse($img->getHandle() === $copy->getHandle()); + $this->assertTrue($copy instanceof TrueColorImage); + $this->assertTrue($copy->isValid()); + $this->assertTrue($copy->isTrueColor()); + $this->assertRGBEqual($copy->getRGBAt(15, 15), 0, 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 15), 255, 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 255, 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(15, 85), 0, 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(50, 50), 127, 0, 0, 0); + /* + $copy = $img->copyChannels('green'); + $this->assertFalse($img->getHandle() === $copy->getHandle()); + $this->assertTrue($copy instanceof TrueColorImage); + $this->assertTrue($copy->isValid()); + $this->assertTrue($copy->isTrueColor()); + $this->assertRGBEqual($copy->getRGBAt(15, 15), 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 15), 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 0, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(15, 85), 0, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(50, 50), 0, 127, 0); + + $copy = $img->copyChannels('blue'); + $this->assertFalse($img->getHandle() === $copy->getHandle()); + $this->assertTrue($copy instanceof TrueColorImage); + $this->assertTrue($copy->isValid()); + $this->assertTrue($copy->isTrueColor()); + $this->assertRGBEqual($copy->getRGBAt(15, 15), 0, 0, 255); + $this->assertRGBEqual($copy->getRGBAt(85, 15), 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(15, 85), 0, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(50, 50), 0, 0, 127); + + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + $copy = $img->copyChannels('alpha'); + $this->assertRGBNear($copy->getRGBAt(25, 25), 0, 0, 0, 0.25 * 127); + $this->assertRGBNear($copy->getRGBAt(75, 25), 0, 0, 0, 0.5 * 127); + $this->assertRGBNear($copy->getRGBAt(75, 75), 0, 0, 0, 0.75 * 127); + $this->assertRGBNear($copy->getRGBAt(25, 75), 0, 0, 0, 127); + */ + } + + public function testCopyCombinedChannels() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + $copy = $img->getChannels('blue', 'alpha'); + $this->assertRGBNear($copy->getRGBAt(25, 25), 0, 0, 255, 0.25 * 127); + $this->assertRGBNear($copy->getRGBAt(75, 25), 0, 0, 255, 0.5 * 127); + $this->assertRGBNear($copy->getRGBAt(75, 75), 0, 0, 255, 0.75 * 127); + $this->assertRGBNear($copy->getRGBAt(25, 75), 0, 0, 0, 127); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/GetMaskTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/GetMaskTest.php new file mode 100644 index 000000000..915a8cb2c --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/GetMaskTest.php @@ -0,0 +1,65 @@ +getMask(); + $this->assertTrue($mask instanceof TrueColorImage); + + $this->assertFalse($mask->isTransparent()); + $this->assertEquals(100, $mask->getWidth()); + $this->assertEquals(100, $mask->getHeight()); + + $this->assertRGBNear($mask->getRGBAt(10, 10), 255, 255, 255); + $this->assertRGBNear($mask->getRGBAt(90, 90), 255, 255, 255); + $this->assertRGBNear($mask->getRGBAt(50, 50), 0, 0, 0); + } + + public function testGetMaskPNGAlpha() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + + $mask = $img->getMask(); + $this->assertTrue($mask instanceof TrueColorImage); + + $this->assertFalse($mask->isTransparent()); + $this->assertEquals(100, $mask->getWidth()); + $this->assertEquals(100, $mask->getHeight()); + + $this->assertRGBNear($mask->getRGBAt(25, 25), 192, 192, 192); + $this->assertRGBNear($mask->getRGBAt(75, 25), 128, 128, 128); + $this->assertRGBNear($mask->getRGBAt(75, 75), 64, 64, 64); + $this->assertRGBNear($mask->getRGBAt(25, 75), 0, 0, 0); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/MergeTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/MergeTest.php new file mode 100644 index 000000000..e44ec54d4 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/MergeTest.php @@ -0,0 +1,98 @@ +merge($overlay, 0, 0, 0); + + $this->assertEquals(100, $res->getWidth()); + $this->assertEquals(100, $res->getHeight()); + + $rgb = $res->getRGBAt(5, 5); + $this->assertRGBAt($res, 5, 5, array('red' => 255, 'green' => 255, 'blue' => 0, 'alpha' => 0)); + $this->assertRGBAt($res, 40, 40, array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 127)); + $this->assertRGBAt($res, 95, 5, array('red' => 0, 'green' => 0, 'blue' => 255, 'alpha' => 0)); + $this->assertRGBAt($res, 60, 40, array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 127)); + $this->assertRGBAt($res, 95, 95, array('red' => 0, 'green' => 255, 'blue' => 0, 'alpha' => 0)); + $this->assertRGBAt($res, 60, 60, array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 127)); + $this->assertRGBAt($res, 5, 95, array('red' => 255, 'green' => 0, 'blue' => 0, 'alpha' => 0)); + $this->assertRGBAt($res, 40, 60, array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 127)); + } + + public function testMergeOpacityHalf() + { + $img = WideImage::load(IMG_PATH . '100x100-color-hole.png'); + $overlay = WideImage::load(IMG_PATH . '100x100-square-overlay.png'); + + $res = $img->merge($overlay, 0, 0, 50); + + $this->assertEquals(100, $res->getWidth()); + $this->assertEquals(100, $res->getHeight()); + + $rgb = $res->getRGBAt(5, 5); + $this->assertRGBAt($res, 5, 5, array('red' => 255, 'green' => 255, 'blue' => 127, 'alpha' => 0)); + $this->assertRGBAt($res, 40, 40, array('red' => 127, 'green' => 127, 'blue' => 127, 'alpha' => 0)); + $this->assertRGBAt($res, 95, 5, array('red' => 0, 'green' => 0, 'blue' => 255, 'alpha' => 0)); + $this->assertRGBAt($res, 60, 40, array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 127)); + $this->assertRGBAt($res, 95, 95, array('red' => 0, 'green' => 127, 'blue' => 0, 'alpha' => 0)); + + // these two should definitely pass ... + + #$this->assertRGBAt($res, 60, 60, array('red' => 127, 'green' => 127, 'blue' => 127, 'alpha' => 0)); + $this->assertRGBAt($res, 5, 95, array('red' => 255, 'green' => 0, 'blue' => 0, 'alpha' => 0)); + #$this->assertRGBAt($res, 40, 60, array('red' => 255, 'green' => 127, 'blue' => 127, 'alpha' => 0)); + } + + public function testMergeOpacityFull() + { + $img = WideImage::load(IMG_PATH . '100x100-color-hole.png'); + $overlay = WideImage::load(IMG_PATH . '100x100-square-overlay.png'); + + $res = $img->merge($overlay, 0, 0, 100); + + $this->assertEquals(100, $res->getWidth()); + $this->assertEquals(100, $res->getHeight()); + + $rgb = $res->getRGBAt(5, 5); + $this->assertRGBAt($res, 5, 5, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0)); + $this->assertRGBAt($res, 40, 40, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0)); + $this->assertRGBAt($res, 95, 5, array('red' => 0, 'green' => 0, 'blue' => 255, 'alpha' => 0)); + $this->assertRGBAt($res, 60, 40, array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 127)); + $this->assertRGBAt($res, 95, 95, array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0)); + $this->assertRGBAt($res, 60, 60, array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0)); + $this->assertRGBAt($res, 5, 95, array('red' => 255, 'green' => 0, 'blue' => 0, 'alpha' => 0)); + $this->assertRGBAt($res, 40, 60, array('red' => 255, 'green' => 0, 'blue' => 0, 'alpha' => 0)); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/MirrorTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/MirrorTest.php new file mode 100644 index 000000000..32f48c1b3 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/MirrorTest.php @@ -0,0 +1,57 @@ +assertRGBEqual($img->getRGBAt(5, 5), 255, 255, 0); + $this->assertRGBEqual($img->getRGBAt(95, 5), 0, 0, 255); + $this->assertRGBEqual($img->getRGBAt(95, 95), 0, 255, 0); + $this->assertRGBEqual($img->getRGBAt(5, 95), 255, 0, 0); + + $new = $img->mirror(); + + $this->assertTrue($new instanceof PaletteImage); + + $this->assertEquals(100, $new->getWidth()); + $this->assertEquals(100, $new->getHeight()); + + $this->assertRGBEqual($new->getRGBAt(95, 5), 255, 255, 0); + $this->assertRGBEqual($new->getRGBAt(5, 5), 0, 0, 255); + $this->assertRGBEqual($new->getRGBAt(5, 95), 0, 255, 0); + $this->assertRGBEqual($new->getRGBAt(95, 95), 255, 0, 0); + + $this->assertTrue($new->isTransparent()); + $this->assertRGBEqual($new->getRGBAt(50, 50), $img->getTransparentColorRGB()); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/MyOperation.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/MyOperation.php new file mode 100644 index 000000000..b9d79aeff --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/MyOperation.php @@ -0,0 +1,8 @@ +resizeCanvas(180, 180, 0, 0); + $this->assertDimensions($resized, 180, 180); + } + + public function testResizeCanvasDown() + { + $img = WideImage::createTrueColorImage(160, 120); + $resized = $img->resizeCanvas(30, 100, 0, 0); + $this->assertDimensions($resized, 30, 100); + } + + public function testResizeCanvasPositionsCenter() + { + $img = WideImage::createTrueColorImage(20, 20); + $black = $img->allocateColor(0, 0, 0); + $white = $img->allocateColor(255, 255, 255); + $img->fill(0, 0, $black); + + $res = $img->resizeCanvas(40, 40, 'center', 'center', $white); + $this->assertRGBAt($res, 5, 5, $white); + $this->assertRGBAt($res, 35, 35, $white); + $this->assertRGBAt($res, 5, 35, $white); + $this->assertRGBAt($res, 35, 5, $white); + $this->assertRGBAt($res, 20, 20, $black); + } + + public function testResizeCanvasPositionsCorner() + { + $img = WideImage::createTrueColorImage(20, 20); + $black = $img->allocateColor(0, 0, 0); + $white = $img->allocateColor(255, 255, 255); + $img->fill(0, 0, $black); + + $res = $img->resizeCanvas(40, 40, 'bottom', 'right', $white); + $this->assertRGBAt($res, 5, 5, $white); + $this->assertRGBAt($res, 35, 35, $black); + $this->assertRGBAt($res, 5, 35, $white); + $this->assertRGBAt($res, 35, 5, $white); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ResizeTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ResizeTest.php new file mode 100644 index 000000000..46435971b --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/ResizeTest.php @@ -0,0 +1,291 @@ +getMock('WideImage\\Operation\\Resize', array('execute')); + $img = $this->getMock('WideImage\\PaletteImage', array('getOperation'), array(imagecreate(10, 10))); + + $img->expects($this->exactly(2))-> + method('getOperation')->with('Resize')-> + will($this->returnValue($op)); + + $op->expects($this->at(0))-> + method('execute')->with($img, 'WIDTH', 'HEIGHT', 'FIT', 'SCALE'); + + $op->expects($this->at(1))-> + method('execute')->with($img, null, null, 'inside', 'any'); + + $img->resize('WIDTH', 'HEIGHT', 'FIT', 'SCALE'); + $img->resize(); + } + + public function testResultTypeIsSameAsInput() + { + $this->assertInstanceOf("WideImage\\PaletteImage", WideImage::createPaletteImage(20, 20)->resize(10, 10)); + $this->assertInstanceOf("WideImage\\TrueColorImage", WideImage::createTrueColorImage(20, 20)->resize(10, 10)); + } + + public function testResizeWithoutParametersDoesNothing() + { + $img = WideImage::createTrueColorImage(70, 20); + $res = $img->resize(); + $this->assertDimensions($res, $img->getWidth(), $img->getHeight()); + } + + public function testPreservesTransparency() + { + $img = $this->load('100x100-color-hole.gif'); + $this->assertTrue($img->isTransparent()); + $res = $img->resize(50, 50); + $this->assertTrue($res->isTransparent()); + $this->assertTransparentColorMatch($img, $res); + $this->assertEquals($res->getColorAt(25, 25), $res->getTransparentColor()); + } + + public function testFitFill() + { + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(100, 50, 'fill'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 30, 'fill'), 120, 30); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(20, 130, 'fill'), 20, 130); + } + + public function testFitOutside() + { + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(100, 50, 'outside'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 30, 'outside'), 120, 60); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(20, 30, 'outside'), 60, 30); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(20, 100, 'outside'), 200, 100); + } + + public function testFitInside() + { + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(100, 50, 'inside'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 30, 'inside'), 60, 30); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(20, 30, 'inside'), 20, 10); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(20, 100, 'inside'), 20, 10); + $this->assertDimensions(WideImage::createPaletteImage(950, 266)->resize(256, null, 'inside'), 256, 72); + } + + public function testScaleDown() + { + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(100, 50, 'fill', 'down'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 60, 'fill', 'down'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 40, 'fill', 'down'), 120, 40); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 60, 'fill', 'down'), 90, 60); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 30, 'fill', 'down'), 90, 30); + + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(100, 50, 'inside', 'down'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 60, 'inside', 'down'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 40, 'inside', 'down'), 80, 40); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 60, 'inside', 'down'), 90, 45); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 30, 'inside', 'down'), 60, 30); + + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(100, 50, 'outside', 'down'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 60, 'outside', 'down'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 40, 'outside', 'down'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 60, 'outside', 'down'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 30, 'outside', 'down'), 90, 45); + } + + public function testScaleUp() + { + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(100, 50, 'fill', 'up'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 60, 'fill', 'up'), 120, 60); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 40, 'fill', 'up'), 120, 40); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 60, 'fill', 'up'), 90, 60); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 30, 'fill', 'up'), 100, 50); + + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(100, 50, 'inside', 'up'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 60, 'inside', 'up'), 120, 60); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 40, 'inside', 'up'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 60, 'inside', 'up'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 30, 'inside', 'up'), 100, 50); + + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(100, 50, 'outside', 'up'), 100, 50); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 60, 'outside', 'up'), 120, 60); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(120, 40, 'outside', 'up'), 120, 60); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 60, 'outside', 'up'), 120, 60); + $this->assertDimensions(WideImage::createPaletteImage(100, 50)->resize(90, 30, 'outside', 'up'), 100, 50); + } + + public function testResizeFill() + { + $img = WideImage::load(IMG_PATH . '100x100-color-hole.gif'); + $resized = $img->resize(50, 20, 'fill'); + $this->assertTrue($resized instanceof Image); + $this->assertTrue($resized->isTransparent()); + $this->assertEquals(50, $resized->getWidth()); + $this->assertEquals(20, $resized->getHeight()); + $this->assertRGBEqual($resized->getRGBAt(5, 5), 255, 255, 0); + $this->assertRGBEqual($resized->getRGBAt(45, 5), 0, 0, 255); + $this->assertRGBEqual($resized->getRGBAt(45, 15), 0, 255, 0); + $this->assertRGBEqual($resized->getRGBAt(5, 15), 255, 0, 0); + + $this->assertRGBEqual($resized->getRGBAt(25, 10), 255, 255, 255); + $this->assertRGBEqual($img->getTransparentColorRGB(), 255, 255, 255); + } + + public function testNullDimensionsAreCalculatedForFill() + { + $img = TrueColorImage::create(100, 50); + $resized = $img->resize(30, null, 'fill'); + $this->assertEquals(30, $resized->getWidth()); + $this->assertEquals(15, $resized->getHeight()); + + $img = TrueColorImage::create(100, 50); + $resized = $img->resize(null, 30, 'fill'); + $this->assertEquals(60, $resized->getWidth()); + $this->assertEquals(30, $resized->getHeight()); + + $img = TrueColorImage::create(100, 50); + $resized = $img->resize(30, 30, 'fill'); + $this->assertEquals(30, $resized->getWidth()); + $this->assertEquals(30, $resized->getHeight()); + + $img = TrueColorImage::create(100, 50); + $resized = $img->resize(30, 40, 'fill'); + $this->assertEquals(30, $resized->getWidth()); + $this->assertEquals(40, $resized->getHeight()); + } + + public function testResizeInside() + { + $img = WideImage::load(IMG_PATH . '100x100-color-hole.gif'); + $resized = $img->resize(50, 20, 'inside'); + $this->assertTrue($resized instanceof Image); + $this->assertTrue($resized->isTransparent()); + $this->assertEquals(20, $resized->getWidth()); + $this->assertEquals(20, $resized->getHeight()); + /* + $this->assertRGBEqual($resized->getRGBAt(5, 5), 255, 255, 0); + $this->assertRGBEqual($resized->getRGBAt(45, 5), 0, 0, 255); + $this->assertRGBEqual($resized->getRGBAt(45, 15), 0, 255, 0); + $this->assertRGBEqual($resized->getRGBAt(5, 15), 255, 0, 0); + $this->assertRGBEqual($resized->getRGBAt(25, 10), 255, 255, 255); + $this->assertRGBEqual($img->getTransparentColorRGB(), 255, 255, 255); + */ + } + + public function testResizeDown() + { + $img = TrueColorImage::create(100, 100); + $resized = $img->resizeDown(30); + $this->assertEquals(30, $resized->getWidth()); + $this->assertEquals(30, $resized->getHeight()); + + $img = TrueColorImage::create(200, 100); + $resized = $img->resizeDown(100); + $this->assertEquals(100, $resized->getWidth()); + $this->assertEquals(50, $resized->getHeight()); + + $img = TrueColorImage::create(200, 100); + $resized = $img->resizeDown(null, 30); + $this->assertEquals(60, $resized->getWidth()); + $this->assertEquals(30, $resized->getHeight()); + + $img = TrueColorImage::create(200, 100); + $resized = $img->resizeDown(201); + $this->assertEquals($img->getWidth(), $resized->getWidth()); + $this->assertEquals($img->getHeight(), $resized->getHeight()); + + $img = TrueColorImage::create(200, 100); + $resized = $img->resizeDown(null, 300); + $this->assertEquals($img->getWidth(), $resized->getWidth()); + $this->assertEquals($img->getHeight(), $resized->getHeight()); + } + + public function testResizeUp() + { + $img = TrueColorImage::create(100, 100); + $resized = $img->resizeUp(300); + $this->assertEquals(300, $resized->getWidth()); + $this->assertEquals(300, $resized->getHeight()); + + $img = TrueColorImage::create(200, 100); + $resized = $img->resizeUp(300); + $this->assertEquals(300, $resized->getWidth()); + $this->assertEquals(150, $resized->getHeight()); + + $img = TrueColorImage::create(20, 10); + $resized = $img->resizeUp(null, 30); + $this->assertEquals(60, $resized->getWidth()); + $this->assertEquals(30, $resized->getHeight()); + + $img = TrueColorImage::create(200, 100); + $resized = $img->resizeUp(199); + $this->assertEquals($img->getWidth(), $resized->getWidth()); + $this->assertEquals($img->getHeight(), $resized->getHeight()); + + $img = TrueColorImage::create(200, 100); + $resized = $img->resizeUp(null, 10); + $this->assertEquals($img->getWidth(), $resized->getWidth()); + $this->assertEquals($img->getHeight(), $resized->getHeight()); + } + + /** + * @group bugs + */ + public function testResizeBug214() + { + $img = TrueColorImage::create(1600, 1200); + $op = new ResizeTestable(); + $dim = $op->prepareDimensions($img, 214, null, 'outside'); + $this->assertEquals(214, $dim['width']); + $this->assertEquals(161, $dim['height']); + } + + /** + * https://sourceforge.net/tracker/?func=detail&aid=3312764&group_id=190526&atid=933712 + * @group bugs + */ + public function testResizeBug950to256() + { + $img = TrueColorImage::create(950, 266); + $op = new ResizeTestable(); + $dim = $op->prepareDimensions($img, 256, null, 'inside'); + $this->assertEquals(256, $dim['width']); + $this->assertEquals(72, $dim['height']); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/RotateTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/RotateTest.php new file mode 100644 index 000000000..605a6eba7 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/RotateTest.php @@ -0,0 +1,64 @@ +skipUnless(function_exists('imagerotate')); + } + + public function testRotateAlphaSafe() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + $this->assertRGBEqual($img->getRGBAt(25, 25), 0, 0, 255, round(128 / 4)); + $this->assertRGBEqual($img->getRGBAt(75, 25), 0, 0, 255, round(2 * 128 / 4)); + $this->assertRGBEqual($img->getRGBAt(75, 75), 0, 0, 255, round(3 * 128 / 4)); + $this->assertRGBEqual($img->getRGBAt(25, 75), 0, 0, 0, 127); + $new = $img->rotate(90, null); + $this->assertEquals(100, $new->getWidth()); + $this->assertEquals(100, $new->getHeight()); + } + + public function testRotateCounterClockwise90() + { + $img = WideImage::load(IMG_PATH . 'fgnl.jpg'); + $new = $img->rotate(-90); + $this->assertEquals(287, $new->getWidth()); + $this->assertEquals(174, $new->getHeight()); + } + + public function testRotate45() + { + $img = WideImage::load(IMG_PATH . '100x100-rainbow.png'); + $new = $img->rotate(45); + $this->assertEquals(141, $new->getWidth()); + $this->assertEquals(141, $new->getHeight()); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/RoundCornersTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/RoundCornersTest.php new file mode 100644 index 000000000..077d13040 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/RoundCornersTest.php @@ -0,0 +1,60 @@ +roundCorners(30, $img->allocateColor(255, 255, 255), WideImage::SIDE_ALL); + + $this->assertEquals(100, $res->getWidth()); + $this->assertEquals(100, $res->getHeight()); + + $this->assertRGBAt($res, 5, 5, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0)); + $this->assertRGBAt($res, 95, 5, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0)); + $this->assertRGBAt($res, 95, 95, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0)); + $this->assertRGBAt($res, 5, 95, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0)); + } + + public function testTransparentCorner() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + $res = $img->roundCorners(30, null, WideImage::SIDE_ALL); + + $this->assertEquals(100, $res->getWidth()); + $this->assertEquals(100, $res->getHeight()); + + $this->assertRGBAt($res, 5, 5, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127)); + $this->assertRGBAt($res, 95, 5, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127)); + $this->assertRGBAt($res, 95, 95, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127)); + $this->assertRGBAt($res, 5, 95, array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127)); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/UnsharpTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/UnsharpTest.php new file mode 100644 index 000000000..6e106c74d --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/Operation/UnsharpTest.php @@ -0,0 +1,45 @@ +unsharp(10, 5, 1); + + $this->assertTrue($result instanceof PaletteImage); + $this->assertTrue($result->isTransparent()); + + $this->assertEquals(100, $result->getWidth()); + $this->assertEquals(100, $result->getHeight()); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/OperationFactoryTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/OperationFactoryTest.php new file mode 100644 index 000000000..187a0afe0 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/OperationFactoryTest.php @@ -0,0 +1,55 @@ +assertSame($op1, $op2); + } + + /** + * @expectedException WideImage\Exception\UnknownImageOperationException + */ + public function testNoOperation() + { + $op = OperationFactory::get('NoSuchOp'); + } + + public function testUserDefinedOp() + { + $op = OperationFactory::get('MyOperation'); + $this->assertTrue($op instanceof MyOperation); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/PaletteImageTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/PaletteImageTest.php new file mode 100644 index 000000000..7eb17d23b --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/PaletteImageTest.php @@ -0,0 +1,105 @@ +assertTrue($img instanceof PaletteImage); + $this->assertTrue($img->isValid()); + $this->assertFalse($img->isTrueColor()); + } + + public function testCopy() + { + $img = WideImage::load(IMG_PATH . '100x100-color-hole.gif'); + $this->assertTrue($img instanceof PaletteImage); + $this->assertTrue($img->isValid()); + $this->assertFalse($img->isTrueColor()); + $this->assertTrue($img->isTransparent()); + $this->assertRGBEqual($img->getRGBAt(15, 15), 255, 255, 0); + $this->assertRGBEqual($img->getRGBAt(85, 15), 0, 0, 255); + $this->assertRGBEqual($img->getRGBAt(85, 85), 0, 255, 0); + $this->assertRGBEqual($img->getRGBAt(15, 85), 255, 0, 0); + $this->assertTrue($img->getTransparentColor() === $img->getColorAt(50, 50)); + + $copy = $img->copy(); + $this->assertFalse($img->getHandle() === $copy->getHandle()); + + $this->assertTrue($copy instanceof PaletteImage); + $this->assertTrue($copy->isValid()); + $this->assertFalse($copy->isTrueColor()); + $this->assertTrue($copy->isTransparent()); + $this->assertRGBEqual($copy->getRGBAt(15, 15), 255, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 15), 0, 0, 255); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 0, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(15, 85), 255, 0, 0); + $this->assertTrue($copy->getTransparentColor() === $copy->getColorAt(50, 50)); + + $this->assertSame($img->getTransparentColorRGB(), $copy->getTransparentColorRGB()); + } + + public function testCopyNoAlpha() + { + $img = WideImage::load(IMG_PATH . '100x100-color-hole.gif'); + $this->assertRGBEqual($img->getRGBAt(85, 85), 0, 255, 0); + $copy = $img->copyNoAlpha(); + $this->assertFalse($img->getHandle() === $copy->getHandle()); + $this->assertTrue($copy instanceof PaletteImage); + $this->assertTrue($copy->isValid()); + $this->assertFalse($copy->isTrueColor()); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 0, 255, 0); + } + + public function testAsTrueColor() + { + $img = WideImage::load(IMG_PATH . '100x100-color-hole.gif'); + $this->assertTrue($img instanceof PaletteImage); + $this->assertTrue($img->isValid()); + + $copy = $img->asTrueColor(); + $this->assertFalse($img->getHandle() === $copy->getHandle()); + + $this->assertTrue($copy instanceof TrueColorImage); + $this->assertTrue($copy->isValid()); + $this->assertTrue($copy->isTrueColor()); + $this->assertTrue($copy->isTransparent()); + $this->assertRGBEqual($copy->getRGBAt(15, 15), 255, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 15), 0, 0, 255); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 0, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(15, 85), 255, 0, 0); + + $this->assertEquals($copy->getRGBAt(50, 50), $copy->getTransparentColorRGB()); + $rgb = $copy->getTransparentColorRGB(); + $this->assertRGBEqual($img->getTransparentColorRGB(), $rgb['red'], $rgb['green'], $rgb['blue']); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/TrueColorImageTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/TrueColorImageTest.php new file mode 100644 index 000000000..ed7f997fe --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/TrueColorImageTest.php @@ -0,0 +1,138 @@ +assertTrue($img instanceof TrueColorImage); + $this->assertTrue($img->isValid()); + $this->assertTrue($img->isTrueColor()); + } + + public function testCopy() + { + $img = WideImage::load(IMG_PATH . '100x100-rgbyg.png'); + $this->assertTrue($img instanceof TrueColorImage); + $this->assertTrue($img->isValid()); + $this->assertTrue($img->isTrueColor()); + $this->assertRGBEqual($img->getRGBAt(15, 15), 0, 0, 255); + $this->assertRGBEqual($img->getRGBAt(85, 15), 255, 0, 0); + $this->assertRGBEqual($img->getRGBAt(85, 85), 255, 255, 0); + $this->assertRGBEqual($img->getRGBAt(15, 85), 0, 255, 0); + $this->assertRGBEqual($img->getRGBAt(50, 50), 127, 127, 127); + + $copy = $img->copy(); + $this->assertFalse($img->getHandle() === $copy->getHandle()); + + $this->assertTrue($copy instanceof TrueColorImage); + $this->assertTrue($copy->isValid()); + $this->assertTrue($copy->isTrueColor()); + $this->assertRGBEqual($copy->getRGBAt(15, 15), 0, 0, 255); + $this->assertRGBEqual($copy->getRGBAt(85, 15), 255, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 255, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(15, 85), 0, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(50, 50), 127, 127, 127); + } + + public function testCopyNoAlpha() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + $this->assertRGBEqual($img->getRGBAt(85, 85), 0, 0, 255, 96); + $copy = $img->copyNoAlpha(); + $this->assertFalse($img->getHandle() === $copy->getHandle()); + $this->assertTrue($copy instanceof TrueColorImage); + $this->assertTrue($copy->isValid()); + $this->assertTrue($copy->isTrueColor()); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 0, 0, 255, 0); + } + + public function testCopyAlphaGetsCopied() + { + $img = WideImage::load(IMG_PATH . '100x100-blue-alpha.png'); + $this->assertTrue($img instanceof TrueColorImage); + $this->assertTrue($img->isValid()); + $this->assertTrue($img->isTrueColor()); + $this->assertRGBNear($img->getRGBAt(25, 25), 0, 0, 255, 0.25 * 127); + $this->assertRGBNear($img->getRGBAt(75, 25), 0, 0, 255, 0.5 * 127); + $this->assertRGBNear($img->getRGBAt(75, 75), 0, 0, 255, 0.75 * 127); + $this->assertRGBNear($img->getRGBAt(25, 75), 0, 0, 0, 127); + + $copy = $img->copy(); + $this->assertFalse($img->getHandle() === $copy->getHandle()); + + $this->assertTrue($copy instanceof TrueColorImage); + $this->assertTrue($copy->isValid()); + $this->assertTrue($copy->isTrueColor()); + $this->assertRGBNear($copy->getRGBAt(25, 25), 0, 0, 255, 0.25 * 127); + $this->assertRGBNear($copy->getRGBAt(75, 25), 0, 0, 255, 0.5 * 127); + $this->assertRGBNear($copy->getRGBAt(75, 75), 0, 0, 255, 0.75 * 127); + $this->assertRGBNear($copy->getRGBAt(25, 75), 0, 0, 0, 127); + } + + public function testAsPalette() + { + if (function_exists('imagecolormatch')) { + $img = WideImage::load(IMG_PATH . '100x100-rgbyg.png'); + $this->assertTrue($img instanceof TrueColorImage); + $this->assertTrue($img->isValid()); + $this->assertTrue($img->isTrueColor()); + + $copy = $img->asPalette(); + $this->assertFalse($img->getHandle() === $copy->getHandle()); + + $this->assertTrue($copy instanceof PaletteImage); + $this->assertTrue($copy->isValid()); + $this->assertFalse($copy->isTrueColor()); + $this->assertRGBEqual($copy->getRGBAt(15, 15), 0, 0, 255); + $this->assertRGBEqual($copy->getRGBAt(85, 15), 255, 0, 0); + $this->assertRGBEqual($copy->getRGBAt(85, 85), 255, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(15, 85), 0, 255, 0); + $this->assertRGBEqual($copy->getRGBAt(50, 50), 127, 127, 127); + } + } + + public function testPreserveTransparency() + { + $img = WideImage::load(IMG_PATH . '100x100-color-hole.gif'); + $this->assertTrue($img->isTransparent()); + $this->assertRGBEqual($img->getTransparentColorRGB(), 255, 255, 255); + + $tc = $img->asTrueColor(); + $this->assertTrue($tc->isTransparent()); + $this->assertRGBEqual($tc->getTransparentColorRGB(), 255, 255, 255); + + $img = $tc->asPalette(); + $this->assertTrue($img->isTransparent()); + $this->assertRGBEqual($img->getTransparentColorRGB(), 255, 255, 255); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/WideImageTest.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/WideImageTest.php new file mode 100644 index 000000000..e3b261eea --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/WideImage/WideImageTest.php @@ -0,0 +1,306 @@ +_FILES = $_FILES; + $_FILES = array(); + } + + public function teardown() + { + $_FILES = $this->_FILES; + + if (PHP_OS == 'WINNT') { + chdir(IMG_PATH . "temp"); + + foreach (new \DirectoryIterator(IMG_PATH . "temp") as $file) { + if (!$file->isDot()) { + if ($file->isDir()) { + exec("rd /S /Q {$file->getFilename()}\n"); + } else { + unlink($file->getFilename()); + } + } + } + } else { + exec("rm -rf " . IMG_PATH . 'temp/*'); + } + } + + public function testLoadFromFile() + { + $img = WideImage::load(IMG_PATH . '100x100-red-transparent.gif'); + $this->assertTrue($img instanceof PaletteImage); + $this->assertValidImage($img); + $this->assertFalse($img->isTrueColor()); + $this->assertEquals(100, $img->getWidth()); + $this->assertEquals(100, $img->getHeight()); + + $img = WideImage::load(IMG_PATH . '100x100-rainbow.png'); + $this->assertTrue($img instanceof TrueColorImage); + $this->assertValidImage($img); + $this->assertTrue($img->isTrueColor()); + $this->assertEquals(100, $img->getWidth()); + $this->assertEquals(100, $img->getHeight()); + } + + public function testLoadFromString() + { + $img = WideImage::load(file_get_contents(IMG_PATH . '100x100-rainbow.png')); + $this->assertTrue($img instanceof TrueColorImage); + $this->assertValidImage($img); + $this->assertTrue($img->isTrueColor()); + $this->assertEquals(100, $img->getWidth()); + $this->assertEquals(100, $img->getHeight()); + } + + public function testLoadFromHandle() + { + $handle = imagecreatefrompng(IMG_PATH . '100x100-rainbow.png'); + $img = WideImage::loadFromHandle($handle); + $this->assertValidImage($img); + $this->assertTrue($img->isTrueColor()); + $this->assertSame($handle, $img->getHandle()); + $this->assertEquals(100, $img->getWidth()); + $this->assertEquals(100, $img->getHeight()); + unset($img); + $this->assertFalse(WideImage::isValidImageHandle($handle)); + } + + public function testLoadFromUpload() + { + copy(IMG_PATH . '100x100-rainbow.png', IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'upltmpimg'); + $_FILES = array( + 'testupl' => array( + 'name' => '100x100-rainbow.png', + 'type' => 'image/png', + 'size' => strlen(file_get_contents(IMG_PATH . '100x100-rainbow.png')), + 'tmp_name' => IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'upltmpimg', + 'error' => false, + ) + ); + + $img = WideImage::loadFromUpload('testupl'); + $this->assertValidImage($img); + } + + public function testLoadFromMultipleUploads() + { + copy(IMG_PATH . '100x100-rainbow.png', IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'upltmpimg1'); + copy(IMG_PATH . 'splat.tga', IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'upltmpimg2'); + $_FILES = array( + 'testupl' => array( + 'name' => array('100x100-rainbow.png', 'splat.tga'), + 'type' => array('image/png', 'image/tga'), + 'size' => array( + strlen(file_get_contents(IMG_PATH . '100x100-rainbow.png')), + strlen(file_get_contents(IMG_PATH . 'splat.tga')) + ), + 'tmp_name' => array( + IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'upltmpimg1', + IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'upltmpimg2' + ), + 'error' => array(false, false), + ) + ); + + $images = WideImage::loadFromUpload('testupl'); + $this->assertInternalType("array", $images); + $this->assertValidImage($images[0]); + $this->assertValidImage($images[1]); + + $img = WideImage::loadFromUpload('testupl', 1); + $this->assertValidImage($img); + } + + public function testLoadMagicalFromHandle() + { + $img = WideImage::load(imagecreatefrompng(IMG_PATH . '100x100-rainbow.png')); + $this->assertValidImage($img); + } + + + public function testLoadMagicalFromBinaryString() + { + $img = WideImage::load(file_get_contents(IMG_PATH . '100x100-rainbow.png')); + $this->assertValidImage($img); + } + + public function testLoadMagicalFromFile() + { + $img = WideImage::load(IMG_PATH . '100x100-rainbow.png'); + $this->assertValidImage($img); + copy(IMG_PATH . '100x100-rainbow.png', IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'upltmpimg'); + $_FILES = array( + 'testupl' => array( + 'name' => 'fgnl.bmp', + 'type' => 'image/bmp', + 'size' => strlen(file_get_contents(IMG_PATH . 'fgnl.bmp')), + 'tmp_name' => IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'upltmpimg', + 'error' => false, + ) + ); + $img = WideImage::load('testupl'); + $this->assertValidImage($img); + } + + public function testLoadFromStringWithCustomMapper() + { + $img = WideImage::loadFromString(file_get_contents(IMG_PATH . 'splat.tga')); + $this->assertValidImage($img); + } + + public function testLoadFromFileWithInvalidExtension() + { + $img = WideImage::load(IMG_PATH . 'actually-a-png.jpg'); + $this->assertValidImage($img); + } + + public function testLoadFromFileWithInvalidExtensionWithCustomMapper() + { + if (PHP_OS == 'WINNT') + $this->markTestSkipped("For some reason, this test kills PHP my 32-bit Vista + PHP 5.3.1."); + + $img = WideImage::loadFromFile(IMG_PATH . 'fgnl-bmp.jpg'); + $this->assertValidImage($img); + } + + /** + * @expectedException WideImage\Exception\InvalidImageSourceException + */ + public function testLoadFromStringEmpty() + { + WideImage::loadFromString(''); + } + + public function testLoadBMPMagicalFromUpload() + { + copy(IMG_PATH . 'fgnl.bmp', IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'upltmpimg'); + $_FILES = array( + 'testupl' => array( + 'name' => 'fgnl.bmp', + 'type' => 'image/bmp', + 'size' => strlen(file_get_contents(IMG_PATH . 'fgnl.bmp')), + 'tmp_name' => IMG_PATH . 'temp' . DIRECTORY_SEPARATOR . 'upltmpimg', + 'error' => false, + ) + ); + $img = WideImage::load('testupl'); + $this->assertValidImage($img); + } + + public function testMapperLoad() + { + FOO::$handle = imagecreate(10, 10); + $filename = IMG_PATH . 'image.foo'; + WideImage::registerCustomMapper(__NAMESPACE__ . '\\FOO', 'image/foo', 'foo'); + $img = WideImage::load($filename); + $this->assertEquals(FOO::$calls['load'], array($filename)); + imagedestroy(FOO::$handle); + } + + public function testLoadFromFileFallbackToLoadFromString() + { + FOO::$handle = imagecreate(10, 10); + $filename = IMG_PATH . 'image-actually-foo.foo2'; + WideImage::registerCustomMapper('FOO', 'image/foo', 'foo'); + WideImage::registerCustomMapper('FOO2', 'image/foo2', 'foo2'); + $img = WideImage::load($filename); + $this->assertEquals(FOO2::$calls['load'], array($filename)); + $this->assertEquals(FOO::$calls['loadFromString'], array(file_get_contents($filename))); + imagedestroy(FOO::$handle); + } + + public function testMapperSaveToFile() + { + $img = WideImage::load(IMG_PATH . 'fgnl.jpg'); + $img->saveToFile('test.foo', '123', 789); + $this->assertEquals(FOO::$calls['save'], array($img->getHandle(), 'test.foo', '123', 789)); + } + + public function testMapperAsString() + { + $img = WideImage::load(IMG_PATH . 'fgnl.jpg'); + $str = $img->asString('foo', '123', 789); + $this->assertEquals(FOO::$calls['save'], array($img->getHandle(), null, '123', 789)); + $this->assertEquals('out', $str); + } + + /** + * @expectedException WideImage\Exception\InvalidImageSourceException + */ + public function testInvalidImageFile() + { + WideImage::loadFromFile(IMG_PATH . 'fakeimage.png'); + } + + /** + * @expectedException WideImage\Exception\InvalidImageSourceException + */ + public function testEmptyString() + { + WideImage::load(''); + } + + /** + * @expectedException WideImage\Exception\InvalidImageSourceException + */ + public function testInvalidImageStringData() + { + WideImage::loadFromString('asdf'); + } + + /** + * @expectedException WideImage\Exception\InvalidImageSourceException + */ + public function testInvalidImageHandle() + { + WideImage::loadFromHandle(0); + } + + /** + * @expectedException WideImage\Exception\InvalidImageSourceException + */ + public function testInvalidImageUploadField() + { + WideImage::loadFromUpload('xyz'); + } +} diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-blue-alpha.png b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-blue-alpha.png new file mode 100644 index 000000000..6c31be7a7 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-blue-alpha.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-color-hole.gif b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-color-hole.gif new file mode 100644 index 000000000..f6d466564 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-color-hole.gif differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-color-hole.png b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-color-hole.png new file mode 100644 index 000000000..f154a8619 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-color-hole.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-rainbow.png b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-rainbow.png new file mode 100644 index 000000000..fab75777a Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-rainbow.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-red-spot-half-cut.png b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-red-spot-half-cut.png new file mode 100644 index 000000000..45811f060 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-red-spot-half-cut.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-red-spot.png b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-red-spot.png new file mode 100644 index 000000000..7a76a39c5 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-red-spot.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-red-transparent.gif b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-red-transparent.gif new file mode 100644 index 000000000..f0f06a6bd Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-red-transparent.gif differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-rgbyg.png b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-rgbyg.png new file mode 100644 index 000000000..6b540ec1b Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-rgbyg.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-square-overlay.png b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-square-overlay.png new file mode 100644 index 000000000..abb310abd Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x100-square-overlay.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x50-rgbt.gif b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x50-rgbt.gif new file mode 100644 index 000000000..1147fa30a Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/100x50-rgbt.gif differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/75x25-gray.png b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/75x25-gray.png new file mode 100644 index 000000000..927d8e618 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/75x25-gray.png differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/actually-a-png.jpg b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/actually-a-png.jpg new file mode 100644 index 000000000..fab75777a Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/actually-a-png.jpg differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/favicon.ico b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/favicon.ico new file mode 100644 index 000000000..6b7759512 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/favicon.ico differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-16b-x.bmp b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-16b-x.bmp new file mode 100644 index 000000000..e323112b4 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-16b-x.bmp differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-16b.bmp b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-16b.bmp new file mode 100644 index 000000000..1aa506734 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-16b.bmp differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-24b.bmp b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-24b.bmp new file mode 100644 index 000000000..6a7ef9af4 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-24b.bmp differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-32b.bmp b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-32b.bmp new file mode 100644 index 000000000..d769b1cad Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-32b.bmp differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-palette-rle.bmp b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-palette-rle.bmp new file mode 100644 index 000000000..f5f0fab5b Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/bmp/rainbow-palette-rle.bmp differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/empty.tga b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/empty.tga new file mode 100644 index 000000000..e69de29bb diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fakeimage.png b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fakeimage.png new file mode 100644 index 000000000..ee9fb9558 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fakeimage.png @@ -0,0 +1 @@ +NOT AN ACTUAL IMAGE \ No newline at end of file diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fgnl-bmp.jpg b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fgnl-bmp.jpg new file mode 100644 index 000000000..c091c82b8 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fgnl-bmp.jpg differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fgnl.bmp b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fgnl.bmp new file mode 100644 index 000000000..c091c82b8 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fgnl.bmp differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fgnl.jpg b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fgnl.jpg new file mode 100644 index 000000000..9f0c23e98 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/fgnl.jpg differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/image-actually-foo.foo2 b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/image-actually-foo.foo2 new file mode 100644 index 000000000..ea8157e69 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/image-actually-foo.foo2 @@ -0,0 +1 @@ +Fake image with custom extension \ No newline at end of file diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/image.foo b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/image.foo new file mode 100644 index 000000000..ea8157e69 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/image.foo @@ -0,0 +1 @@ +Fake image with custom extension \ No newline at end of file diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/logo.gif b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/logo.gif new file mode 100644 index 000000000..8c5454b26 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/logo.gif differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/images/splat.tga b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/splat.tga new file mode 100644 index 000000000..92ca79bc8 Binary files /dev/null and b/htdocs/class/libraries/vendor/smottt/wideimage/test/images/splat.tga differ diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/run.bat b/htdocs/class/libraries/vendor/smottt/wideimage/test/run.bat new file mode 100644 index 000000000..2f1ccd9bc --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/run.bat @@ -0,0 +1 @@ +phpunit --verbose --bootstrap test-init.php %1 %2 %3 %4 %5 %6 WideImage diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/run.sh b/htdocs/class/libraries/vendor/smottt/wideimage/test/run.sh new file mode 100644 index 000000000..945444df6 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/run.sh @@ -0,0 +1 @@ +phpunit $* --verbose --bootstrap `dirname $0`/test-init.php `dirname $0`/WideImage diff --git a/htdocs/class/libraries/vendor/smottt/wideimage/test/test-init.php b/htdocs/class/libraries/vendor/smottt/wideimage/test/test-init.php new file mode 100644 index 000000000..4dcdd03b8 --- /dev/null +++ b/htdocs/class/libraries/vendor/smottt/wideimage/test/test-init.php @@ -0,0 +1,90 @@ +assertInstanceOf('WideImage\\Image', $image); + $this->assertTrue($image->isValid()); + } + + public function assertDimensions($image, $width, $height) + { + $this->assertEquals($width, $image->getWidth()); + $this->assertEquals($height, $image->getHeight()); + } + + public function assertTransparentColorMatch($img1, $img2) + { + $tc1 = $img1->getTransparentColorRGB(); + $tc2 = $img2->getTransparentColorRGB(); + $this->assertEquals($tc1, $tc2); + } + + public function assertTransparentColorAt($img, $x, $y) + { + $this->assertEquals($img->getTransparentColor(), $img->getColorAt($x, $y)); + } + + public function assertRGBWithinMargin($rec, $r, $g, $b, $a, $margin) + { + if (is_array($r)) { + $a = $r['alpha']; + $b = $r['blue']; + $g = $r['green']; + $r = $r['red']; + } + + $result = + abs($rec['red'] - $r) <= $margin && + abs($rec['green'] - $g) <= $margin && + abs($rec['blue'] - $b) <= $margin; + + $result = $result && ($a === null || abs($rec['alpha'] - $a) <= $margin); + + $this->assertTrue($result, + "RGBA [{$rec['red']}, {$rec['green']}, {$rec['blue']}, {$rec['alpha']}] " . + "doesn't match RGBA [$r, $g, $b, $a] within margin [$margin]."); + } + + public function assertRGBAt($img, $x, $y, $rgba) + { + if (is_array($rgba)) { + $cmp = $img->getRGBAt($x, $y); + } else { + $cmp = $img->getColorAt($x, $y); + } + + $this->assertSame($cmp, $rgba); + } + + public function assertRGBNear($rec, $r, $g = null, $b = null, $a = null) + { + $this->assertRGBWithinMargin($rec, $r, $g, $b, $a, 2); + } + + public function assertRGBEqual($rec, $r, $g = null, $b = null, $a = null) + { + $this->assertRGBWithinMargin($rec, $r, $g, $b, $a, 0); + } +}