In that case you will need to convert the resulting tensor to be integer values and not floating point.
You can use something like:
tf.cast(data, 'int32')

However before doing that inspect the resulting Tensor to see what the values are after the image read. Depending how it decoded if it decided to take RGB values and normalize them eg instead of numbers from 0-255 it gives numbers  0 -1 as a floating point then you would want to convert back to whole number by multiplying by 255 first. Else 0.1239803 would just become 0 in a cast to integer which is not what you want!
However if you are using the PNG method I listed above it automatically returns an int32 tensor so it is probably better to do that if you are not using that method and you know your images are always PNG.

  
      

      js.tensorflow.org
  

  
    

TensorFlow.js

  A WebGL accelerated, browser based JavaScript library for training and deploying ML models