PageSourceSearch

https://www.convertsimple.com/wp-content/uploads/2022/01/svgconvert.js?v=

js convertsimple.com collected 2026-10-04 00:17:11 UTC 3,325 bytes, 112 lines download raw bytes

1
2
3importScripts("/wp-content/uploads/2022/01/DOMParser.js");
4importScripts("/wp-content/uploads/2022/01/canvg.min_.js");
5
6
7async function goConvert(file, fileNameNoExtension, rowId, from, to, options) {
8	sendStatusUpdate(rowId, "Converting file...", "PROCESSING");
9	
10	try {
11		var outputFileNameWithExtension = fileNameNoExtension + "." + to;
12		
13		
14		var fileReader = new FileReader();
15        fileReader.onload = async() => {
16			var result = fileReader.result;
17			
18			const canvas = new OffscreenCanvas(200, 200);
19			const ctx = canvas.getContext('2d');
20			var v = await canvg.Canvg.from(ctx, result, canvg.presets.offscreen());
21
22			
23			await v.render();
24			
25			var contentType = extensionToContentType[to];
26			
27			sendStatusUpdate(rowId, "Encoding image...", "PROCESSING");
28			var outputFile = await canvas.convertToBlob({type: contentType});
29			
30			sendCompletedFile(rowId, outputFile, outputFileNameWithExtension, to);
31
32			
33			/*
34			var blob = b64toBlob(result, extensionToContentType[to]);
35			const img = await createImageBitmap(blob);
36			//var arr = new Uint16Array(result.buffer, result.byteOffset, result.byteLength / Uint16Array.BYTES_PER_ELEMENT);
37			//var image = new ImageData(arr, 100);
38			console.log(img);
39			var canvasFactory = new NodeCanvasFactory();
40			var canvasAndContext = canvasFactory.create(
41			  img.width,
42			  img.height
43			);
44			
45			var canvas = canvasAndContext.canvas;
46			var ctx = canvasAndContext.context;
47			
48			ctx.drawImage(img, img.width, img.height);
49			
50			
51			var contentType = extensionToContentType[to];
52			
53			sendStatusUpdate(rowId, "Encoding image " + pageNum + "...", "PROCESSING");
54			var outputFile = await canvas.convertToBlob({type: contentType});
55			
56			sendCompletedFile(rowId, outputFile, outputFileNameWithExtension, to);
57			*/
58		};
59		fileReader.readAsText(file);
60		
61	} catch (err) {
62		console.log(err);
63		sendStatusUpdate(rowId, "Conversion error.", "ERROR");
64	}
65}
66
67const b64toBlob = (b64Data, contentType='', sliceSize=512) => {
68  const byteCharacters = atob(b64Data);
69  const byteArrays = [];
70
71  for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
72    const slice = byteCharacters.slice(offset, offset + sliceSize);
73
74    const byteNumbers = new Array(slice.length);
75    for (let i = 0; i < slice.length; i++) {
76      byteNumbers[i] = slice.charCodeAt(i);
77    }
78
79    const byteArray = new Uint8Array(byteNumbers);
80    byteArrays.push(byteArray);
81  }
82
83  const blob = new Blob(byteArrays, {type: contentType});
84  return blob;
85}
86
87function NodeCanvasFactory() {}
88NodeCanvasFactory.prototype = {
89  create: function NodeCanvasFactory_create(width, height) {
90    var canvas = new OffscreenCanvas(width, height);
91    var context = canvas.getContext("2d");
92    return {
93      canvas,
94      context,
95    };
96  },
97
98  reset: function NodeCanvasFactory_reset(canvasAndContext, width, height) {
99    canvasAndContext.canvas.width = width;
100    canvasAndContext.canvas.height = height;
101  },
102
103  destroy: function NodeCanvasFactory_destroy(canvasAndContext) {
104
105    // Zeroing the width and height cause Firefox to release graphics
106    // resources immediately, which can greatly reduce memory consumption.
107    canvasAndContext.canvas.width = 0;
108    canvasAndContext.canvas.height = 0;
109    canvasAndContext.canvas = null;
110    canvasAndContext.context = null;
111  },
112};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.