MCPcopy Index your code
hub / github.com/OpenSignLabs/OpenSign / fetchImageBase64

Function fetchImageBase64

apps/OpenSign/src/constant/Utils.js:1958–1977  ·  view source on GitHub ↗
(imageUrl)

Source from the content-addressed store, hash-verified

1956};
1957//convert https url to base64
1958export const fetchImageBase64 = async (imageUrl) => {
1959 try {
1960 const response = await fetch(imageUrl);
1961 const blob = await response.blob();
1962
1963 return new Promise((resolve, reject) => {
1964 const reader = new FileReader();
1965 reader.readAsDataURL(blob);
1966 reader.onloadend = () => {
1967 const base64data = reader.result;
1968 resolve(base64data);
1969 };
1970 reader.onerror = (error) => {
1971 reject(error);
1972 };
1973 });
1974 } catch (error) {
1975 throw new Error("Error converting URL to base64:", error);
1976 }
1977};
1978//function for select image and upload image
1979export const changeImageWH = async (base64Image) => {
1980 const newWidth = 300;

Callers 2

signPdfFunFunction · 0.90
signPdfFunFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected