read the Image Layer Data
@ignore
321937
function readImageLayer(map, data, z) {
        // Normalize properties
        me.TMXUtils.applyTMXProperties(data.properties, data);

        // create the layer
        var imageLayer = me.pool.pull("me.ImageLayer",
            // x/y is deprecated since 0.15 and replace by offsetx/y
            +data.offsetx || +data.x || 0,
            +data.offsety || +data.y || 0,
            Object.assign({
                name: data.name,
                image: data.image,
                z: z
            }, data.properties)
        );

        // set some additional flags
        var visible = typeof(data.visible) !== "undefined" ? data.visible : true;
        imageLayer.setOpacity(visible ? +data.opacity : 0);

        return imageLayer;
    }
253909
function layerContainsImage (layer, imageUrl) {
  // Check the layer itself.
  if (layer.type === 'image' && layer.imageUrl === imageUrl) {
    return layer;
  }

  // Check the layer's children.
  if (layer.children) {
    for (var i=0, len=layer.children.length; i < len; i++) {
      if (layerContainsImage(layer.children[i], imageUrl)) {
        return layer.children[i];
      }
    }
  }

  return false;
}
853109
function readData(fp, options) {
  // shallow clone options
  var opts = utils.extend({}, options);
  // get the loader for this file.
  var ext = opts.lang || path.extname(fp);
  if (ext && ext.charAt(0) !== '.') {
    ext = '.' + ext;
  }
  if (!this.dataLoaders.hasOwnProperty(ext)) {
    return this.dataLoader('read')(fp, opts);
  }
  return this.dataLoader(ext)(fp, opts);
}
352976
public function readData(DataContainer $data)
    {
        $this->size = $data->getInteger('s', self::DEFAULT_SIZE);
        $this->renderedSize = $data->getInteger('r', self::DEFAULT_SIZE);
        $this->layers = array_map(function (DataContainer $data): Layer {
            return (new Layer())->readData($data);
        }, $data->getObjectArray('l'));
        return $this;
    }
803242
private void readChunkIfNeeded() {
        if (workBufferSize > workBufferPosition) {
            return;
        }
        if (workBuffer == null) {
            workBuffer = bitmapProvider.obtainByteArray(WORK_BUFFER_SIZE);
        }
        workBufferPosition = 0;
        workBufferSize = Math.min(rawData.remaining(), WORK_BUFFER_SIZE);
        rawData.get(workBuffer, 0, workBufferSize);
    }
547309
function imageToImageData ( image ) {
	if ( image instanceof HTMLImageElement ) {
		// http://stackoverflow.com/a/3016076/229189
		if ( ! image.naturalWidth || ! image.naturalHeight || image.complete === false ) {
			throw new Error( "This this image hasn't finished loading: " + image.src );
		}

		const canvas = new Canvas( image.naturalWidth, image.naturalHeight );
		const ctx = canvas.getContext( '2d' );
		
		ctx.drawImage( image, 0, 0, canvas.width, canvas.height );

		const imageData = ctx.getImageData( 0, 0, canvas.width, canvas.height );

		if ( imageData.data && imageData.data.length ) {
			if ( typeof imageData.width === 'undefined' ) {
				imageData.width = image.naturalWidth;
			}

			if ( typeof imageData.height === 'undefined' ) {
				imageData.height = image.naturalHeight;
			}
		}
		
		return imageData;
	} else {
		throw new Error( 'This object does not seem to be an image.' );
		return;
	}
}
1315626
def _read_color_image(self):
        
        # read raw buffer
        im_arr = self._color_stream.read_frame()
        raw_buf = im_arr.get_buffer_as_triplet()
        r_array = np.array([raw_buf[i][0] for i in range(PrimesenseSensor.COLOR_IM_WIDTH * PrimesenseSensor.COLOR_IM_HEIGHT)])        
        g_array = np.array([raw_buf[i][1] for i in range(PrimesenseSensor.COLOR_IM_WIDTH * PrimesenseSensor.COLOR_IM_HEIGHT)])        
        b_array = np.array([raw_buf[i][2] for i in range(PrimesenseSensor.COLOR_IM_WIDTH * PrimesenseSensor.COLOR_IM_HEIGHT)])        

        # convert to uint8 image
        color_image = np.zeros([PrimesenseSensor.COLOR_IM_HEIGHT, PrimesenseSensor.COLOR_IM_WIDTH, 3])
        color_image[:,:,0] = r_array.reshape(PrimesenseSensor.COLOR_IM_HEIGHT,
                                             PrimesenseSensor.COLOR_IM_WIDTH)
        color_image[:,:,1] = g_array.reshape(PrimesenseSensor.COLOR_IM_HEIGHT,
                                             PrimesenseSensor.COLOR_IM_WIDTH)
        color_image[:,:,2] = b_array.reshape(PrimesenseSensor.COLOR_IM_HEIGHT,
                                             PrimesenseSensor.COLOR_IM_WIDTH)
        if self._flip_images:
            color_image = np.flipud(color_image.astype(np.uint8))
        else:
            color_image = np.fliplr(color_image.astype(np.uint8))
        return ColorImage(color_image, frame=self._frame)
