// DeleteImage deletes an image.
493515
func (c *Conn) DeleteImage(image *Image) error {
	return c.do("smugmug.images.delete", nil, "ImageID", itoa64(image.ID))
}
624918
func (s *SetUICustomizationInput) SetImageFile(v []byte) *SetUICustomizationInput {
	s.ImageFile = v
	return s
}
292165
func (s *DetectModerationLabelsInput) SetImage(v *Image) *DetectModerationLabelsInput {
	s.Image = v
	return s
}
132339
func (s *UsersService) DeletePhoto() *UsersDeletePhotoCall {
	var call UsersDeletePhotoCall
	call.service = s
	return &call
}
1301586
func (s *DetectFacesInput) SetImage(v *Image) *DetectFacesInput {
	s.Image = v
	return s
}
169368
func (c *CloudAPI) GetImage(imageID string) (*cloudapi.Image, error) {
	if err := c.ProcessFunctionHook(c, imageID); err != nil {
		return nil, err
	}

	for _, image := range c.images {
		if image.Id == imageID {
			return &image, nil
		}
	}

	return nil, fmt.Errorf("Image %s not found", imageID)
}
1137560
func (e *EmptyService) RemoveImage(ctx context.Context, imageType options.ImageType) error {
	return nil
}
1216463
func (c *FakeImages) Delete(name string, options *v1.DeleteOptions) error {
	_, err := c.Fake.
		Invokes(testing.NewRootDeleteAction(imagesResource, name), &image.Image{})
	return err
}
1041639
func (c *Client) GetImage(ctx context.Context, ref string) (Image, error) {
	i, err := c.ImageService().Get(ctx, ref)
	if err != nil {
		return nil, err
	}
	return NewImage(c, i), nil
}
1000214
func normalizeImage(image string) string {
	if strings.Contains(image, ":") {
		t := strings.Split(image, ":")
		return t[0]
	}
	return image
}
76867
func convertImage(dest *Image, src image.Image) {
	var r, g, b, a uint32
	var x, y, i int

	for x = dest.Rect.Min.X; x < dest.Rect.Max.X; x++ {
		for y = dest.Rect.Min.Y; y < dest.Rect.Max.Y; y++ {
			r, g, b, a = src.At(x, y).RGBA()
			i = dest.PixOffset(x, y)
			dest.Pix[i+0] = uint8(b >> 8)
			dest.Pix[i+1] = uint8(g >> 8)
			dest.Pix[i+2] = uint8(r >> 8)
			dest.Pix[i+3] = uint8(a >> 8)
		}
	}
}
787966
func cleanImageOnNode(ctx context.Context, node *types.Node, image string, count int) error {
	log.Debugf("[cleanImageOnNode] node: %s, image: %s", node.Name, image)
	images, err := node.Engine.ImageList(ctx, image)
	if err != nil {
		return err
	}

	if len(images) < count {
		return nil
	}

	images = images[count:]
	for _, image := range images {
		log.Debugf("[cleanImageOnNode] Delete Images: %s", image.Tags)
		if _, err := node.Engine.ImageRemove(ctx, image.ID, false, true); err != nil {
			log.Errorf("[cleanImageOnNode] Node %s ImageRemove error: %s, imageID: %s", node.Name, err, image.Tags)
		}
	}
	return nil
}
1295884
func (c *Client) DeleteFile(fileName string) error {
	if c.masterKey == "" {
		return ErrRequiresMasterKey
	}
	resp, err := c.doSimple("DELETE", "/1/files/"+fileName)
	if err != nil {
		return err
	}
	c.trace("DeleteFile", fileName)
	defer resp.Body.Close()
	return nil
}
982388
func (client *Client) DeleteImageWithForce(regionId common.Region, imageId string, force bool) error {
	args := DeleteImageArgs{
		RegionId: regionId,
		ImageId:  imageId,
		Force:    force,
	}

	response := &DeleteImageResponse{}
	return client.Invoke("DeleteImage", &args, &response)
}
144800
func (c *Client) GetImage(imageID string) (*Image, error) {
	var resp Image
	req := request{
		method: client.GET,
		url:    makeURL(apiImages, imageID),
		resp:   &resp,
	}
	if _, err := c.sendRequest(req); err != nil {
		return nil, errors.Newf(err, "failed to get image with id: %s", imageID)
	}
	return &resp, nil
}
918595
func (d *dockerCoordinator) removeImageImpl(id string, ctx context.Context) {
	// Wait for the delay or a cancellation event
	select {
	case <-ctx.Done():
		// We have been cancelled
		return
	case <-time.After(d.removeDelay):
	}

	// Ensure we are suppose to delete. Do a short check while holding the lock
	// so there can't be interleaving. There is still the smallest chance that
	// the delete occurs after the image has been pulled but before it has been
	// incremented. For handling that we just treat it as a recoverable error in
	// the docker driver.
	d.imageLock.Lock()
	select {
	case <-ctx.Done():
		d.imageLock.Unlock()
		return
	default:
	}
	d.imageLock.Unlock()

	for i := 0; i < 3; i++ {
		err := d.client.RemoveImage(id)
		if err == nil {
			break
		}

		if err == docker.ErrNoSuchImage {
			d.logger.Debug("unable to cleanup image, does not exist", "image_id", id)
			return
		}
		if derr, ok := err.(*docker.Error); ok && derr.Status == 409 {
			d.logger.Debug("unable to cleanup image, still in use", "image_id", id)
			return
		}

		// Retry on unknown errors
		d.logger.Debug("failed to remove image", "image_id", id, "attempt", i+1, "error", err)

		select {
		case <-ctx.Done():
			// We have been cancelled
			return
		case <-time.After(3 * time.Second):
		}
	}

	d.logger.Debug("cleanup removed downloaded image", "image_id", id)

	// Cleanup the future from the map and free the context by cancelling it
	d.imageLock.Lock()
	if cancel, ok := d.deleteFuture[id]; ok {
		delete(d.deleteFuture, id)
		cancel()
	}
	d.imageLock.Unlock()
}
768552
func ImageRemove(id string) error {
	return mgr.Do(func(ctx context.Context, cli *client.Client) (err error) {
		opts := types.ImageRemoveOptions{}
		_, err = cli.ImageRemove(ctx, id, opts)
		return
	})
}