Tabnine Logo For Javascript
image-type
Code IndexAdd Tabnine to your IDE (free)

How to use image-type

Best JavaScript code snippets using image-type(Showing top 2 results out of 315)

origin: lehoangduc/face-recognition-api

/**
  * Validate image
  *
  * @param path
  * @returns Error|true
  */
 validateImage(path) {
  let buffer = readChunk.sync(path, 0, 12);
  let type = imageType(buffer);

  return new Promise((resolve, reject) => {
   if (this.validExtensions.indexOf(type.ext) === -1) {
    return reject(new Error(this.errors.url_image_invalid));
   }

   resolve(type.ext);
  });
 }
origin: image-js/image-js

function loadBinary(image, base64Url) {
 const type = imageType(image);
 if (type) {
  switch (type.mime) {
   case 'image/png':
    return loadPNG(image);
   case 'image/jpeg':
    return loadJPEG(image);
   case 'image/tiff':
    return loadTIFF(image);
   default:
    return loadGeneric(getBase64(type.mime));
  }
 }
 return loadGeneric(getBase64('application/octet-stream'));
 function getBase64(type) {
  if (base64Url) {
   return base64Url;
  } else {
   return toBase64URL(image, type);
  }
 }
}
image-type(npm)

Most used image-type functions

  • imageType
  • ImageTypeResult.mime

Popular in JavaScript

  • lodash
    Lodash modular utilities.
  • mocha
    simple, flexible, fun test framework
  • ms
    Tiny millisecond conversion utility
  • path
  • rimraf
    A deep deletion module for node (like `rm -rf`)
  • redis
    Redis client library
  • minimist
    parse argument options
  • minimatch
    a glob matcher in javascript
  • cheerio
    Tiny, fast, and elegant implementation of core jQuery designed specifically for the server
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now