mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 05:33:02 -05:00
Improve performance of image processing (#135)
* Improve performance of image processing * refactor * add changelog
This commit is contained in:
parent
fd14e544b8
commit
8a86304fea
4 changed files with 31 additions and 3 deletions
5
.changeset/khaki-mirrors-smoke.md
Normal file
5
.changeset/khaki-mirrors-smoke.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"penpot-exporter": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Improve image processing speed
|
24
package-lock.json
generated
24
package-lock.json
generated
|
@ -1,15 +1,16 @@
|
||||||
{
|
{
|
||||||
"name": "penpot-exporter",
|
"name": "penpot-exporter",
|
||||||
"version": "0.3.1",
|
"version": "0.4.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "penpot-exporter",
|
"name": "penpot-exporter",
|
||||||
"version": "0.3.1",
|
"version": "0.4.1",
|
||||||
"license": "MPL2.0",
|
"license": "MPL2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@create-figma-plugin/ui": "^3.2",
|
"@create-figma-plugin/ui": "^3.2",
|
||||||
|
"base64-js": "^1.5",
|
||||||
"classnames": "^2.5",
|
"classnames": "^2.5",
|
||||||
"preact": "^10.21",
|
"preact": "^10.21",
|
||||||
"react-hook-form": "^7.51",
|
"react-hook-form": "^7.51",
|
||||||
|
@ -3240,6 +3241,25 @@
|
||||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/base64-js": {
|
||||||
|
"version": "1.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||||
|
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/better-path-resolve": {
|
"node_modules/better-path-resolve": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/better-path-resolve/-/better-path-resolve-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/better-path-resolve/-/better-path-resolve-1.0.0.tgz",
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"license": "MPL2.0",
|
"license": "MPL2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@create-figma-plugin/ui": "^3.2",
|
"@create-figma-plugin/ui": "^3.2",
|
||||||
|
"base64-js": "^1.5",
|
||||||
"classnames": "^2.5",
|
"classnames": "^2.5",
|
||||||
"preact": "^10.21",
|
"preact": "^10.21",
|
||||||
"react-hook-form": "^7.51",
|
"react-hook-form": "^7.51",
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { fromByteArray } from 'base64-js';
|
||||||
|
|
||||||
import { imagesLibrary } from '@plugin/ImageLibrary';
|
import { imagesLibrary } from '@plugin/ImageLibrary';
|
||||||
import { detectMimeType } from '@plugin/utils';
|
import { detectMimeType } from '@plugin/utils';
|
||||||
|
|
||||||
|
@ -36,7 +38,7 @@ const generateAndRegister = async (imageHash: string) => {
|
||||||
|
|
||||||
const bytes = await image.getBytesAsync();
|
const bytes = await image.getBytesAsync();
|
||||||
const { width, height } = await image.getSizeAsync();
|
const { width, height } = await image.getSizeAsync();
|
||||||
const b64 = figma.base64Encode(bytes);
|
const b64 = fromByteArray(bytes);
|
||||||
const mtype = detectMimeType(b64);
|
const mtype = detectMimeType(b64);
|
||||||
const dataUri = `data:${mtype};base64,${b64}`;
|
const dataUri = `data:${mtype};base64,${b64}`;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue