Add an image style at once
5533
protected function submitAddImageStyle()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->setSubmittedList('actions');
        $this->validateComponent('image_style');
        $this->addImageStyle();
    }
981705
def element_style(attrs, style_def, parent_style):
    """"""
    style = parent_style.copy()
    if 'class' in attrs:
        for css_class in attrs['class'].split():
            css_style = style_def['.' + css_class]
            style.update(css_style)
    if 'style' in attrs:
        immediate_style = dumb_property_dict(attrs['style'])
        style.update(immediate_style)
    return style
949946
function(css, imageIndex){
    var urlVal = css.value[imageIndex];
    var image  = this._isSpriteImage(urlVal, imageIndex, css);
    var images = this.images;

    if (image){
      image = path.relative('./', image);
      image = image.replace(/\\+/g, '/');
      images[css.id] = image;
    }
  }
815940
function injectStyle(obj) {
  if (!obj) return ''

  var selectors = Object.keys(obj)

  var styles = selectors.map(function(key) {
    var selector = obj[key]
    var style = inlineStyle(selector)
    var inline = key.concat('{').concat(style).concat('}')
    return inline
  })

  var results = styles.join('')
  insertCss(results)

  return results
}
842808
def stylize(text, styles, reset=True):
    """"""
    terminator = attr("reset") if reset else ""
    return "{}{}{}".format("".join(styles), text, terminator)
650781
function setImage(image, img) {
  if (!image.hasLoaded) {
    image.hasLoaded = true;

    setTimeout(function() {
      image.element.className += ' loaded';
    }, 100);
  }

  image.trigger('load', img);

  if (image.element.tagName.toLowerCase() === 'img') {
    return setImageTag(image, img);
  } else {
    return setDivTag(image, img);
  }
}
3390
function (imagen, width, height, quality, type, ratio, centerCrop, resizeIf) {
    var deferred = $q.defer();
    var canvasElement = document.createElement('canvas');
    var imageElement = document.createElement('img');
    imageElement.setAttribute('style', 'visibility:hidden;position:fixed;z-index:-100000');
    document.body.appendChild(imageElement);

    imageElement.onload = function () {
      var imgWidth = imageElement.width, imgHeight = imageElement.height;
      imageElement.parentNode.removeChild(imageElement);
      if (resizeIf != null && resizeIf(imgWidth, imgHeight) === false) {
        deferred.reject('resizeIf');
        return;
      }
      try {
        if (ratio) {
          var ratioFloat = upload.ratioToFloat(ratio);
          var imgRatio = imgWidth / imgHeight;
          if (imgRatio < ratioFloat) {
            width = imgWidth;
            height = width / ratioFloat;
          } else {
            height = imgHeight;
            width = height * ratioFloat;
          }
        }
        if (!width) {
          width = imgWidth;
        }
        if (!height) {
          height = imgHeight;
        }
        var dimensions = calculateAspectRatioFit(imgWidth, imgHeight, width, height, centerCrop);
        canvasElement.width = Math.min(dimensions.width, width);
        canvasElement.height = Math.min(dimensions.height, height);
        var context = canvasElement.getContext('2d');
        context.drawImage(imageElement,
          Math.min(0, -dimensions.marginX / 2), Math.min(0, -dimensions.marginY / 2),
          dimensions.width, dimensions.height);
        deferred.resolve(canvasElement.toDataURL(type || 'image/WebP', quality || 0.934));
      } catch (e) {
        deferred.reject(e);
      }
    };
    imageElement.onerror = function () {
      imageElement.parentNode.removeChild(imageElement);
      deferred.reject();
    };
    imageElement.src = imagen;
    return deferred.promise;
  }
30485
function setStyles(element, styles) {
  Object.keys(styles).forEach(function (prop) {
    var unit = '';
    // add unit if the value is numeric and is one of the following
    if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
      unit = 'px';
    }
    element.style[prop] = styles[prop] + unit;
  });
}
525506
def add_rect(img, box, color=None, thickness=1):
    
    if color is None:
        color = COL_GRAY

    box = box.to_int()
    cv.rectangle(img, box.top_left(), box.bottom_right(), color, thickness)
