Create an image tag for the specified filename

@param string $filename
@param array $attributes
@return string
490424
private function createImageTag($filename, $attributes)
    {
        $img = '<ac:image';

        foreach ($attributes as $name => $value) {
            if ($name == 'style') {
                $re = '/float:\s*?(left|right);?/';
                if (preg_match($re, $value, $matches)) {
                    $img .= ' ac:align="' . $matches[1] . '"';
                    $value = preg_replace($re, "", $value, 1);
                }
            }

            $img .= ' ac:' . $name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
        }

        $img .= "><ri:attachment ri:filename=\"$filename\" /></ac:image>";

        return $img;
    }
602774
public static function table(
        string $content = null, 
        array $attributes = []
    ) : string
    {
        return self::tag("table", $content, $attributes);
    }
679544
public static function image($relative, array $attributes = [])
    {
        $attributes += ['alt' => null];

        $height = isset($attributes['height']) ? $attributes['height'] : 0;

        $width = isset($attributes['width']) ? $attributes['width'] : 0;

        $url = static::url($relative, $width, $height);
        
        $attributes['src'] = $url;

        $attrs = [];

        foreach ($attributes as $name => $attr) {

            $attrs[] = "$name=\"{$attr}\"";
        }

        $attrs = implode(' ', $attrs);

        return "<img {$attrs} />";

    }
1175089
public function stylesheetLinkTag($filename, $attributes)
    {
        $webPaths = array();
        $absolutePaths = $this->parser->stylesheetFiles($filename);

        foreach ($absolutePaths as $absolutePath)
        {
            $webPaths[] = $this->parser->absolutePathToWebPath($absolutePath);
        }

        $config = $this->getConfig();
        $composer = $config['stylesheet_link_tag'];

        return $composer->process($webPaths, $absolutePaths, $attributes);
    }
377774
final public function tag(string $name, array $attributes = [])
    {
        if ('' === $name) {
            throw new InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.');
        }

        foreach ($attributes as $attribute => $value) {
            if (null !== $value && !is_scalar($value)) {
                throw new InvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type.', $name, $attribute));
            }
        }

        $this->definition->addTag($name, $attributes);

        return $this;
    }
841975
public function create(string $tag = 'div', $value = null, array $attributes = []): Htmlable
    {
        if (\is_array($value)) {
            $attributes = $value;
            $value = null;
        }

        $content = '<'.$tag.$this->attributes($attributes).'>';

        if (! \is_null($value)) {
            $content .= $this->entities($value).'</'.$tag.'>';
        }

        return $this->toHtmlString($content);
    }
531049
public function create($tag = 'div', $value = null, $attributes = [])
    {
        if (is_array($value)) {
            $attributes = $value;
            $value      = null;
        }

        $content = '<'.$tag.$this->attributes($attributes).'>';

        if (! is_null($value)) {
            $content .= $this->entities($value).'</'.$tag.'>';
        }

        return $this->raw($content);
    }
1333011
public static function create($name, $attributes)
    {
        // Not supported is type=image, <button>, list, output, select-optgroup
        $types = [

            // Standard HTML 4.01
            'text'              => '\Anax\HTMLForm\FormElementText',
            'file'              => '\Anax\HTMLForm\FormElementFile',
            'password'          => '\Anax\HTMLForm\FormElementPassword',
            'hidden'            => '\Anax\HTMLForm\FormElementHidden',
            'textarea'          => '\Anax\HTMLForm\FormElementTextarea',
            'radio'             => '\Anax\HTMLForm\FormElementRadio',
            'checkbox'          => '\Anax\HTMLForm\FormElementCheckbox',
            'select'            => '\Anax\HTMLForm\FormElementSelect',
            'select-multiple'   => '\Anax\HTMLForm\FormElementSelectMultiple',
            'submit'            => '\Anax\HTMLForm\FormElementSubmit',
            'reset'             => '\Anax\HTMLForm\FormElementReset',
            'button'            => '\Anax\HTMLForm\FormElementButton',

            // HTML5
            'color'             => '\Anax\HTMLForm\FormElementColor',
            'date'              => '\Anax\HTMLForm\FormElementDate',
            'number'            => '\Anax\HTMLForm\FormElementNumber',
            'range'             => '\Anax\HTMLForm\FormElementRange',
            'tel'               => '\Anax\HTMLForm\FormElementTel',
            'email'             => '\Anax\HTMLForm\FormElementEmail',
            'url'               => '\Anax\HTMLForm\FormElementUrl',
            'search'            => '\Anax\HTMLForm\FormElementSearch',
            'file-multiple'     => '\Anax\HTMLForm\FormElementFileMultiple',
            'datetime'          => '\Anax\HTMLForm\FormElementDatetime',
            'datetime-local'    => '\Anax\HTMLForm\FormElementDatetimeLocal',
            'month'             => '\Anax\HTMLForm\FormElementMonth',
            'time'              => '\Anax\HTMLForm\FormElementTime',
            'week'              => '\Anax\HTMLForm\FormElementWeek',

            // Custom
            'search-widget'     => '\Anax\HTMLForm\FormElementSearchWidget',
            'checkbox-multiple' => '\Anax\HTMLForm\FormElementCheckboxMultiple',
            // Address
        ];

        // $attributes['type'] must contain a valid type creating an object
        // to succeed.
        $type = isset($attributes['type']) ? $attributes['type'] : null;
        if (!($type && isset($types[$type]))) {
            throw new Exception("Form element does not exists and can not be created: $name - $type");
        }
        return new $types[$type]($name, $attributes);
    }
