/*

@description Load any kind of image
@param file: object
180348
function(file) {
      var defer = new $.Deferred(),
        size = file.size,
        $image = $('<img>'),
        onImageLoaded = function() {

          log('File Loaded:' + src);
          _bytesLoaded += size;
          onElementLoaded(file, this);
          // removing the file from the array
          _files[_currentSegment].splice(0, 1);
          updatePercentage();
          defer.resolve();

        },
        onImageError = function() {
          log('File load error : ' + src);
          _bytesLoaded += size;
          // removing the file from the array
          _files[_currentSegment].splice(0, 1);
          updatePercentage();
          defer.resolve();
        },
        src;

      // load the svg or the fallback image
      if (file.source.toString() === '[object Object]') {
        if (file.source.svg && _support.svg) {
          src = file.source.svg;
        } else if (file.source.fallback) {
          src = file.source.fallback;
        }
      } else {
        src = file.source;
      }

      $image.on('load', onImageLoaded);
      $image.on('error', onImageError);
      $image.attr('src', src);

      // preventing a memory leak
      $image = null;

      return defer.promise();
    }
211578
function loadBinary (file, callback) {
  if (isPlask) {
    loadBinaryPlask(file, callback)
  } else {
    loadBinaryBrowser(file, callback)
  }
}
192786
function(file) {
        this.number++;

        var resource;
        var adapter = this.adapter;
        var resourceCache = adapter.resourceCache;
        var that = this;

        // ignore > map > normalize
        if (adapter.resourceIgnore(file)) {
            return Promise.resolve('');
        }
        file = adapter.resourceMap(file);
        file = this.normalize(file);

        if (this.number > this.adapter.resourceMaxNumber) {
            var errors = new Error('Exceed the maximum load limit on the number of resources');
            errors = new Resource.Error(errors, file);
            return Promise.reject(errors);
        }

        adapter.resourceBeforeLoad(file);

        if (resourceCache && this.cache[file]) {
            resource = this.cache[file];
            if (resource) {
                return resource;
            }
        }


        resource = new Promise(function(resolve, reject) {

            if (that.isRemoteFile(file)) {
                that.loadRemoteFile(file, onload);
            } else {
                that.loadLocalFile(file, onload);
            }

            function onload(errors, data) {
                if (errors) {
                    errors = new Resource.Error(errors, file);
                    reject(errors);
                } else {
                    resolve(data.toString());
                }
            }

        });


        if (resourceCache) {
            this.cache[file] = resource;
        }

        return resource;
    }
433475
def load(file):
    
    with open(file, 'r') as f:
        contents = f.read()
    lambder.load_events(contents)
579307
function (file) {
    this.src = file.src || {};
    if (this.path) {
      this.src.path = this.path;
    }
    if (Buffer.isBuffer(this.contents)) {
      this.content = this.contents.toString();
    }
    if (this.content) {
      this.options.orig = this.content;
    }

    // ensure that `file` has `path` and `content` properties
    this.validate(file);

    this.options.orig = file.content;
    this.options.plural = this.collection.options.plural;
    this.options.handled = this.options.handled = [];

    this.src = file.src || {};
    this.src.path = this.src.path || this.path;

    // add non-emumerable properties
    this.defineOption('route', this.options.route);
    this.define('_callbacks', this._callbacks);
    file.__proto__ = this;
    file.path = this.path;

    // handle `onLoad` middleware routes
    this.app.handle('onLoad', file);
  }
948036
public function load($file)
    {
        $loader = new PhpConfig();
        $templates = $loader->read($file);
        $this->add($templates);
    }
494665
function loadFile(file) {
    console.log('loadFile:', file);

    // <file> can be Image, File URL object or URL string (http://* or data:image/*)
    rasterToGcode.load(file).then(function(rtg) {
        console.log('rasterToGcode:', rtg);
    })
    .catch(function(error) {
        console.error('error:', error);
    });
}
1269911
public static Properties load(File file) throws IOException {
		FileInputStream input = new FileInputStream(file);
		Properties properties = null;
		try {
			properties = load(input);
		} finally {
			IOUtils.close(input);
		}
		return properties;
	}
1238362
function loadFile(file, db, callback) { 
    callback = callback || function() {};
    
    if (file.substr(0, 1) !== '/') {
        var parentPath = module.parent.filename.split('/');
        parentPath.pop();
        file = parentPath.join('/') + '/' + file;
    }
    
    load(require(file), db, callback);
}
277923
public function loadImageDetails($file = null)
    {
        $file = $file ? $file : $this->pathToImage;

        is_readable($file)
            or $this->raiseError('Image file does not exist.');

        $info = list($this->width, $this->height, $this->fileType) = getimagesize($file);
        if (empty($info)) {
            // To support webp
            $this->fileType = false;
            if (function_exists("exif_imagetype")) {
                $this->fileType = exif_imagetype($file);
                if ($this->fileType === false) {
                    if (function_exists("imagecreatefromwebp")) {
                        $webp = imagecreatefromwebp($file);
                        if ($webp !== false) {
                            $this->width  = imagesx($webp);
                            $this->height = imagesy($webp);
                            $this->fileType = IMG_WEBP;
                        }
                    }
                }
            }
        }

        if (!$this->fileType) {
            throw new Exception("Loading image details, the file doesn't seem to be a valid image.");
        }

        if ($this->verbose) {
            $this->log("Loading image details for: {$file}");
            $this->log(" Image width x height (type): {$this->width} x {$this->height} ({$this->fileType}).");
            $this->log(" Image filesize: " . filesize($file) . " bytes.");
            $this->log(" Image mimetype: " . $this->getMimeType());
        }

        return $this;
    }
355005
protected function loadInstanceFromFile($file) {
        if(file_exists($file)) {
            $arguments = $this->getConfiguration() [ AbstractFileConfiguration::SERVICE_INIT_ARGUMENTS ] ?? NULL;

            $object = _context_less_require($file, $arguments, $this->serviceManager);
            if(is_object($object)) {
                $this->instance = $object;
                if(method_exists($object, 'setConfiguration') && ($cfg = $this->getConfiguration()[AbstractFileConfiguration::SERVICE_INIT_CONFIGURATION] ?? NULL))
                    $object->setConfiguration($cfg);
            }
            else {
                $e= new InvalidServiceException("Executation of file $file did not return an object");
                $e->setServiceName($this->serviceName);
                $e->setServiceObject($object);
                throw $e;
            }
        } else {
            $e = new FileNotFoundException("File $file does not exist");
            $e->setServiceName($this->serviceName);
            $e->setFilename($file);
            throw $e;
        }
    }
375521
public static Properties load(File file) throws IOException {
        if (file.isFile()) {
            return load(file.toURI().toURL());
        }
        return new Properties();
    }
503649
function exif (file) {
    "use strict";    
    var deferred = Q.defer(), o = {};
    
    new ExifImage({ image : file }, function (error, data) {
      if (error) 
         {
         // callback.call("error " + file);
         deferred.reject("ERROR");     
         }
      if (data)
        {
        o.file = file;
        o.data = data;    
        deferred.resolve(o); 
        }
    });
    
    return deferred.promise;
    }
960114
function (file) {
        if (!this.ignore(file)) {
            file = this.map(file);
            file = utils.normalize(file);
            return file;
        }
    }
1303412
def load(cls, file):
        
        d = json.load(file)
        return cls.create(d)
569611
public void loadTagMappingFile(String file) {
        if (file != null) {
            File f = new File(file);
            if (!f.exists()) {
                throw new IllegalArgumentException("tag mapping file parameter points to a file that does not exist");
            }
            if (f.isDirectory()) {
                throw new IllegalArgumentException("tag mapping file parameter points to a directory, must be a file");
            } else if (!f.canRead()) {
                throw new IllegalArgumentException(
                        "tag mapping file parameter points to a file we have no read permissions");
            }

            try {
                this.tagMapping = f.toURI().toURL();
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
            }
        } else {
            this.tagMapping = PoiWriterTask.class.getClassLoader().getResource("poi-mapping.xml");
        }
    }
992065
public void openFile(File file) {
		final String path = massageFilePath(file);
		if( path == null )
			return;
		inputFilePath = path;

		// update recent items menu
		BoofSwingUtil.invokeNowOrLater(() -> {
			BoofSwingUtil.addToRecentFiles(DemonstrationBase.this,path);
			updateRecentItems();
		});

		BufferedImage buffered = inputFilePath.endsWith("mjpeg") ? null : UtilImageIO.loadImage(inputFilePath);
		if( buffered == null ) {
			if( allowVideos )
				openVideo(false,inputFilePath);
		} else if( allowImages ){
			openImage(false,file.getName(), buffered);
		}
	}