995879
function() {
			//merge initial options
			_opt = merge(_def, opt);
			_opt.bgColor = hexToRgb(_opt.bgColor);
			_opt.textColor = hexToRgb(_opt.textColor);
			_opt.position = _opt.position.toLowerCase();
			_opt.animation = (animation.types['' + _opt.animation]) ? _opt.animation : _def.animation;

			var isUp = _opt.position.indexOf('up') > -1;
			var isLeft = _opt.position.indexOf('left') > -1;

			//transform animation
			if (isUp || isLeft) {
				for (var i = 0; i < animation.types['' + _opt.animation].length; i++) {
					var step = animation.types['' + _opt.animation][i];

					if (isUp) {
						if (step.y < 0.6) {
							step.y = step.y - 0.4;
						} else {
							step.y = step.y - 2 * step.y + (1 - step.w);
						}
					}

					if (isLeft) {
						if (step.x < 0.6) {
							step.x = step.x - 0.4;
						} else {
							step.x = step.x - 2 * step.x + (1 - step.h);
						}
					}

					animation.types['' + _opt.animation][i] = step;
				}
			}
			_opt.type = (type['' + _opt.type]) ? _opt.type : _def.type;
			try {
				_orig = link.getIcon();
				//create temp canvas
				_canvas = document.createElement('canvas');
				//create temp image
				_img = document.createElement('img');
				if (_orig.hasAttribute('href')) {
					_img.setAttribute('src', _orig.getAttribute('href'));
					//get width/height
					_img.onload = function() {
						_h = (_img.height > 0) ? _img.height : 32;
						_w = (_img.width > 0) ? _img.width : 32;
						_canvas.height = _h;
						_canvas.width = _w;
						_context = _canvas.getContext('2d');
						icon.ready();
					};
				} else {
					_img.setAttribute('src', '');
					_h = 32;
					_w = 32;
					_img.height = _h;
					_img.width = _w;
					_canvas.height = _h;
					_canvas.width = _w;
					_context = _canvas.getContext('2d');
					icon.ready();
				}
			} catch(e) {
				throw 'Error initializing favico. Message: ' + e.message;
			}

		}
711736
def _compose_style(self):
        """"""
        valid_styles = (
            'color', 'width', 'filter', 'strokeWidth', 'strokeColor',
        )
        self.styling = '\n'.join(
            '{prop}: {style}'.format(prop=s, style=getattr(self, s))
            for s in valid_styles
            if getattr(self, s) is not None
        )
372158
public static Image newImage (String path, String... styles)
    {
        return setStyleNames(new Image(path), styles);
    }
169128
function appendStyle(code) {
        var dom = document.createElement('style');
        dom.innerHTML = code;
        head.appendChild(dom);
    }
604017
def add_styles(self, **styles):
        """"""
        for stylename in sorted(styles):
            self._doc.styles.addElement(styles[stylename])
1363982
def mergeStyles(self, styles):
        "  "
        for k, v in six.iteritems(styles):
            if k in self and self[k]:
                self[k] = copy.copy(self[k])
                self[k].update(v)
            else:
                self[k] = v
1178085
public function editImageStyle($style_id = null)
    {
        $this->setImageStyle($style_id);
        $this->setTitleEditImageStyle();
        $this->setBreadcrumbEditImageStyle();

        $this->setData('imagestyle', $this->data_imagestyle);
        $this->setData('actions', $this->getActionsImageStyle());
        $this->setData('can_delete', $this->canDeleteImageStyle());

        $this->submitEditImageStyle();
        $this->setDataEditImageStyle();

        $this->outputEditImageStyle();
    }
1310788
function (rect) {
		var s = '';
		for (var n in rect) {
			s += (n + ':' + rect[n] + (isNaN(rect[n]) ? '; ' : 'px; '));
		}
		this.addStyles(s);
	}