1372470
static public function createFromFile($filename) {
		if (!file_exists($filename))
			throw new Exception('Invalid (filename) parameter! File does not exist!');

		$image_info = getimagesize($filename);
		if ($image_info === false)
			throw new Exception('Invalid (filename) parameter! File is corrupted!');

		switch ($image_info[2]) {
			case IMAGETYPE_JPEG:
			case IMAGETYPE_JPEG2000:
				$image = imagecreatefromjpeg($filename);
				break;
			case IMAGETYPE_PNG:
				$image = imagecreatefrompng($filename);
				break;
			case IMAGETYPE_GIF:
				$image = imagecreatefromgif($filename);
				break;
			case IMAGETYPE_WBMP:
				$image = imagecreatefromwbmp($filename);
				break;
			case IMAGETYPE_BMP:
				$image = imagecreatefrombmp($filename);
				break;
			default:
				throw new Exception('Unknown image format!');
				break;
		}

		return new self($image);
	}
1185073
public function imageCreateJpegfromExif($filename)
    {
        $img  = imagecreatefromjpeg($filename);
        $exif = exif_read_data($filename);
        if (!$exif || !isset($exif['Orientation'])) {
            return $img;
        }
        $orientation = $exif['Orientation'];
        if ($orientation === 6 || $orientation === 5) {
            $img = imagerotate($img, 270, null);
        } elseif ($orientation === 3 || $orientation === 4) {
            $img = imagerotate($img, 180, null);
        } elseif ($orientation === 8 || $orientation === 7) {
            $img = imagerotate($img, 90, null);
        }
        if ($orientation === 5 || $orientation === 4 || $orientation === 7) {
            imageflip($img, IMG_FLIP_HORIZONTAL);
        }
        
        return $img;
    }
1287988
protected static function _renderImage($src, $className, array $attributes = array())
        {
            if (is_array($attributes['class'])) {
                $attributes['class'][] = $className;
            } else {
                $attributes['class'] .= ' ' . $className;
            }

            return sprintf('<img src="%s"%s />', Html::escape($src), Html::attributes($attributes));
        }
446288
public function imageTag($source, $alt = null, $attributes = [])
    {
        $assetsOptions = ['host' => array_pull($attributes, 'host', $this->assetsHost)];

        // E.g. image_tag('logo.png', "My Logo"); => <img src="http://localhost/assets/logo-f2331bb588d007ba354e5fa406f9f4aa.png" alt="My Logo">
        $alt = $alt ?: humanize(basename($source, ".".File::extension($source)));

        return app('html')->image($this->assetPath($source, $assetsOptions), $alt, $attributes);
    }
1151458
public static function tag($name, $content = NULL, Array $attributes = NULL) {
    $tag = new HTMLTag($name, $content, $attributes);
    return $tag;
  }
1239357
public static function newFromFile(
        string $filename,
        array $options = []
    ): Image {
        Utils::debugLog('newFromFile', [
            'instance' => null,
            'arguments' => [$filename, $options]
        ]);

        $options = self::unwrap($options);
        $result = vips_image_new_from_file($filename, $options);
        self::errorIsArray($result);
        $result = self::wrapResult($result);

        Utils::debugLog('newFromFile', ['result' => $result]);

        return $result;
    }
988204
public function open($url, array $attributes = [])
    {
        $tag = new Tag('form', $attributes);
        $tag->action = $url;
        $tag->method = 'POST';
        return $tag;
    }
749131
public static function add_attributes($tag, $attributes) {
        $tag = self::remove_attributes($tag, array_keys($attributes));
        if (!preg_match('/^(<.*?)(>.*)$/s', $tag, $matches)) {
            return $tag;
        }
        $rv = $matches[1];
        foreach ($attributes as $name => $value) {
            $rv .= " $name=\"".s($value).'"';
        }
        $rv .= $matches[2];
        return $rv;
    }
1219527
public function buildTagAttributes(array $attributes)
	{
		$html = array();

		foreach ($attributes as $key => $value)
		{
			if (is_null($value))
				continue;

			if (is_numeric($key))
				$key = $value;

			$html[] = $key . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
		}

		return (count($html) > 0) ? ' ' . implode(' ', $html) : '';
	}