Saturday 29 October 2022

fabricjs how to see if object src is raster or vectorized

I am creating a function, that, if the object image source is vectorized I will make it larger by scaling it up. But if the image is raster I will use a machine learning model "super resolution" to scale it up.

Currently in the code below I am using toDataURL to return a rasterized version of the image every time, however, to achieve the goal above, I would like to know how to first identify the "type" of the object src, if it is raster or vectorized.

const stringifiedObjectJson = JSON.stringify(obj), fabric.util.enlivenObjects([JSON.parse(json)], function (objects) {
  objects.forEach(function (o) {
    o.top -= bound.top;
    o.left -= bound.left;
    canvas.add(o);
  });
  canvas.renderAll();
  return canvas.toDataURL("image/png");
});


from fabricjs how to see if object src is raster or vectorized

No comments:

Post a Comment