1.0.3 • Published 4 years ago

pnm-convertor v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

PNM Convertor

npm version

Simple promise function to convert .pbm, .pgm. or .ppm file to image format (The default format type is image/png).

Installation

 # with npm
npm install pnm-convertor
# with yarn
yarn add pnm-convertor

Usage

// React
import React, { memo, useState, useCallback } from 'react';
import convert from 'pnm-convertor';

const Demo = () => {
  const [image, setImage] = useState(null);
  const onChange = useCallback(async (e) => {
    const files = e.target.files;
    const file = await convert(files[0]);
    setImage(file);
  }, []);
  return (
    <div>
      <input type="file" onChange={onChange} />
      {image && <img src={image} alt="upload" />}
    </div>
  );
};

export default memo(Demo);
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago