getheaderAnim(im)

        Get animation header. To replace PILs getheader()[0]
169216
def getheaderAnim(self, im):
        
        bb = b'GIF89a'
        bb += intToBin(im.size[0])
        bb += intToBin(im.size[1])
        bb += b'\x87\x00\x00'
        return bb
728077
def imdecode(self, s):
        """"""
        def locate():
            """Locate the image file/index if decode fails."""
            if self.seq is not None:
                idx = self.seq[(self.cur % self.num_image) - 1]
            else:
                idx = (self.cur % self.num_image) - 1
            if self.imglist is not None:
                _, fname = self.imglist[idx]
                msg = "filename: {}".format(fname)
            else:
                msg = "index: {}".format(idx)
            return "Broken image " + msg
        try:
            img = imdecode(s)
        except Exception as e:
            raise RuntimeError("{}, {}".format(locate(), e))
        return img
373334
def get_header(self, hdrclass, returnval=None):
        '''
        
        '''
        if isinstance(hdrclass, str):
            return self.get_header_by_name(hdrclass)

        for hdr in self._headers:
            if isinstance(hdr, hdrclass):
                return hdr
        return returnval
393829
def readGif(filename, asNumpy=True):
    

    # Check PIL
    if PIL is None:
        raise RuntimeError("Need PIL to read animated gif files.")

    # Check Numpy
    if np is None:
        raise RuntimeError("Need Numpy to read animated gif files.")

    # Check whether it exists
    if not os.path.isfile(filename):
        raise IOError('File not found: ' + str(filename))

    # Load file using PIL
    pilIm = PIL.Image.open(filename)
    pilIm.seek(0)

    # Read all images inside
    images = []
    try:
        while True:
            # Get image as numpy array
            tmp = pilIm.convert()  # Make without palette
            a = np.asarray(tmp)
            if len(a.shape) == 0:
                raise MemoryError("Too little memory to convert PIL image to array")
            # Store, and next
            images.append(a)
            pilIm.seek(pilIm.tell() + 1)
    except EOFError:
        pass

    # Convert to normal PIL images if needed
    if not asNumpy:
        images2 = images
        images = []
        for im in images2:
            images.append(PIL.Image.fromarray(im))

    # Done
    return images
559017
def as_PIL(self):
        
        if isinstance(self.data, numpy.ndarray):
            if self.data.dtype == numpy.uint8:
                result = PIL.Image.fromarray(self.data)
            else:
                result = PIL.Image.fromarray(
                    self.data.clip(0, 255).astype(numpy.uint8))
        elif isinstance(self.data, PIL.Image.Image):
            result = self.data
        else:
            raise RuntimeError(
                'Cannot convert "%s" to PIL' % self.data.__class__.__name__)
        return result
1079124
def __get_img(self):
        
        with self.fs.open(self.__img_path, 'rb') as fd:
            img = PIL.Image.open(fd)
            img.load()
            return img
1196867
def getHeader(self,exten=None):
        
        _image=fileutil.openImage(self._filename, clobber=False, memmap=False)
        _header=fileutil.getExtn(_image,extn=exten).header
        _image.close()
        del _image
        return _header
812213
def header(self):
        

        if self._header_encoding is None:
            return self._header
        else:
            return self._header.decode(self._header_encoding)
1135754
def _convert_image(self, im):
        
        pixels   = []
        pix_line = ""
        im_left  = ""
        im_right = ""
        switch   = 0
        img_size = [ 0, 0 ]


        if im.size[0] > 512:
            print  "WARNING: Image is wider than 512 and could be truncated at print time "
        if im.size[1] > 255:
            raise ImageSizeError()

        im_border = self._check_image_size(im.size[0])
        for i in range(im_border[0]):
            im_left += "0"
        for i in range(im_border[1]):
            im_right += "0"

        for y in range(im.size[1]):
            img_size[1] += 1
            pix_line += im_left
            img_size[0] += im_border[0]
            for x in range(im.size[0]):
                img_size[0] += 1
                RGB = im.getpixel((x, y))
                im_color = (RGB[0] + RGB[1] + RGB[2])
                im_pattern = "1X0"
                pattern_len = len(im_pattern)
                switch = (switch - 1 ) * (-1)
                for x in range(pattern_len):
                    if im_color <= (255 * 3 / pattern_len * (x+1)):
                        if im_pattern[x] == "X":
                            pix_line += "%d" % switch
                        else:
                            pix_line += im_pattern[x]
                        break
                    elif im_color > (255 * 3 / pattern_len * pattern_len) and im_color <= (255 * 3):
                        pix_line += im_pattern[-1]
                        break 
            pix_line += im_right
            img_size[0] += im_border[1]

        return (pix_line, img_size)
