Current Path: > home > codekrsu > > ameliagraphics.com > wp-content > plugins > extendify > > src > Shared > utils
Operation : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 Software : Apache Server IP : 162.0.232.56 | Your IP: 216.73.216.111 Domains : 1034 Domain(s) Permission : [ 0755 ]
Name | Type | Size | Last Modified | Actions |
---|---|---|---|---|
__tests__ | Directory | - | - | |
get-url-parameter.js | File | 680 bytes | March 13 2025 21:10:44. | |
resize-image.js | File | 1595 bytes | May 12 2025 16:42:28. | |
sanitize.js | File | 540 bytes | March 13 2025 21:10:44. |
/** * Resize an image to the specified dimensions. * * @param {string} imageUrl - The source URL or blob URL of the image. * @param {Object} options - Configuration options. * @param {{ width: number, height: number }} options.size - Required size (e.g., { width: 64, height: 64 }). * @param {string} [options.mimeType='image/png'] - Output format (e.g., 'image/png', 'image/webp'). * @returns {Promise<string>} - A blob URL of the resized image. * * @throws Will throw an error if imageUrl or size is invalid, or if resizing fails. */ export const resizeImage = async (imageUrl, options = {}) => { const { size, mimeType = 'image/png' } = options; if ( !imageUrl || !size || typeof size.width !== 'number' || typeof size.height !== 'number' || size.width <= 0 || size.height <= 0 ) { throw new Error('Invalid imageUrl or size dimensions'); } const img = await loadImage(imageUrl); const canvas = document.createElement('canvas'); canvas.width = size.width; canvas.height = size.height; const ctx = canvas.getContext('2d'); ctx.clearRect(0, 0, size.width, size.height); ctx.drawImage(img, 0, 0, size.width, size.height); return new Promise((resolve) => { canvas.toBlob( (blob) => { if (!blob) { throw new Error('Failed to create blob from canvas'); } resolve(URL.createObjectURL(blob)); }, mimeType, 0.95, ); }); }; const loadImage = (src) => new Promise((resolve, reject) => { const img = new Image(); img.crossOrigin = 'anonymous'; img.onload = () => resolve(img); img.onerror = reject; img.src = src; });
SILENT KILLER Tool