pgm-utils
v1.0.2
Published
A PGM Utils
Maintainers
Readme
PGMUtils
Introduction
A toolkit for parsing and generating PGM files
Version History
| Version Number | Update Content | Updater | | -------------- | -------------------------- | ----------- | | 1.0.0 | PGM parsing and generation toolkit | CorrineCao |
Installation Tutorial
- npm install pgm-utils
- yarn add pgm-utils
Usage Instructions
Parse PGM to ImageData
<Upload customRequest={async (info: any) => { const { file: originFileObj } = info; if (originFileObj.name.endsWith('.pgm')) { const pgmImg: ImageData = await PGMUtils.PGMTool.getImageDataByPGMBlob(originFileObj); } }} > <Button type="primary">Upload and parse PGM file</Button> </Upload>Generate PGM from ImageData
const pgmBlob: Uint8Array = PGMUtils.PGMTool.getPGMByImageData(imageData);Unzip and parse zip files with pgm, yaml, and json files
<Upload
customRequest={async (info: any) => {
const { file: originFileObj } = info;
if (info.file.name.endsWith('.zip')) {
if (originFileObj) {
PGMUtils.DeflateTool.inflatePKG(originFileObj).then((res) => {
console.log('>>>>res:', res);
});
}
}
}}
>
<Button type="primary">Upload and parse compressed PGM file</Button>
</Upload>Compress files and return a file object. It supports direct export of ZIP format files, which can include JSON, PGM, and YAML file formats. File names can be customized.
import PGMUtils from 'pgm-utils'; const record: Record<string, any> = {}; record['test.json'] = { name: 'test', ... }; record['test.pgm'] = ImageData; record['test.yaml'] = { name: 'test', origin: [0,0,0], ... } PGMUtils.DeflateTool.deflatePKG(record, 'compressed name');Directly compress and obtain a File object of ZIP type
const file = await PGMUtils.DeflateTool.getDeflatePKG(record, 'compressed name');Compress and directly export the ZIP file
PGMUtils.DeflateTool.exportDeflatePKG(record, 'compressed name');Get the content of the uploaded YAML file
<Upload customRequest={async (info: any) => { const { file: originFileObj } = info; if (originFileObj.name.endsWith('.yaml')) { const yamlInfo = await PGMUtils.YamlTool.getYamlInfoByBlob(originFileObj); } }} > <Button type="primary">Upload YAML file</Button> </Upload>Convert string data into YAML file object data
const yamlInfo = PGMUtils.YamlTool.getYamlInfoByContent(yamlContent);- Convert YAML object data into string-type data
const yamlContent = PGMUtils.YamlTool.getContentByYamlInfo(yamlInfo);Contribute
CorrineCao
