|
1 | 1 | import { promises as fs } from 'fs'
|
2 | 2 | import { join } from 'path'
|
3 | 3 |
|
4 |
| -import { createCanvas, Image } from '@napi-rs/canvas' |
| 4 | +// import { createCanvas, Image } from '@napi-rs/canvas' |
5 | 5 | import b from 'benny'
|
6 | 6 | import sharp from 'sharp'
|
7 | 7 | import svg2img from 'svg2img'
|
@@ -37,25 +37,25 @@ async function run() {
|
37 | 37 | }),
|
38 | 38 |
|
39 | 39 | // test from https://github.com/Brooooooklyn/canvas/blob/main/example/resize-svg.js
|
40 |
| - b.add('skr-canvas(Rust)', () => { |
41 |
| - const image = new Image() |
42 |
| - image.src = svg1 |
| 40 | + // b.add('skr-canvas(Rust)', () => { |
| 41 | + // const image = new Image() |
| 42 | + // image.src = svg1 |
43 | 43 |
|
44 |
| - const w = 1200 |
45 |
| - const h = 623 |
| 44 | + // const w = 1200 |
| 45 | + // const h = 623 |
46 | 46 |
|
47 |
| - // resize SVG |
48 |
| - image.width = w |
49 |
| - image.height = h |
| 47 | + // // resize SVG |
| 48 | + // image.width = w |
| 49 | + // image.height = h |
50 | 50 |
|
51 |
| - // create a canvas of the same size as the image |
52 |
| - const canvas = createCanvas(w, h) |
53 |
| - const ctx = canvas.getContext('2d') |
| 51 | + // // create a canvas of the same size as the image |
| 52 | + // const canvas = createCanvas(w, h) |
| 53 | + // const ctx = canvas.getContext('2d') |
54 | 54 |
|
55 |
| - // fill the canvas with the image |
56 |
| - ctx.drawImage(image, 0, 0) |
57 |
| - canvas.toBuffer('image/png') |
58 |
| - }), |
| 55 | + // // fill the canvas with the image |
| 56 | + // ctx.drawImage(image, 0, 0) |
| 57 | + // canvas.toBuffer('image/png') |
| 58 | + // }), |
59 | 59 |
|
60 | 60 | b.add('svg2img(canvg + node-canvas)', () => {
|
61 | 61 | svg2img(svg1.toString('utf8'), { width: 1200, height: 623 }, function (_error, _buffer) {})
|
@@ -93,25 +93,25 @@ async function run() {
|
93 | 93 | }),
|
94 | 94 |
|
95 | 95 | // test from https://github.com/Brooooooklyn/canvas/blob/main/example/resize-svg.js
|
96 |
| - b.add('skr-canvas(Rust)', () => { |
97 |
| - const image = new Image() |
98 |
| - image.src = icon |
| 96 | + // b.add('skr-canvas(Rust)', () => { |
| 97 | + // const image = new Image() |
| 98 | + // image.src = icon |
99 | 99 |
|
100 |
| - const w = 386 |
101 |
| - const h = 386 |
| 100 | + // const w = 386 |
| 101 | + // const h = 386 |
102 | 102 |
|
103 |
| - // resize SVG |
104 |
| - image.width = w |
105 |
| - image.height = h |
| 103 | + // // resize SVG |
| 104 | + // image.width = w |
| 105 | + // image.height = h |
106 | 106 |
|
107 |
| - // create a canvas of the same size as the image |
108 |
| - const canvas = createCanvas(w, h) |
109 |
| - const ctx = canvas.getContext('2d') |
| 107 | + // // create a canvas of the same size as the image |
| 108 | + // const canvas = createCanvas(w, h) |
| 109 | + // const ctx = canvas.getContext('2d') |
110 | 110 |
|
111 |
| - // fill the canvas with the image |
112 |
| - ctx.drawImage(image, 0, 0) |
113 |
| - canvas.toBuffer('image/png') |
114 |
| - }), |
| 111 | + // // fill the canvas with the image |
| 112 | + // ctx.drawImage(image, 0, 0) |
| 113 | + // canvas.toBuffer('image/png') |
| 114 | + // }), |
115 | 115 |
|
116 | 116 | b.add('svg2img(canvg + node-canvas)', () => {
|
117 | 117 | svg2img(icon.toString('utf8'), { width: 386, height: 386 }, function (_error, _buffer) {})
|
@@ -139,25 +139,25 @@ async function run() {
|
139 | 139 | await sharp(tiger).toBuffer()
|
140 | 140 | }),
|
141 | 141 |
|
142 |
| - b.add('skr-canvas(Rust)', () => { |
143 |
| - const image = new Image() |
144 |
| - image.src = tiger |
| 142 | + // b.add('skr-canvas(Rust)', () => { |
| 143 | + // const image = new Image() |
| 144 | + // image.src = tiger |
145 | 145 |
|
146 |
| - const w = 900 |
147 |
| - const h = 900 |
| 146 | + // const w = 900 |
| 147 | + // const h = 900 |
148 | 148 |
|
149 |
| - // resize SVG |
150 |
| - image.width = w |
151 |
| - image.height = h |
| 149 | + // // resize SVG |
| 150 | + // image.width = w |
| 151 | + // image.height = h |
152 | 152 |
|
153 |
| - // create a canvas of the same size as the image |
154 |
| - const canvas = createCanvas(w, h) |
155 |
| - const ctx = canvas.getContext('2d') |
| 153 | + // // create a canvas of the same size as the image |
| 154 | + // const canvas = createCanvas(w, h) |
| 155 | + // const ctx = canvas.getContext('2d') |
156 | 156 |
|
157 |
| - // fill the canvas with the image |
158 |
| - ctx.drawImage(image, 0, 0) |
159 |
| - canvas.toBuffer('image/png') |
160 |
| - }), |
| 157 | + // // fill the canvas with the image |
| 158 | + // ctx.drawImage(image, 0, 0) |
| 159 | + // canvas.toBuffer('image/png') |
| 160 | + // }), |
161 | 161 |
|
162 | 162 | b.add('svg2img(canvg + node-canvas)', () => {
|
163 | 163 | svg2img(tiger.toString('utf8'), { width: 900, height: 900 }, function (_error, _buffer) {})
|
|
0 commit comments