create capatcha image resource
540621
private function createCaptchaImage()
	{
		
		$this->_image_resource = imagecreatetruecolor( $this->_image_info['width'], $this->_image_info['height'] );
		
		if( function_exists( 'imageantialias' ) )
			imageantialias( $this->_image_resource, true );
		
		# Get Colors Values	
		$rgb = $this->getRGBFromRange(
			$this->_image_info['color'][0],
			$this->_image_info['color'][1],
			$this->_image_info['color'][2],
			$this->_image_info['color']['range']
			);

		# Get Color;
		$background_color = imagecolorallocate(
			$this->_image_resource,					# Image Resource
			$rgb[0],								# R
			$rgb[1],								# G
			$rgb[2]									# B
			);
		
		# Apply Color
		imagefill(
			$this->_image_resource,					# Image Resource
			0,										# Positon X
			0,										# Positon Y
			$background_color						# Color
			);


		# Method End
	}
94627
function createIconFiles(srcFile, dest) {
  const thisTaskName = swlog.logSubStart('create icon files');

  return new Promise(resolve => {
    const exportArtboardsOptions = [
      'export',
      'artboards',
      srcFile,
      `--formats=${options.iconFormats.join(',')}`,
      '--include-symbols=NO',
      '--save-for-web=YES',
      `--output=${dest}`
    ];

    const outputStr = sketchtoolExec(exportArtboardsOptions.join(' '));
    resolve(outputStr);
  })
  .then(output => {
    options.iconFormats.forEach(format => {
      const regex = new RegExp(`\\.${format}`, 'g');
      const count = (output.match(regex) || []).length;
      swlog.logTaskAction('Created', `${count} ${format.toUpperCase()} files`);
    })

    swlog.logSubEnd(thisTaskName);

    if (options.iconFormats.indexOf('svg') !== -1) {
      return optimizeSVGs(dest);
    }
  });
}
1316216
def build_image_from_inherited_image(self, image_name: str, image_tag: str,
                                         repo_path: Path,
                                         requirements_option: RequirementsOptions):
        

        base_name, base_tag = self.get_inherit_image()

        if requirements_option == RequirementsOptions.no_requirements:
            image = self.get_image(base_name, base_tag)
            image.tag(image_name, image_tag)  # so ``build_image`` doesn't have to be called next time

            return image

        dockerfile = self.get_install_requirements_dockerfile(base_name, base_tag, repo_path, requirements_option)

        self.get_or_build_image(image_name, image_tag, dockerfile, build_context=repo_path.parent, pull=False)

        return self.get_image(image_name, image_tag)
504010
def set_image(self):
        """"""

        if not self.image:
            scrape_image(self)

        # If still no image then use first contributor image
        if not self.image:
            contributors = self.get_primary_contributors()
            if contributors:
                self.image = contributors[0].image
                self.save(set_image=False)

        # If still not image then default
        if not self.image:
            filename = settings.STATIC_ROOT + 'music/images/default.png'
            if os.path.exists(filename):
                image = File(
                    open(filename, 'rb')
                )
                image.name = 'default.png'
                self.image = image
                self.save(set_image=False)
874893
function buildResourceHint (hint, asset, glob) {
  var as = ''

  if (hint === 'dns-prefetch' || hint === 'preconnect') {
    if (!urlMatch(asset, glob)) {
      return ''
    }

    asset = urlParse(asset)
    if (isDuplicate(asset, true)) {
      return ''
    }
  } else {
    if (!minimatch(asset, glob) || isDuplicate(asset)) {
      return ''
    }
    if (globMatch(asset, fonts)) {
      as += ' as="font"'
    } else if (isCSS(asset)) {
      as += ' as="style"'
    }
  }

  parsedAssets.push(asset)
  return `<link rel="${hint}" href="${asset}"${as} />`
}
402344
def make_image_converters(self, image, configuration, harpoon_spec):
        """"""
        def convert_image(path, val):
            log.info("Converting %s", path)
            everything = path.configuration.root().wrapped()
            meta = Meta(everything, [])
            configuration.converters.started(path)

            base = path.configuration.root().wrapped()
            base.update(configuration.as_dict(ignore=["images"]))
            base.update(val.as_dict(ignore=["images"]))

            base["__image__"] = base
            everything["__image__"] = base

            base["harpoon"] = configuration["harpoon"]
            base["configuration"] = configuration
            return harpoon_spec.image_spec.normalise(meta.at("images").at(image), base)

        converter = Converter(convert=convert_image, convert_path=["images", image])
        configuration.add_converter(converter)

        def convert_tasks(path, val):
            spec = harpoon_spec.tasks_spec(available_actions)
            meta = Meta(path.configuration.root(), []).at("images").at(image).at("tasks")
            configuration.converters.started(path)
            tasks = spec.normalise(meta, val)
            for task in tasks.values():
                task.image = image
            return tasks

        converter = Converter(convert=convert_tasks, convert_path=["images", image, "tasks"])
        configuration.add_converter(converter)
