Poll imgadm and compare available images
541807
def beacon(config):
    '''
    
    '''
    ret = []

    # NOTE: lookup current images
    current_images = __salt__['imgadm.list'](verbose=True)

    # NOTE: apply configuration
    if IMGADM_STATE['first_run']:
        log.info('Applying configuration for imgadm beacon')

        _config = {}
        list(map(_config.update, config))

        if 'startup_import_event' not in _config or not _config['startup_import_event']:
            IMGADM_STATE['images'] = current_images

    # NOTE: import events
    for uuid in current_images:
        event = {}
        if uuid not in IMGADM_STATE['images']:
            event['tag'] = "imported/{}".format(uuid)
            for label in current_images[uuid]:
                event[label] = current_images[uuid][label]

        if event:
            ret.append(event)

    # NOTE: delete events
    for uuid in IMGADM_STATE['images']:
        event = {}
        if uuid not in current_images:
            event['tag'] = "deleted/{}".format(uuid)
            for label in IMGADM_STATE['images'][uuid]:
                event[label] = IMGADM_STATE['images'][uuid][label]

        if event:
            ret.append(event)

    # NOTE: update stored state
    IMGADM_STATE['images'] = current_images

    # NOTE: disable first_run
    if IMGADM_STATE['first_run']:
        IMGADM_STATE['first_run'] = False

    return ret
327325
def has_image(self, digest, mime_type, index, size=500):
        """"""
        cache_key = f"img:{index}:{size}:{digest}"
        return mime_type.startswith("image/") or cache_key in self.cache
1336738
def checkImages(images):
    
    # Init results
    images2 = []

    for im in images:
        if PIL and isinstance(im, PIL.Image.Image):
            # We assume PIL images are allright
            images2.append(im)

        elif np and isinstance(im, np.ndarray):
            # Check and convert dtype
            if im.dtype == np.uint8:
                images2.append(im)  # Ok
            elif im.dtype in [np.float32, np.float64]:
                im = im.copy()
                im[im < 0] = 0
                im[im > 1] = 1
                im *= 255
                images2.append(im.astype(np.uint8))
            else:
                im = im.astype(np.uint8)
                images2.append(im)
            # Check size
            if im.ndim == 2:
                pass  # ok
            elif im.ndim == 3:
                if im.shape[2] not in [3, 4]:
                    raise ValueError('This array can not represent an image.')
            else:
                raise ValueError('This array can not represent an image.')
        else:
            raise ValueError('Invalid image type: ' + str(type(im)))

    # Done
    return images2
1118757
def _check_img_lib():
    """"""
    # Import imageio or PIL
    imageio = PIL = None
    try:
        import imageio
    except ImportError:
        try:
            import PIL.Image
        except ImportError:
            pass
    return imageio, PIL
209607
def get(img, light=False):
    """"""
    cols = gen_colors(img)

    if len(cols) < 6:
        logging.error("colorz failed to generate enough colors.")
        logging.error("Try another backend or another image. (wal --backend)")
        sys.exit(1)

    return adjust(cols, light)
476142
def image_exists(self, image_name, image_tag):
        
        try:
            self.get_image(image_name, image_tag)
            return True
        except docker.errors.ImageNotFound:
            return False
411833
private function performCompare($image1, $image2)
    {
        $result = $image1->compareImages($image2, Imagick::METRIC_MEANSQUAREERROR);
        return $result[1];
    }
859486
def _get_renditions(self, kwargs):
        
        img_1x, size = self.get_rendition(
            1, **utils.remap_args(kwargs, {"quality": "quality_ldpi"}))
        img_2x, _ = self.get_rendition(
            2, **utils.remap_args(kwargs, {"quality": "quality_hdpi"}))

        return (img_1x, img_2x, size)
158202
def get(img, light=False):
    """"""
    cols = gen_colors(img)
    return adjust(cols, light)
597495
def _get_album_or_image(json, imgur):
    """"""
    if json['is_album']:
        return Gallery_album(json, imgur, has_fetched=False)
    return Gallery_image(json, imgur)
619817
def image2wxbitmap(img):
    ""
    if is_wxPhoenix:
        wximg = wx.Image(*img.size)
    else:
        wximg = wx.EmptyImage(*img.size)
    wximg.SetData(img.tobytes())
    return wximg.ConvertToBitmap()
705584
function _getNeighborPixels(coord, imgSize, imgCols) {
    var res = [], pos;

    if (coord.x > 0 && coord.y > 0) { // tlPx
        pos = {
            x: coord.x - 1,
            y: coord.y - 1
        };
        res.push({
            coord: pos,
            color: _getColorByXY(pos, imgSize, imgCols)
        });
    }

    if (coord.y > 0) { // tPx
        pos = {
            x: coord.x,
            y: coord.y - 1
        };
        res.push({
            coord: pos,
            color: _getColorByXY(pos, imgSize, imgCols)
        });
    }

    if (coord.x < imgSize.w && coord.y > 0) { // trPx
        pos = {
            x: coord.x + 1,
            y: coord.y - 1
        };
        res.push({
            coord: pos,
            color: _getColorByXY(pos, imgSize, imgCols)
        });
    }

    if (coord.x < imgSize.w) { // rPx
        pos = {
            x: coord.x + 1,
            y: coord.y
        };
        res.push({
            coord: pos,
            color: _getColorByXY(pos, imgSize, imgCols)
        });
    }

    if (coord.x < imgSize.w && coord.y < imgSize.h) { // brPx
        pos = {
            x: coord.x + 1,
            y: coord.y + 1
        };
        res.push({
            coord: pos,
            color: _getColorByXY(pos, imgSize, imgCols)
        });
    }

    if (coord.y < imgSize.h) { // bPx
        pos = {
            x: coord.x,
            y: coord.y + 1
        };
        res.push({
            coord: pos,
            color: _getColorByXY(pos, imgSize, imgCols)
        });
    }

    if (coord.x > 0 && coord.y < imgSize.h) { // blPx
        pos = {
            x: coord.x - 1,
            y: coord.y + 1
        };
        res.push({
            coord: pos,
            color: _getColorByXY(pos, imgSize, imgCols)
        });
    }

    if (coord.x > 0) { // lPx
        pos = {
            x: coord.x - 1,
            y: coord.y
        };
        res.push({
            coord: pos,
            color: _getColorByXY(pos, imgSize, imgCols)
        });
    }

    return res;
}
716584
def get_random_image(img_dir):
    """"""
    images, current_wall = get_image_dir(img_dir)

    if len(images) > 2 and current_wall in images:
        images.remove(current_wall)

    elif not images:
        logging.error("No images found in directory.")
        sys.exit(1)

    random.shuffle(images)
    return os.path.join(img_dir, images[0])
504399
def version():
    '''
    
    '''
    ret = {}
    cmd = 'imgadm --version'
    res = __salt__['cmd.run'](cmd).splitlines()
    ret = res[0].split()
    return ret[-1]
535103
def convert(self, im):
        
        _im = im
        if self.image_property:
            _im = self.image_property.convert(im)

        return _im
590694
def _extract_image_urls(arg: Message_T) -> List[str]:
    """"""
    arg_as_msg = Message(arg)
    return [s.data['url'] for s in arg_as_msg
            if s.type == 'image' and 'url' in s.data]
1371079
def image_exists(self, id=None, tag=None):
        
        exists = False
        if id and self.image_by_id(id):
            exists = True
        elif tag and self.image_by_tag(tag):
            exists = True

        return exists