Skip to content

yezhi780625/pnm-convertor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

Convert NetPBM format file to DataURL

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published