935295
def image(self, raw_url, title='', alt=''):
        '''  '''
        max_images = self._config.get('count')
        if max_images is not None and len(self._out.images) >= max_images:
            # We already have enough images, so bail out
            return ' '

        image_specs = raw_url
        if title:
            image_specs += ' "{}"'.format(title)

        alt, container_args = image.parse_alt_text(alt)

        spec_list, _ = image.get_spec_list(image_specs, container_args)

        for spec in spec_list:
            if not spec:
                continue

            self._out.images.append(self._render_image(spec, alt))
            if max_images is not None and len(self._out.images) >= max_images:
                break

        return ' '
743933
function imageToCanvas(img) {
    var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
    var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

    if (!img.complete) {
      throw new Error('Can not create canvas from Image. Image is not loaded yet.');
    }
    var canvas = document.createElement("canvas");
    if (width === null && height === null) {
      canvas.width = img.naturalWidth;
      canvas.height = img.naturalHeight;
      canvas.getContext("2d").drawImage(img, 0, 0);
    } else {
      canvas.width = width;
      canvas.height = height;
      canvas.getContext("2d").drawImage(img, 0, 0, width, height);
    }
    return canvas;
  }
848998
def _create_body(self, name, img=None, cont=None, img_format=None,
            img_name=None):
        
        img = utils.get_id(img)
        cont = utils.get_name(cont)
        body = {"type": name}
        if name == "export":
            body["input"] = {
                    "image_uuid": img,
                    "receiving_swift_container": cont}
        else:
            nm = "%s/%s" % (cont, utils.get_name(img))
            body["input"] = {
                    "image_properties": {"name": img_name or img},
                    "import_from": nm,
                    "import_from_format": img_format or DEFAULT_FORMAT}
        return body
941598
def _create_board_image_cv(self, board=None):
        """"""
        board = board or base.Board()  # empty board by default
        tile_h, tile_w = self._TILE_SHAPE[0:2]
        board_shape = tile_h * 8, tile_w * 8, 3
        board_image = numpy.zeros(board_shape, dtype=numpy.uint8)
        # place each tile on the image
        for (row, col), tile in board.positions_with_tile():
            tile_image = self._tile_images[tile._type]
            t, l = row * tile_h, col * tile_w
            b, r = t + tile_h, l + tile_w
            board_image[t:b, l:r] = tile_image
        return board_image
227116
def create_sprite_image(examples):
    

    def generate_image_from_thubnails(thumbnails, thumbnail_dims):
      """Generates a sprite atlas image from a set of thumbnails."""
      num_thumbnails = tf.shape(thumbnails)[0].eval()
      images_per_row = int(math.ceil(math.sqrt(num_thumbnails)))
      thumb_height = thumbnail_dims[0]
      thumb_width = thumbnail_dims[1]
      master_height = images_per_row * thumb_height
      master_width = images_per_row * thumb_width
      num_channels = 3
      master = np.zeros([master_height, master_width, num_channels])
      for idx, image in enumerate(thumbnails.eval()):
        left_idx = idx % images_per_row
        top_idx = int(math.floor(idx / images_per_row))
        left_start = left_idx * thumb_width
        left_end = left_start + thumb_width
        top_start = top_idx * thumb_height
        top_end = top_start + thumb_height
        master[top_start:top_end, left_start:left_end, :] = image
      return tf.image.encode_png(master)

    image_feature_name = 'image/encoded'
    sprite_thumbnail_dim_px = 32
    with tf.compat.v1.Session():
      keys_to_features = {
          image_feature_name:
              tf.FixedLenFeature((), tf.string, default_value=''),
      }
      parsed = tf.parse_example(examples, keys_to_features)
      images = tf.zeros([1, 1, 1, 1], tf.float32)
      i = tf.constant(0)
      thumbnail_dims = (sprite_thumbnail_dim_px,
                        sprite_thumbnail_dim_px)
      num_examples = tf.constant(len(examples))
      encoded_images = parsed[image_feature_name]

      # Loop over all examples, decoding the image feature value, resizing
      # and appending to a list of all images.
      def loop_body(i, encoded_images, images):
        encoded_image = encoded_images[i]
        image = tf.image.decode_jpeg(encoded_image, channels=3)
        resized_image = tf.image.resize(image, thumbnail_dims)
        expanded_image = tf.expand_dims(resized_image, 0)
        images = tf.cond(
            tf.equal(i, 0), lambda: expanded_image,
            lambda: tf.concat([images, expanded_image], 0))
        return i + 1, encoded_images, images

      loop_out = tf.while_loop(
          lambda i, encoded_images, images: tf.less(i, num_examples),
          loop_body, [i, encoded_images, images],
          shape_invariants=[
              i.get_shape(),
              encoded_images.get_shape(),
              tf.TensorShape(None)
          ])

      # Create the single sprite atlas image from these thumbnails.
      sprite = generate_image_from_thubnails(loop_out[2], thumbnail_dims)
      return sprite.eval()