1119645
def _read_image_data( mhd_file):
    
    tempdir = get_tempdir()
    
    # Load description from mhd file
    fname = tempdir + '/' + mhd_file
    des = open(fname, 'r').read()
    
    # Get data filename and load raw data
    match = re.findall('ElementDataFile = (.+?)\n', des)
    fname = tempdir + '/' + match[0]
    data = open(fname, 'rb').read()
    
    # Determine dtype
    match = re.findall('ElementType = (.+?)\n', des)
    dtype_itk = match[0].upper().strip()
    dtype = DTYPE_ITK2NP.get(dtype_itk, None)
    if dtype is None:
        raise RuntimeError('Unknown ElementType: ' + dtype_itk)
    
    # Create numpy array
    a = np.frombuffer(data, dtype=dtype)
    
    # Determine shape, sampling and origin of the data
    match = re.findall('DimSize = (.+?)\n', des)
    shape = [int(i) for i in match[0].split(' ')]
    #
    match = re.findall('ElementSpacing = (.+?)\n', des)
    sampling = [float(i) for i in match[0].split(' ')]
    #
    match = re.findall('Offset = (.+?)\n', des)
    origin = [float(i) for i in match[0].split(' ')]
    
    # Reverse shape stuff to make z-y-x order
    shape = [s for s in reversed(shape)]
    sampling = [s for s in reversed(sampling)]
    origin = [s for s in reversed(origin)]
    
    # Take vectors/colours into account
    N = np.prod(shape)
    if N != a.size:
        extraDim = int( a.size / N )
        shape = tuple(shape) + (extraDim,)
        sampling = tuple(sampling) + (1.0,)
        origin = tuple(origin) + (0,)
    
    # Check shape
    N = np.prod(shape)
    if N != a.size:
        raise RuntimeError('Cannot apply shape to data.')
    else:
        a.shape = shape
        a = Image(a)
        a.sampling = sampling
        a.origin = origin
    return a
506331
public function parseImageInfo() 
    {
    	if (null === $this->sourceImagePath) {
    		throw new NoSourceException();
    	}
    	
    	$pathinfo = pathinfo($this->sourceImagePath);
    	if (!is_array($pathinfo)) {
    		throw new \RuntimeException("It is not possible to correctly get pathinfo for the image file '" . $this->sourceImagePath . "' ");
    	}
        
        $imagesize = getimagesize($this->sourceImagePath);
        if (!is_array($imagesize)) {
            throw new \RuntimeException("It is not possible to correctly get imagesize for the image file '" . $this->sourceImagePath . "' ");
        }
    	
    	$info = $pathinfo + $imagesize;
        
        if (isset($info[0])) {
            $info['width'] = $info[0];
        } else {
            throw new \RuntimeException("Unable to get width for the image file '" . $this->sourceImagePath . "' ");
        }
        
        if (isset($info[1])) {
            $info['height'] = $info[1];
        } else {
            throw new \RuntimeException("Unable to get height for the image file '" . $this->sourceImagePath . "' ");
        }
        
        if (!isset($info['mime'])) {
            throw new \RuntimeException("Unable to get mimetype for the image file '" . $this->sourceImagePath . "' ");
        }

        unset($info[0], $info[1], $info[2], $info[3]);
        
        switch(strtolower($info['mime'])) {
		case 'image/png':
			$info['extension'] = 'png';
            break;
            
		case 'image/jpeg':
			$info['extension'] = 'jpg';
            break;
            
		case 'image/gif':
			$info['extension'] = 'gif';
            break;
            
		default:
			throw new \RuntimeException("Unable to get extension for the image file '" . $this->sourceImagePath . "' ");
            break;
        }
    	
        // We set the default width/height values for the destination image if resize is not called
        $this->destImageWidth = $info['width'];
        $this->destImageHeight = $info['height'];
        
        $this->setExtension($info['extension']);
        $this->imageInfo = $info;
        
    	return $this;
    }
