(imageUrl)
| 1956 | }; |
| 1957 | //convert https url to base64 |
| 1958 | export 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 |
| 1979 | export const changeImageWH = async (base64Image) => { |
| 1980 | const newWidth = 300; |
no outgoing calls
no test coverage detected