create Image objects and transfer image files to media root
504446
def create_images_from_urls_in_content(self, body):
        """"""
        soup = BeautifulSoup(body, "html5lib")
        for img in soup.findAll('img'):
            old_url = img['src']
            if 'width' in img:
                width = img['width']
            if 'height' in img:
                height = img['height']
            else:
                width = 100
                height = 100
            path, file_ = os.path.split(img['src'])
            if not img['src']:
                continue  # Blank image
            if img['src'].startswith('data:'):
                continue # Embedded image
            try:
                remote_image = urllib.request.urlretrieve(
                    self.prepare_url(img['src']))
            except (urllib.error.HTTPError,
                    urllib.error.URLError,
                    UnicodeEncodeError,
                    ValueError):
                print("Unable to import " + img['src'])
                continue
            image = Image(title=file_, width=width, height=height)
            try:
                image.file.save(file_, File(open(remote_image[0], 'rb')))
                image.save()
                new_url = image.file.url
                body = body.replace(old_url, new_url)
                body = self.convert_html_entities(body)
            except TypeError:
                print("Unable to import image {}".format(remote_image[0]))
        return body
588171
function (options, dir, callback) {
  if (_.isObject(options.icon)) {
    createHicolorIcon(options, dir, callback)
  } else if (options.icon) {
    createPixmapIcon(options, dir, callback)
  } else {
    callback()
  }
}
1363378
def insert_virtual_media(self, url, device='FLOPPY'):
        """"""
        dic = {
            'DEVICE': device.upper(),
            'IMAGE_URL': url,
        }
        data = self._execute_command(
            'INSERT_VIRTUAL_MEDIA', 'RIB_INFO', 'write', dic)
        return data
432113
def dump_image_data(dataset_dir, data_dir, dataset, color_array_info, root=None, compress=True):
    """"""
    if root is None:
        root = {}
    root['vtkClass'] = 'vtkImageData'
    container = root

    container['spacing'] = dataset.GetSpacing()
    container['origin'] = dataset.GetOrigin()
    container['extent'] = dataset.GetExtent()

    dump_all_arrays(dataset_dir, data_dir, dataset, container, compress)

    return root
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;
  }
1364867
def make_image(self, conf, images, chain=None, parent_chain=None, made=None, ignore_deps=False, ignore_parent=False, pushing=False):
        """"""
        made = {} if made is None else made
        chain = [] if chain is None else chain
        parent_chain = [] if parent_chain is None else parent_chain

        if conf.name in made:
            return

        if conf.name in chain and not ignore_deps:
            raise BadCommand("Recursive dependency images", chain=chain + [conf.name])

        if conf.name in parent_chain and not ignore_parent:
            raise BadCommand("Recursive FROM statements", chain=parent_chain + [conf.name])

        if conf.name not in images:
            raise NoSuchImage(looking_for=conf.name, available=images.keys())

        if not ignore_deps:
            for dependency, image in conf.dependency_images():
                self.make_image(images[dependency], images, chain=chain + [conf.name], made=made, pushing=pushing)

        if not ignore_parent:
            for dep in conf.commands.dependent_images:
                if not isinstance(dep, six.string_types):
                    self.make_image(dep, images, chain, parent_chain + [conf.name], made=made, pushing=pushing)

        # Should have all our dependencies now
        log.info("Making image for '%s' (%s)", conf.name, conf.image_name)
        cached = self.build_image(conf, pushing=pushing)
        made[conf.name] = True
        return cached
362972
def save_image(filename,view='axial',type='png',hostname=None):
    ''''''
    driver_send("SAVE_%s %simage %s" % (type.upper(),view.lower(),filename),hostname=hostname)
574270
def exportdb(outdir):
    """"""
    ecode = 0
    try:
        imgdir = os.path.join(outdir, "images")
        feeddir = os.path.join(outdir, "feeds")
        storedir = os.path.join(outdir, "storedfiles")

        for d in [outdir, imgdir, feeddir, storedir]:
            if not os.path.exists(d):
                os.makedirs(d)

        anchore_print("exporting images...")
        imagelist = anchore_utils.get_image_list().keys()
        for imageId in imagelist:
            thefile = os.path.join(imgdir, imageId+".json")
            if not os.path.exists(thefile):
                with open(thefile, 'w') as OFH:
                    OFH.write(json.dumps(contexts['anchore_db'].load_image_new(imageId)))

            stored_namespaces = contexts['anchore_db'].load_files_namespaces(imageId)
            for namespace in stored_namespaces:
                stored_files = contexts['anchore_db'].load_files_tarfile(imageId, namespace)
                if os.path.exists(stored_files):
                    thedir = os.path.join(storedir, imageId, namespace)
                    if not os.path.exists(thedir):
                        os.makedirs(thedir)
                    thefile = os.path.join(thedir, "stored_files.tar.gz")
                    shutil.copy(stored_files, thefile)

        anchore_print("exporting feeds...")
        feedmeta = contexts['anchore_db'].load_feedmeta()
        thefile = os.path.join(feeddir, "feedmeta.json")
        with open(thefile, 'w') as OFH:
            OFH.write(json.dumps(feedmeta))

        for feed in feedmeta:
            feedobj = feedmeta[feed]
            for group in feedobj['groups']:
                groupobj = feedobj['groups'][group]
                datafiles = groupobj.pop('datafiles', [])
                for datafile in datafiles:
                    thedir = os.path.join(feeddir, feed, group)
                    if not os.path.exists(thedir):
                        os.makedirs(thedir)
                    thefile = os.path.join(thedir, datafile)
                    if not os.path.exists(thefile):
                        with open(thefile, 'w') as OFH:
                            OFH.write(json.dumps(contexts['anchore_db'].load_feed_group_data(feed, group, datafile)))

    except Exception as err:
        anchore_print_err("operation failed: " + str(err))
        ecode = 1

    sys.exit(ecode)
