Skip to content

Commit

Permalink
Improve performance of image processing (#135)
Browse files Browse the repository at this point in the history
* Improve performance of image processing

* refactor

* add changelog
  • Loading branch information
jordisala1991 authored Jun 4, 2024
1 parent fd14e54 commit 8a86304
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-mirrors-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"penpot-exporter": patch
---

Improve image processing speed
24 changes: 22 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"license": "MPL2.0",
"dependencies": {
"@create-figma-plugin/ui": "^3.2",
"base64-js": "^1.5",
"classnames": "^2.5",
"preact": "^10.21",
"react-hook-form": "^7.51",
Expand Down
4 changes: 3 additions & 1 deletion plugin-src/translators/fills/translateImageFill.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { fromByteArray } from 'base64-js';

import { imagesLibrary } from '@plugin/ImageLibrary';
import { detectMimeType } from '@plugin/utils';

Expand Down Expand Up @@ -36,7 +38,7 @@ const generateAndRegister = async (imageHash: string) => {

const bytes = await image.getBytesAsync();
const { width, height } = await image.getSizeAsync();
const b64 = figma.base64Encode(bytes);
const b64 = fromByteArray(bytes);
const mtype = detectMimeType(b64);
const dataUri = `data:${mtype};base64,${b64}`;

Expand Down

0 comments on commit 8a86304

Please sign in to comment.