96720
def ensure_image(name, url, images_root, md5, untar_to=None):
    """"""
    image_dir_path = os.path.join(images_root, name)
    mkdir(image_dir_path)
    image_file_path = os.path.join(image_dir_path, os.path.basename(url))
    ensure_file(url, image_file_path, md5)
    if untar_to:
        prepare_image(image_file_path, untar_to)
1299726
def make(collector, image, **kwargs):
    """"""
    tag = kwargs.get("artifact", NotSpecified)
    if tag is NotSpecified:
        tag = collector.configuration["harpoon"].tag

    if tag is not NotSpecified:
        image.tag = tag

    Builder().make_image(image, collector.configuration["images"])
    print("Created image {0}".format(image.image_name))
512416
function createPictures(id, farm, server, secret) {

		var NO_LIMIT = 2048;
		var sizes = [
			{id: 't', max: 100},
			{id: 'm', max: 240},
			{id: 'n', max: 320},
			{id: '', max: 500},
			{id: 'z', max: 640},
			{id: 'c', max: 800},
			{id: 'b', max: 1024},
			{id: 'h', max: 1600},
			{id: 'k', max: 2048},
			{id: 'o', max: NO_LIMIT}
		];

		return sizes.map(function(size) {
			return {
				source: createPhotoUrl(id, farm, server, secret, size.id),

				// Note: this is a guess that's almost certain to be wrong (unless square source)
				width: size.max,
				height: size.max
			};
		});
	}
491399
def _make_sprite_image(images, save_path):
    """"""
    if isinstance(images, np.ndarray):
        images = nd.array(images, dtype=images.dtype, ctx=current_context())
    elif not isinstance(images, (NDArray, np.ndarray)):
        raise TypeError('images must be an MXNet NDArray or numpy.ndarray,'
                        ' while received type {}'.format(str(type(images))))

    assert isinstance(images, NDArray)
    shape = images.shape
    nrow = int(np.ceil(np.sqrt(shape[0])))
    _save_image(
        images, os.path.join(save_path, 'sprite.png'), nrow=nrow, padding=0, square_image=True)
729223
def _create_thumbnail(self, model_instance, thumbnail, image_name):
        
        thumbnail = self._do_resize(thumbnail, self.thumbnail_size)
        full_image_name = self.generate_filename(model_instance, image_name)
        thumbnail_filename = _get_thumbnail_filename(full_image_name)
        thumb = self._get_simple_uploaded_file(thumbnail, thumbnail_filename)
        self.storage.save(thumbnail_filename, thumb)
42679
def make_rendition(self, width, height):
        '''
        '''
        image = Image.open(self.master)
        format = image.format

        target_w = float(width)
        target_h = float(height)

        if (target_w == 0):
            target_w = self.master_width

        if (target_h == 0):
            target_h = self.master_height

        rendition_key = '%dx%d' % (target_w, target_h)

        if rendition_key in self.renditions:
            return self.renditions[rendition_key]

        if (target_w != self.master_width or target_h != self.master_height):
            r = target_w / target_h
            R = float(self.master_width) / self.master_height
            if r != R:
                if r > R:
                    crop_w = self.master_width
                    crop_h = crop_w / r
                    x = 0
                    y = int(self.master_height - crop_h) >> 1
                else:
                    crop_h = self.master_height
                    crop_w = crop_h * r
                    x = int(self.master_width - crop_w) >> 1
                    y = 0
                image = image.crop((x, y, int(crop_w + x), int(crop_h + y)))

            image.thumbnail((int(target_w), int(target_h)), Image.ANTIALIAS)

            filename, ext = os.path.splitext(self.get_master_filename())
            rendition_name = '%s/%s_%s%s' % (
                IMAGE_DIRECTORY,
                filename,
                rendition_key,
                ext
            )
            fd = BytesIO()
            image.save(fd, format)
            default_storage.save(rendition_name, fd)

            self.renditions[rendition_key] = rendition_name
            self.save()

            return rendition_name

        return self.master.name