311894
def get_header_index(self, hdrclass, startidx=0):
        '''
        
        '''
        for hdridx in range(startidx, len(self._headers)):
            if isinstance(self._headers[hdridx], hdrclass):
                return hdridx
        return -1
1187731
private Rectangle getPICTFrame() throws IOException {
        if (frame == null) {
            // Read in header information
            readPICTHeader(imageInput);

            if (DEBUG) {
                System.out.println("Done reading PICT header!");
            }
        }

        return frame;
    }
1325807
def get_astheader(expnum, ccd, version='p', prefix=None):
    
    logger.debug("Getting ast header for {}".format(expnum))
    if version == 'p':
        try:
            # Get the SG header if possible.
            sg_key = "{}{}".format(expnum, version)
            if sg_key not in sgheaders:
                _get_sghead(expnum)
            if sg_key in sgheaders:
                for header in sgheaders[sg_key]:
                        if header.get('EXTVER', -1) == int(ccd):
                            return header
        except:
            pass

    try:
       ast_uri = dbimages_uri(expnum, ccd, version=version, ext='.fits')
       if ast_uri not in astheaders:
           hdulist = get_image(expnum, ccd=ccd, version=version, prefix=prefix,
                               cutout="[1:1,1:1]", return_file=False, ext='.fits')
           assert isinstance(hdulist, fits.HDUList)
           astheaders[ast_uri] = hdulist[0].header
    except:
       ast_uri = dbimages_uri(expnum, ccd, version=version, ext='.fits.fz')
       if ast_uri not in astheaders:
           hdulist = get_image(expnum, ccd=ccd, version=version, prefix=prefix,
                               cutout="[1:1,1:1]", return_file=False, ext='.fits.fz')
           assert isinstance(hdulist, fits.HDUList)
           astheaders[ast_uri] = hdulist[0].header
    return astheaders[ast_uri]
1005235
def get_header_description(filedata):
    """"""
    python_version = sys.version_info.major
    if python_version == 3:
        filedata = Parser().parsestr(filedata)
    else:
        filedata = Parser().parsestr(filedata.encode("UTF-8", "replace"))

    payload = filedata.get_payload()
    lines = payload.split('\n')
    while True:
        if lines and lines[-1] == '':
            lines.pop()
        else:
            break
    return '\n'.join(lines)
1262298
def get_header_anim(self, im):
        
        bb = "GIF89a"
        bb += int_to_bin(im.size[0])
        bb += int_to_bin(im.size[1])
        bb += "\x87\x00\x00"
        return bb
551200
async def get_image(
        self,
        input_source: str,
        output_format: str = IMAGE_JPEG,
        extra_cmd: Optional[str] = None,
        timeout: int = 15,
    ) -> Optional[bytes]:
        """"""
        command = ["-an", "-frames:v", "1", "-c:v", output_format]

        # open input for capture 1 frame
        is_open = await self.open(
            cmd=command,
            input_source=input_source,
            output="-f image2pipe -",
            extra_cmd=extra_cmd,
        )

        # error after open?
        if not is_open:
            _LOGGER.warning("Error starting FFmpeg.")
            return None

        # read image
        try:
            proc_func = functools.partial(self._proc.communicate, timeout=timeout)
            image, _ = await self._loop.run_in_executor(None, proc_func)
            return image

        except (subprocess.TimeoutExpired, ValueError):
            _LOGGER.warning("Timeout reading image.")
            self.kill()
            return None
738832
def get_header(self, name, default=None):
        '''  '''
        return self._headers.get(_hkey(name), [default])[-1]
641566
def get_image(self, cat, img):
        
        filename = self.path(cat, img)
        data = []
        if filename.endswith('mat'):
            data = loadmat(filename)['output']
        else:
            data = imread(filename)
        if self.size is not None:
            return imresize(data, self.size)
        else:
            return data