/*
This method specifies the HTML that should be converted into a image.

html - The HTML to convert into a image.
options - A instance of the GrabzItImageOptions class that defines any special options to use when creating the image.
507530
public function HTMLToImage($html, GrabzItImageOptions $options = null)
	{
		if ($options == null)
		{
			$options = new GrabzItImageOptions();			
		}		

		$this->request = new GrabzItRequest($this->getRootUrl(true) . GrabzItClient::TakePicture, true, $options, $html);
	}
1293689
def _replace_options(string, options)
      # Unescape the string so we can use the returned string
      # to set an elements inner html.
      s = string.gsub('&lt;', '<').gsub('&gt;', '>')

      if options
        # But escape option values to prevent code injection
        s.gsub(/%\{(\w+)\}/) do |m|
          key = ($1 || m.tr("%{}", ""))

          if options.key?(key)
            options[key].to_s.gsub('<', '&lt;').gsub('>', '&gt;')
          else
            key
          end
        end
      else
        s
      end
    end
978167
function Option(options){
		// options should be an object
		if ( typeof options !== 'object' ) {
			throw new Error('options should be an object');
		}
		
		// All options except value must be provided.
		if ( !options.name || !options.description || !options.type || options.defaultValue === undefined ) {
			throw new Error('name,description, type, and defaultValue required');
		}

		// Set name of option
		this.name = options.name;

		// A description of the setting.
		this.description = options.description;

		// The type of value `this` option can have.
		if ( options.type !== Array && options.type !== Number && options.type !== Boolean &&
			options.type !== String && options.type !== Object ){

			throw new Error('Option type must be Boolean,Number,Function,String, or Object');
		}

		this.type = options.type;

		// Default value as defined by node-jshint
		this.defaultValue = options.defaultValue;

		// Current value takes default value by default.
		this.setValue( options.defaultValue );
	}
622116
public static function image($url, $alt = '', $htmlOptions = array())
	{
		// Load assets
		if (!self::$_assetsUrl)
			self::loadAssets();

		// Add the data-src attribute
		if (!isset($htmlOptions['data-src']))
			$htmlOptions['data-src'] = $url;

		// Add the CSS class
		if (isset($htmlOptions['class']))
		{
			$cssClasses = explode(' ', $htmlOptions['class']);

			if (!in_array('lazy', $cssClasses))
				$cssClasses[] = 'lazy';

			$htmlOptions['class'] = implode(' ', $cssClasses);
		}
		else
			$htmlOptions['class'] = 'lazy';

		return \CHtml::image(self::$_assetsUrl.'/images/loader.gif', $alt, $htmlOptions);
	}
176840
def picture_url_options
      return {} if picture.nil?

      {
        format: picture.default_render_format,
        crop_from: crop_from.presence,
        crop_size: crop_size.presence
      }.with_indifferent_access
    end
1238510
def to_image(options = {})
      options = {
          tileable: false,
      }.merge! options

      # Create a new Image from the flipped pixel data.
      stub = ImageStub.new to_blob, width, height
      if defined? TexPlay
        Gosu::Image.new $window, stub, options[:tileable], options
      else
        Gosu::Image.new $window, stub, options[:tileable]
      end
    end
1157268
function (options) {
    this.matchingJadeFilePath = options.matchingJadeFilePath;
    this.htmlFilePath = options.htmlFilePath;
    this.lastRenderToFile = undefined;
    this.jadeOptions = (typeof options.jadeOptions === 'undefined') ? { pretty: true } : options.jadeOptions;
}
542118
function _render_option(){

	var buf = new Array();

	// Sort the items in the mdata array.
	// Also keep a lookup for a "special" entry.
	// var default_on_p = false;
	var mdata_keys = bbop.core.get_keys(anchor.mdata);
	function _data_comp(a, b){

	    // Get the associated data.
	    var a_data = anchor.mdata[a];
	    var b_data = anchor.mdata[b];

	    // if( (a_data['special'] == true && a_data['selected'] == true) ||
	    // 	(b_data['special'] == true && b_data['selected'] == true) ){
	    // 	default_on_p = true;
	    // }

	    //
	    var retval = 0;
	    if( a_data['special'] != b_data['special'] ){
		if( a_data['count'] == true ){
		    retval = 1;
		}else{
		    retval = -1;
		}
	    }else if( a_data['count'] != b_data['count'] ){
		if( a_data['count'] > b_data['count'] ){
		    retval = -1;
		}else{
		    retval = 1;
		}
	    }else if( a_data['label'] != b_data['label'] ){
		if( a_data['label'] > b_data['label'] ){
		    retval = 1;
		}else{
		    retval = -1;
		}
	    }

	    return retval;
	}
	mdata_keys.sort(_data_comp); // inplace sort

	//
	for( var mski = 0; mski < mdata_keys.length; mski++ ){

	    var write_data = anchor.mdata[mdata_keys[mski]];
	    
	    // Write out option if:
	    // 1) the default is selected (so we want to see everything)
	    // 2) the selection is special
	    // 3) if the default is not selected, either the item is selected or
	    // 4) it has a count (and is thus interesting)
	    if( // default_on_p == true ||
	    	write_data['selected'] == true ||
	    	write_data['special'] == true ||
	    	( write_data['count'] && write_data['count'] > 0 ) ){
		    
		    buf.push('<option');
		    // Title.
		    buf.push(' title="');
		    buf.push(write_data['value']);
		    buf.push('"');		
		    // Value.
		    buf.push(' value="');
		    buf.push(write_data['value']);
		    buf.push('"');		
		    if( write_data['selected'] ){
			buf.push(' selected="selected"');
		    }
		    buf.push('>');
		    //buf.push(bbop.core.crop(write_data['label']));
		    buf.push(bbop.core.crop(write_data['label'], 40, '...'));
		    
		    if( write_data['count'] && write_data['count'] > 0 ){
			buf.push(' (' + write_data['count'] + ')');
		    }
		    
		    buf.push('</option>');
		}
		
	}
	return buf.join('');
    }
18061
protected void addOption(AbstractRenderAppender buffer, String type, String optionValue,
                             String optionDisplay, int idx, String altText, char accessKey, boolean disabled)
            throws JspException
    {
        ServletRequest req = pageContext.getRequest();
        if (_cr == null)
            _cr = TagRenderingBase.Factory.getConstantRendering(req);

        assert(buffer != null);
        assert(optionValue != null);
        assert(optionDisplay != null);
        assert(type != null);

        if (_orientation != null && isVertical()) {
            _cr.TR_TD(buffer);
        }

        _inputState.clear();
        _inputState.type = type;
        _inputState.name = getQualifiedDataSourceName();
        _inputState.value = optionValue;
        _inputState.style = _style;
        _inputState.styleClass = _class;

        if (isMatched(optionValue, null)) {
            _inputState.checked = true;
        }
        _inputState.disabled = isDisabled();
        _inputState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ALT, altText);
        if (accessKey != 0x00)
            _inputState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ACCESSKEY, Character.toString(accessKey));

        // if there are attributes defined push them to the options.
        if (_attrs != null && _attrs.size() > 0) {
            Iterator iterator = _attrs.keySet().iterator();
            for (; iterator.hasNext();) {
                String key = (String) iterator.next();
                if (key == null)
                    continue;

                String value = (String) _attrs.get(key);
                _inputState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, key, value);
            }
        }

        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_BOOLEAN_TAG, req);
        br.doStartTag(buffer, _inputState);
        br.doEndTag(buffer);

        String ls = _labelStyle;
        String lsc = _labelStyleClass;

        _spanState.style = ls;
        _spanState.styleClass = lsc;

        br = TagRenderingBase.Factory.getRendering(TagRenderingBase.SPAN_TAG, req);
        br.doStartTag(buffer, _spanState);
        buffer.append(optionDisplay);
        br.doEndTag(buffer);

        // backward compatibility this is now overridden by the _orientation
        if (_orientation == null) {
            _cr.BR(buffer);
        }
        else {
            if (isVertical()) {
                _cr.TR_TD(buffer);
            }
            else {
                _cr.NBSP(buffer);
            }
        }
    }
428868
function
configure(options) {

  var config = {
    context: {},
    extension: '.html',
    verbose: false,
    renderString: false,
    piping: true
  };
  if (options === undefined || options === null)
    options = {};
  else
    options = cloneDeep(options);

  configureErrors(config, options);
  configureVerbosity(config, options);
  configureGlobals(config, options);
  configureLocals(config, options);
  configureContext(config, options);
  configureFiles(config, options);
  configureNunjucks(config, options);
  configurePluginOptions(config, options);

  return config;
}
114260
function TexImage () {
    TexFlags.call(this)

    this.xOffset = 0
    this.yOffset = 0

    // data
    this.data = null
    this.needsFree = false

    // html element
    this.element = null

    // copyTexImage info
    this.needsCopy = false
  }
927698
public static String exportToHtml(Option option) {
        String folderPath = System.getProperty("java.io.tmpdir");
        return exportToHtml(option, folderPath);
    }
530622
function renderImageToDataURL(img, blob, options, doSquash) {
        var canvas = document.createElement("canvas"),
            mime = options.mime || "image/jpeg",
            promise = new qq.Promise();

        renderImageToCanvas(img, blob, canvas, options, doSquash)
            .then(function() {
                promise.success(
                    canvas.toDataURL(mime, options.quality || 0.8)
                );
            });

        return promise;
    }
1280725
function(options){
	
	/**
	 *	@var
	 *	@desc Default sharper configuration options  
	**/
	var defaultOptions = {
		
		/**
		 *	@member {string}
		 *	@desc name of the image file field in multipart for data
		**/
		field : 'file',
		
		/**
		 *	@member {string}
		 *	@desc location of file upload
		**/
		location : '/var/www/uploads/',
		
		/**
		 *	@member {string}
		 *	@desc date-format to create upload directory
		**/
		dirFormat : 'yyyy/mmm/d',

		/**
		 *	@member {Number}
		 *	@desc length of the filename to be created
		**/
		fileNameLen : 50,

		/**
		 *	@member {string}
		 *	@desc maximum size of the file to be uploaded
		**/
		maxFileSize : '10mb',

		/**
		 *	@member {Array}
		 *	@desc type of files to be accepted (file extensions)
		**/
		accept : ['png','jpeg','jpg'],

		/**
		 *	@member {string}
		 *	@desc output extension of the image file
		**/
		output : 'jpg',

		/**
		 *	@member {Array}
		 *	@desc output images sizes and name suffix
		**/
		sizes : [
		    {suffix : 'lg', width : 500, height:500},
		],

		/*
		 *	sharp-libvips options
		 *	to process an image
		**/
		resize : true,
		crop : false,
		background : {r:200, g:200, b:200, a:1},
		embed : false,
		max : false,
		min : false,
		withoutEnlargement : false,
		ignoreAspectRatio : false,
		extract : false,
		trim : false,
		flatten : false,
		extend : false,
		negate : false,
		rotate : false,
		flip : false,
		flop : false,
		blur : false,
		sharpen : false,
		gamma : false,
		grayscale : false,
		greyscale : false,
		normalize : false,
		normalise : false,
		progressive : false,
		quality : false,
	};


	/**
	 *	@var
	 *	@desc Transformed options to be applied to sharper  
	**/
	var options = _.assign(defaultOptions, options);


	/********************************************************************/


	/**
	 *	@function middleware
	 *	@desc Express middleware function to be returned by sharper
	**/
	return function(req, res, next){
		
		/**
		 *	@name waterfall
		 *	@desc using async waterfall function,
		 *	run multiple tasks in series
		**/
		async.waterfall(
			[
				/**
				 *	@function masterUpload
				 *	@desc Upload master image file using multer
				 *	@param {Function} callback async callback function
				**/
				function(callback){
					// Create config variables
					var dir = dateformat(new Date(), options.dirFormat);
					var destination = options.location + dir;
					var filename = randomstring.generate(
						options.fileNameLen
					);

					// Create master upload function
					var masterUploader = multer({
						storage : multer.diskStorage({
							destination: destination,
							filename: function(req, file, cb){
								cb(null, filename);
							}
						}),
						limits : {
							// this will return error object
							fileSize : bytes(options.maxFileSize),
							files : 1
						},
						fileFilter : function(req, file, cb){
							var fileExt = mime.extension(file.mimetype);
							if(!_.includes(options.accept, fileExt)){
								cb(new sError('file not acceptable', 'FILE_TYPE_UNSUPPORTED', fileExt));
							}
							else{
								cb(null, true);
							}
						}
					}).single(options.field);

					// Run master uploader
					masterUploader(req, res, function(err){
						if(err) return callback(err);
						
						callback(null, {
							dir : dir,
							destination : destination,
							filename : filename
						});
					});
				},


				/**
				 *	@function processImages
				 *	@desc Process all images in sharp
				 *	@param {Object} state upload state object received from
				 *	masterUpload callback function
				 *	@param {Function} callback async callback function
				**/
				function(state, callback){
					// Get instance of sharp with master image file
					var master = sharp(state.destination + '/' + state.filename);

					// Process images with sizes [in config options]
					async.each(
						options.sizes,
						function(size, _cb){
							// resize by default
							var $query = master.background(options.background);

							// check resize
							if(options.resize == true){
								$query = $query.resize(size.width, size.height);
							}

							// check crop (on valid crop option)
							if(options.crop != false && _.has(sharp.gravity, options.crop)){
								$query = $query.crop(sharp.gravity[options.crop]);
							}

							// check embed
							if(options.embed == true){
								$query = $query.embed();
							}

							// check max
							if(options.max == true){
								$query = $query.max();
							}

							// check min
							if(options.min == true){
								$query = $query.min();
							}

							// check withoutEnlargement
							if(options.withoutEnlargement == true){
								$query = $query.withoutEnlargement();
							}

							// check ignoreAspectRatio
							if(options.ignoreAspectRatio == true){
								$query = $query.ignoreAspectRatio();
							}

							// check extract
							if(options.extract != false){
								$query = $query.extract(options.extract);
							}

							// check trim
							if(options.trim != false){
								$query = $query.trim(_.toInteger(options.trim));
							}

							// check flatten
							if(options.flatten == true){
								$query = $query.flatten();
							}

							// check extend
							if(options.extend != false){
								$query = $query.extend(options.extend);
							}

							// check negate
							if(options.negate == true){
								$query = $query.negate();
							}

							// check rotate
							if(_.includes([0,90,180,270], options.rotate)){
								$query = $query.rotate(options.rotate);
							}

							// check flip
							if(options.flip == true){
								$query = $query.flip();
							}

							// check flop
							if(options.flop == true){
								$query = $query.flop();
							}

							// check blur
							if(options.blur != false){
								if(options.blur == true) $query = $query.blur();
								else $query = $query.blur(_.toNumber(options.blur));
							}

							// check sharpen
							if(options.sharpen == true){
								$query = $query.sharpen();
							}

							// check gamma
							if(options.gamma != false){
								if(options.gamma == true) $query = $query.gamma();
								else $query = $query.gamma(_.toNumber(options.gamma));
							}

							// check grayscale
							if(options.grayscale == true || options.greyscale == true){
								$query = $query.grayscale();
							}

							// check normalize
							if(options.normalize == true || options.normalise == true){
								$query = $query.normalize();
							}

							// check quality
							if(options.quality != false){
								$query = $query.quality(_.toInteger(options.quality));
							}

							// check progressive
							if(options.progressive == true){
								$query = $query.progressive();
							}


							// run query
							$query.toFile(
								state.destination + '/' + state.filename + '.' +
								size.suffix + '.' + options.output, 
								function(err){
									if(err) return _cb(err)
									_cb(null);
								}
							);
						},

						// each callback
						function(err){
							if(err) return callback(err);
							callback(null, state);
						}
					);
				},


				/**
				 *	@function deleteMaster
				 *	@desc Delete master image file from file system
				 *	@param {Object} state upload state object received from
				 *	masterUpload callback function
				 *	@param {Function} callback async callback function
				**/
				function(state, callback){
					// Unlock master image
					sharp.cache(false);
					
					// Unlink file
					fs.unlink(state.destination + '/' + state.filename, function(err){
						if(err)	return callback(err);
						callback(null, state);
					});
				}
			],


			/**
			 *	@function waterfallCallback
			 *	@desc callback function for async watefall
			 *	@param {Error} err Error received from waterfall functions
			 *	@param {Function} state upload state object received from
			 *	deleteMaster callback function
			**/
			function(err, state){
				// Call next error middleware
				if(err) return next(err);

				// Add state to express response object
				res.sharper = state;
				
				// Call next middleware
				next();
			}
		);
	}
}
588171
function (options, dir, callback) {
  if (_.isObject(options.icon)) {
    createHicolorIcon(options, dir, callback)
  } else if (options.icon) {
    createPixmapIcon(options, dir, callback)
  } else {
    callback()
  }
}
1074398
function Jpegs2mjpeg(options) {
    if (!(this instanceof Jpegs2mjpeg))
        return new Jpegs2mjpeg(options);
    Transform.call(this);
    var opt = options instanceof Object ? util._extend({}, options) : {};
    this._boundary = 'boundary' in opt ? opt['boundary'] : 'xboundary';
    this._event = 'event' in opt ? opt['event'] : 'ready';
    this._delay = 'delay' in opt ? opt['delay'] : 0;
    this._ready = false;
    this._clients = [];
}
264874
function makeOptionsHot(id, options) {
  if (options.functional) {
    const render = options.render
    options.render = (h, ctx) => {
      const instances = map[id].instances
      if (ctx && instances.indexOf(ctx.parent) < 0) {
        instances.push(ctx.parent)
      }
      return render(h, ctx)
    }
  } else {
    injectHook(options, initHookName, function() {
      const record = map[id]
      if (!record.Ctor) {
        record.Ctor = this.constructor
      }
      record.instances.push(this)
    })
    injectHook(options, 'beforeDestroy', function() {
      const instances = map[id].instances
      instances.splice(instances.indexOf(this), 1)
    })
  }
}