Retrieve the binary image data for a given Image object

 @param [Image] image An Image model object from the Instagram service

 @raise [Exception] If there are request problems

 @return [String] Binary image data
357327
def harvest_image_data(image)
      response = Typhoeus.get(image.large_url(false), followlocation: true)

      if response.success?
        raise "Invalid content type: " + response.headers['Content-Type'] unless (response.headers['Content-Type'] == 'image/jpeg')
      elsif response.timed_out?
        raise "Request timed out"
      elsif response.code == 0
        raise "Could not get an HTTP response"
      else
        raise "HTTP request failed: " + response.code.to_s
      end

      response.body
    end
120112
def get_thumbnail_image(self, page=1):
        
        url = self.get_thumbnail_image_url(page=page)
        return self._get_url(url)
1183602
def get_image(verbose=False):
  """"""
  base_data = tf.constant(image_data(verbose=verbose))
  base_image = tf.image.decode_image(base_data, channels=3)
  base_image.set_shape((IMAGE_HEIGHT, IMAGE_WIDTH, 3))
  parsed_image = tf.Variable(base_image, name='image', dtype=tf.uint8)
  return parsed_image
177192
def convert(key, block = nil)
      if block.nil? or block.call(key)
        img_tag(key)
      else
        ":#{key}:"
      end
    end
1095211
def extract_image_data(instagram_metadata)
      {
        url: instagram_metadata.link,
        external_id: instagram_metadata.id,
        large_url: instagram_metadata.images.standard_resolution.url,
        name: instagram_metadata.caption && instagram_metadata.caption.text,
        tags: instagram_metadata.tags,
        user: instagram_metadata.user,
        original_datetime: Time.at(instagram_metadata.created_time.to_i).to_datetime,
        original_metadata: instagram_metadata,
        media_type: instagram_metadata.type,
        video_url: instagram_metadata.videos && instagram_metadata.videos.standard_resolution.url
      }
    end
1319360
def locate(self, image):
        
        from .entity import Image
        if not isinstance(image, Image):
            raise TypeError('image must be a sqlalchemy_imageattach.entity.'
                            'Image instance, not ' + repr(image))
        url = self.get_url(image.object_type, image.object_id,
                           image.width, image.height, image.mimetype)
        if '?' in url:
            fmt = '{0}&_ts={1}'
        else:
            fmt = '{0}?_ts={1}'
        return fmt.format(url, image.created_at.strftime('%Y%m%d%H%M%S%f'))
841791
def image(self, s=0, c=0, z=0, t=0):
        
        return self.proxy_image(s=s, c=c, z=z, t=t).image
1282062
def image(self, image):
        
        if image.mode != '1':
            raise ValueError('Image must be in mode 1.')
        imwidth, imheight = image.size
        if imwidth != self.width or imheight != self.height:
            raise ValueError('Image must be same dimensions as display ({0}x{1}).' \
                .format(self.width, self.height))
        print("bitmap display: image")
        image.save("dummydisplay.bmp")
644370
def inspect_image(self, image_id):
        
        logger.info("inspecting image '%s'", image_id)
        logger.debug("image_id = '%s'", image_id)
        if isinstance(image_id, ImageName):
            image_id = image_id.to_str()
        image_metadata = self.d.inspect_image(image_id)
        return image_metadata
793974
def get_img_data(f, maxsize = (1200, 850), first = False):
    
    img = Image.open(f)
    img.thumbnail(maxsize)
    if first:                     # tkinter is inactive the first time
        bio = io.BytesIO()
        img.save(bio, format = "PNG")
        del img
        return bio.getvalue()
    return ImageTk.PhotoImage(img)
1156170
def parse(cls, image_name):
        
        result = cls()

        # registry.org/namespace/repo:tag
        s = image_name.split('/', 2)

        if len(s) == 2:
            if '.' in s[0] or ':' in s[0]:
                result.registry = s[0]
            else:
                result.namespace = s[0]
        elif len(s) == 3:
            result.registry = s[0]
            result.namespace = s[1]
        result.repository = s[-1]

        try:
            result.repository, result.digest = result.repository.rsplit("@", 1)
        except ValueError:
            try:
                result.repository, result.tag = result.repository.rsplit(":", 1)
            except ValueError:
                result.tag = "latest"

        return result
84628
def get_image_hash(image):
    '''
    
    '''
    md5 = hashlib.md5()
    try:
        for chunk in image.file.chunks():
            md5.update(chunk)
        return md5.hexdigest()
    # this should only occur in tests
    except ValueError:
        # see link below for why we try not to use .open()
        # https://docs.djangoproject.com/en/1.9/ref/files/uploads/#django.core.files.uploadedfile.UploadedFile.chunks  # noqa
        image.file.open()

        for chunk in image.file.chunks():
            md5.update(chunk)
        return md5.hexdigest()
    finally:
        image.file.close()
1279739
def avatar=(avatar)
      if avatar.respond_to? :read
        # Set the file to binary mode if supported, so we don't get problems with Windows
        avatar.binmode if avatar.respond_to?(:binmode)

        avatar_string = 'data:image/jpg;base64,'
        avatar_string += Base64.strict_encode64(avatar.read)
        update_profile_data(avatar: avatar_string)
      else
        update_profile_data(avatar: avatar)
      end
    end
247123
def open_image(fname_or_instance: Union[str, IO[bytes]]):
    
    if isinstance(fname_or_instance, Image.Image):
        return fname_or_instance

    return Image.open(fname_or_instance)
1134152
def get_images(img_type)
      images = Hash.new

      if img_type == "OSImage"
        response = @connection.query_azure("images")
      elsif img_type == "VMImage"
        response = @connection.query_azure("vmimages")
      end

      unless response.to_s.empty?
        osimages = response.css(img_type)

        osimages.each do |image|
          item = Image.new(image)
          images[item.name] = item
        end
      end

      images
    end
328344
private static Raster getRaster(final RenderedImage image) {
        return image instanceof BufferedImage
               ? ((BufferedImage) image).getRaster()
               : image.getNumXTiles() == 1 && image.getNumYTiles() == 1
                 ? image.getTile(0, 0)
                 : image.getData();
    }
1048254
def process(image)
      raise ArgumentError, "process() operates only on ZBar::Image objects" unless image.kind_of?(ZBar::Image)
      image = image.instance_variable_get(:@img)
  
      if ZBar.zbar_process_image(@processor, image) != 0
        raise ArgumentError, "processing failed"
      end
  
      out = []
  
      sym = ZBar.zbar_image_first_symbol(image)
      until sym.null?
        out << Symbol.new(sym)
        sym = ZBar.zbar_symbol_next(sym)
      end
  
      out
    end