785489
def write_image_to_disk(self, msg, result, fh):
        """"""
        cairosvg.svg2png(bytestring=msg.encode('utf-8'), write_to=fh)
232268
function(callback) {
      var firstThumbnail;

      for (var i = 0; i < thumbnailsPaths.length; i++) {
        var thumbnailsPath = thumbnailsPaths[i].thumbnailPath;

        if (!firstThumbnail)
          firstThumbnail = gm(thumbnailsPath);
        else
          firstThumbnail.append(thumbnailsPath, horizontally);

        images.push({
          sprite: destinationPath,
          image: thumbnailsPaths[i].originalPath,
          x: horizontally ? width * i : 0,
          y: horizontally ? 0 : height * i
        });
      }
      firstThumbnail
        .quality(quality)
        .write(destinationPath, callback);
    }
294596
def base64ToImage(imgData, out_path, out_file):
        
        fh = open(os.path.join(out_path, out_file), "wb")
        fh.write(imgData.decode('base64'))
        fh.close()
        del fh
        return os.path.join(out_path, out_file)
152813
def _thumbnail_local(self, original_filename, thumb_filename,
                         thumb_size, thumb_url, crop=None, bg=None,
                         quality=85):
        """"""

        # create folders
        self._get_path(thumb_filename)

        thumb_url_full = url_for('static', filename=thumb_url)

        # Return the thumbnail URL now if it already exists locally
        if os.path.exists(thumb_filename):
            return thumb_url_full

        try:
            image = Image.open(original_filename)
        except IOError:
            return ''

        img = self._thumbnail_resize(image, thumb_size, crop=crop, bg=bg)

        img.save(thumb_filename, image.format, quality=quality)

        return thumb_url_full
945590
def custom_image(self, user):
        """"""
        for ext in self.valid_custom_image_extensions():
            image_location = self._custom_image_path(user, ext)
            if os.path.isfile(image_location):
                return image_location
        return None
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
474555
def __create_image(self, inpt, hashfun):
        """"""
        if hashfun not in generator.HASHES.keys():
            print ("Unknown or unsupported hash function. Using default: %s"
                   % self.DEFAULT_HASHFUN)
            algo = self.DEFAULT_HASHFUN
        else:
            algo = hashfun
        return generator.generate(inpt, algo)
364676
public void createImages() {
		image = UtilImageIO.loadImage(UtilIO.pathExample("standard/barbara.jpg"));

		gray = ConvertBufferedImage.convertFromSingle(image, null, GrayU8.class);
		derivX = GeneralizedImageOps.createSingleBand(GrayS16.class, gray.getWidth(), gray.getHeight());
		derivY = GeneralizedImageOps.createSingleBand(GrayS16.class, gray.getWidth(), gray.getHeight());

		GImageDerivativeOps.gradient(DerivativeType.SOBEL, gray, derivX, derivY, BorderType.EXTENDED);
	}
156312
function copyMedia (path, to, cert, callback) {
  var hookPath = __dirname + '/../data/buffer/hook.sh'
  debug('copyMedia', path, to, cert)

  if (/^http/.test(to)) {
    debug('using http')
    var parsed = url.parse(to)
    debug('parsed', parsed)

    var domain = url.parse(to).domain
    var file = url.parse(to).path
    debug(domain, file)

    var a = parsed.pathname.split('/')
    var uri = parsed.protocol + '//' + parsed.host
    for (var i = 0; i < a.length - 1; i++) {
      uri += a[i] + '/'
    }
    uri += urlencode(a[i])
    debug('uri', uri)

    // uri = 'https://phone.servehttp.com:8000/data/buffer/image/'  + urlencode('file%3A%2F%2F%2Fmedia%2Fmelvin%2FElements%2Fpichunter.com%2F2443342_15_o.jpg')

    var options = {
      method: 'PUT',
      url: uri,
      key: fs.readFileSync(cert),
      cert: fs.readFileSync(cert),
      headers: { // We can define headers too
        'Content-Type': 'image/jpg'
      }
    }

    debug(options)
    fs.createReadStream(path).pipe(request.put(options, function (err, response, body) {
      if (err) {
        debug(err)
        callback(err)
      } else {
        debug('success')
        callback(null)
        setTimeout(function () {
          exec(hookPath)
        }, 0)
      }
    }))
  } else {
    fs.copy(path, to, function (err) {
      if (err) {
        callback(err)
      } else {
        callback(null, null)
        setTimeout(function () {
          exec(hookPath)
        }, 0)
      }
    })
  }
}