Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/m4k15y6666fk/auto-thumbnail
https://github.com/m4k15y6666fk/auto-thumbnail
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/m4k15y6666fk/auto-thumbnail
- Owner: m4k15y6666fk
- License: mit
- Created: 2024-06-02T18:56:57.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-02T20:01:21.000Z (7 months ago)
- Last Synced: 2024-06-02T21:41:40.924Z (7 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# auto-thumbnail
**rectangle image -> square image**
**長方形の画像 -> 正方形の画像**
## Summary / 概要
Auto thumbnail (squared thumbnail) image generator with entropy.
エントロピーによってサムネイル画像(正方形)を生成するスクリプト
## Usage / 使い方
### Install
```bash
# install all sources into "auto-thumbnail" directory in your current path
git clone "https://github.com/m4k15y6666fk/auto-thumbnail.git"
```### Use in your JavaScript
```js
// import the module
import { toThumbnail } from "./auto-thumbnail/index.js";// convert image file (File Object) to thumbnail (File Object)
// File - https://developer.mozilla.org/en-US/docs/Web/API/File
const thumbnail = await toThumbnail(
file, // File Object - https://developer.mozilla.org/en-US/docs/Web/API/File
{
outputSize: 512, // thumbnail size (width & height)
inputSize: 256, // [CAUTION] This value is only using when computing entropy.
type: 'image/jpeg', // MIME type of output thumbnail
quality: 0.8 // compression level of thumbnail (range: 0.0 - 1.0)
}
);/* Other Methods for adovanced operation */
import { file2imagedata, transpose } from "./auto-thumbnail/index.js";
// convert image file (File Object) into ImageData
// ImageData Object - https://developer.mozilla.org/en-US/docs/Web/API/ImageData
const pixels = await file2imagedata(
file, // File
{
size: -1
// minimum side of output (width OR height)
// "-1" is meaning of input size and output size is equivalant.
}
);// transpose imageData
const transposed_imagedata = transpose(
pixels // imageData
)
```## Donate / ご支援
### OFUSE
[https://ofuse.me/m4k15y6666fk](https://ofuse.me/m4k15y6666fk)