816024
function getImageData(img) {
  let data = null;
  return new Promise((reslove, reject) => {
    if (img.src) {
      if (/^data\:/i.test(img.src)) { // Data URI
        data = base64ToArrayBuffer(img.src);
        reslove(data)
      } else if (/^blob\:/i.test(img.src)) { // Object URL
        var fileReader = new FileReader();
        fileReader.onload = function (e) {
          data = e.target.result;
          reslove(data)
        };
        objectURLToBlob(img.src, function (blob) {
          fileReader.readAsArrayBuffer(blob);
        });
      } else {
        var http = new XMLHttpRequest();
        http.onload = function () {
          if (this.status == 200 || this.status === 0) {
            data = http.response
            reslove(data)
          } else {
            throw "Could not load image";
          }
          http = null;
        };
        http.open("GET", img.src, true);
        http.responseType = "arraybuffer";
        http.send(null);
      }
    } else {
      reject('img error')
    }
  })
}
552835
public function readMap()
    {
        $fileData = include $this->file;
        $this->map = !is_array($fileData) ? $this->map : $fileData;
    }
98254
def _read(self):
        """"""
        _, data_img_name, label_img_name = self.f.readline().strip('\n').split("\t")
        data = {}
        label = {}
        data[self.data_name], label[self.label_name] = self._read_img(data_img_name, label_img_name)
        return list(data.items()), list(label.items())
235442
public void readImage() {
    if (ifd.containsTagId(TiffTags.getTagId("StripOffsets"))
        || ifd.containsTagId(TiffTags.getTagId("StripBYTECount"))) {
      readStrips();
    }
    if (ifd.containsTagId(TiffTags.getTagId("TileOffsets"))
        || ifd.containsTagId(TiffTags.getTagId("TileBYTECounts"))) {
      readTiles();
    }
  }
506326
function(file, $canvas, callback) {
            this.newImage();
            if (!file)
                return;

            var reader = new FileReader();
            reader.onload = function (fileReaderEvent) {
                image.onload = function () { readImageToCanvasOnLoad(this, $canvas, callback); };
                image.src = fileReaderEvent.target.result;      // The URL from FileReader

            };
            reader.readAsDataURL(file);
        }
417195
def _read_layers(self, layers, image_id):
        

        for layer in self.docker.history(image_id):
            layers.append(layer['Id'])
60827
private Dimension getImageDimension() {
    Dimension dimension = null;

    // check for cropping dimension
    if (this.media.getCropDimension() != null) {
      dimension = this.media.getCropDimension();
    }
    else {
      // if binary is image try to calculcate dimensions by loading it into a layer
      Layer layer = this.resource.adaptTo(Layer.class);
      if (layer != null) {
        dimension = new Dimension(layer.getWidth(), layer.getHeight());
      }
    }

    return dimension;
  }
154135
public static void readPixels(DataInput in, float[] data, int numpixels) throws IOException {
        byte[] rgbe = new byte[4];
        float[] rgb = new float[3];
        int offset = 0;

        while (numpixels-- > 0) {
            in.readFully(rgbe);

            rgbe2float(rgb, rgbe, 0);

            data[offset++] = rgb[0];
            data[offset++] = rgb[1];
            data[offset++] = rgb[2];
        }
    }