Skip to content

Commit

Permalink
Wideimage
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Dec 2, 2024
1 parent 3c67560 commit 8b3b37b
Show file tree
Hide file tree
Showing 133 changed files with 5,141 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* @package Demos
*/
?>
<form style="font-family: Verdana, Tahoma; font-size: 11px">
<input type="hidden" name="demo" value="<?php echo $activeDemo->name; ?>" />
<div style="background-color: #f0f0f0; padding: 5px;">
<input type="submit" value="refresh" />
<?php
foreach ($activeDemo->fields as $field)
$field->render();
?>
<br />
<span style="font-family: Verdana, Tahoma; font-size: 11px">
Read the <a href="../doc/WideImage/WideImage_Image.html#method<?php echo $activeDemo->name; ?>">API documentation</a> for this operation.
</span>

<div style="background-color: #d0d0d0; padding: 5px; text-align: right; float: right; width: 300px;">
<?php
$top_form['output']->render();
echo "<br />\n";
echo ' Palette options (only for <em>png8</em> and <em>gif</em> output):<br />';
$top_form['ncolors']->render();
echo "<br />\n";
$top_form['dither']->render();
$top_form['match_palette']->render();
?>
</div>
</div>
</form>

<?php
$activeDemo->text();
?>


<?php
$images_in_row = 2;
$in_row = 0;
$images = array();
$di = new DirectoryIterator(dirname(__FILE__) . '/images/');
foreach ($di as $file)
if (!$file->isDot() && strpos($file->getFilename(), '.') !== 0)
$images[] = $file->getFilename();

asort($images);
foreach ($images as $image_file)
{
echo '<div class="images">';
echo '<img src="images/' . $image_file . '" />';
$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 '&nbsp;';
echo '<a href="' . $img_url . '">';
echo '<img src="' . $img_url . '" />';
echo '</a>';
echo "</div>\n";
}
?>
<div style="clear: both"></div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* @package Demos
*/
class Demo_addNoise extends Demo
{
public $order = 9350;

function init()
{
$this->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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* @package Demos
*/
class Demo_applyConvolution extends Demo
{
public $order = 2025;

protected $base_matrix = array(array(2, 0, 0), array(0, -1, 0), array(0, 0, -1));

function init()
{
$this->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'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* @package Demos
*/
class Demo_applyFilter extends Demo
{
public $order = 2000;

function init()
{
$this->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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* @package Demos
*/
class Demo_applyMask extends Demo
{
public $order = 600;

function init()
{
$this->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';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* @package Demos
*/
class Demo_asGrayscale extends Demo
{
public $order = 300;

function execute($img, $request)
{
return $img->asGrayscale();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* @package Demos
*/
class Demo_asNegative extends Demo
{
public $order = 300;

function execute($img, $request)
{
return $img->asNegative();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* @package Demos
*/
class Demo_autoCrop extends Demo
{
public $order = 1050;

function init()
{
$this->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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* @package Demos
*/
class Demo_correctGamma extends Demo
{
public $order = 2050;

function init()
{
$this->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'));
}
}
26 changes: 26 additions & 0 deletions htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/crop.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* @package Demos
*/
class Demo_crop extends Demo
{
public $order = 1000;

function init()
{
$this->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);
}
}
13 changes: 13 additions & 0 deletions htdocs/class/libraries/vendor/smottt/wideimage/demo/demos/flip.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* @package Demos
*/
class Demo_flip extends Demo
{
public $order = 1200;

function execute($image, $request)
{
return $image->flip();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* @package Demos
*/
class Demo_getCanvas extends Demo
{
public $order = 1300;

function init()
{
$this->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:
<pre>
\$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')});
</pre>";
}
}
Loading

0 comments on commit 8b3b37b

Please sign in to comment.