image-to-file-converter

1.0.6 • Public • Published

image-to-file-converter

Install

$ npm install image-to-file-converter

Usage

画像パスからFileオブジェクト

import { pathToFile } from 'image-to-file-converter'

pathToFile('./path/to/image.jpg').then((res)=>{
      console.info(res)  // File
})  

Functions

base64ToFile

base64ToFile(src: string,  resize?: number, name?: string): Promise<File>
  • src:string | 元画像のbase64
  • name?: string | 拡張子付きのファイル名
  • resize?: number | 縮小後の長辺の長さ nullまたは0以下の時は原寸

pathToFile

pathToFile(src: string,  resize?: number): Promise<File>

DEMO

https://tkpea.github.io/image-to-file-converter/example/dist/

Example

$ git clone https://github.com/tkpea/image-to-file-converter.git
$ cd ./example/image-to-file-converter
$ npm install
$ npm run start

TIPS

FileオブジェクトのダウンロードURLを生成する

let url = window.URL.createObjectURL(File);

Readme

Keywords

Package Sidebar

Install

npm i image-to-file-converter

Weekly Downloads

2

Version

1.0.6

License

MIT

Unpacked Size

9.04 kB

Total Files

4

Last publish

Collaborators

  • tkpea