How to use the image-js function in image-js

To help you get started, we’ve selected a few image-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rai-project / mlmodelscope / src / components / InferenceResult / ReadRawImageResults.js View on Github external
function read_rawimage_results(features) {
  // ignore data for now and use results
  // const compressed_data = results.responses[0].features[0].raw_image.compressed_data;
  const compressed_data = features[0].raw_image.compressed_data;
  const binary_compressed_data = base64ToUint8Array(compressed_data);
  const jsonBuf = snappyjs.uncompress(binary_compressed_data);

  var enc = new TextDecoder("utf-8");
  const json = enc.decode(jsonBuf);

  var imagedata = JSON.parse(json);
  var width = results.responses[0].features[0].raw_image.width
  var height = results.responses[0].features[0].raw_image.height
  var img = new Image(width, height, imagedata, {kind: "RGB"})
  var rgbaimg = img.rgba8();
  return rgbaimg.toDataURL();
}
github rai-project / mlmodelscope / src / components / InferenceResult / InstanceSegmentationResult.js View on Github external
render() {
    this.convertFloatMaskToImage();
    var img = new Imagejs(this.instanceWidth, this.instanceHeight, this.maskImage, {kind: "RGB"})
    var rgbaimg = img.rgba8();
    var image = new window.Image();
    image.src = rgbaimg.toDataURL();
    console.log(rgbaimg.toDataURL());
    var x1 = Math.round(this.props.instance_segment.xmin * this.imageWidth);
    var x2 = Math.round(this.props.instance_segment.xmax * this.imageWidth);
    var y1 = Math.round(this.props.instance_segment.ymin * this.imageHeight);
    var y2 = Math.round(this.props.instance_segment.ymax * this.imageHeight);
    return(
github rai-project / mlmodelscope / src / components / InferenceResult / SemanticSegmentationResult.js View on Github external
render() {
    this.convertIntMaskToImage();
    var img = new Imagejs(this.width, this.height, this.maskImage, {kind: "RGB"})
    var rgbaimg = img.rgba8();
    var image = new window.Image();
    image.src = rgbaimg.toDataURL();
    return(
      <img height="{this.props.height}" width="{this.props.width}" y="{0}" x="{0}">
    )
  }
}

image-js

Image processing and manipulation in JavaScript

MIT
Latest version published 4 months ago

Package Health Score

76 / 100
Full package analysis