icre-lib

ICRE Library

$500

0 downloads
icrescenti

ICRE Library v1.0.4

New Functions Added

downscaleImage

Downscales an image to a specified maximum size in kilobytes while maintaining aspect ratio.

downscaleImage(base64Image, maxsize)

Parameters:

  • base64Image (string): The base64 encoded image to downscale
  • maxsize (number): The maximum size in kilobytes (default: 1500)

Returns:

  • (Promise): A promise that resolves to the base64 encoded downscaled image

Example:

const base64Image = "data:image/jpeg;base64,/9j/4AAQSkZJRg..."; // Your base64 image
const downscaledImage = await downscaleImage(base64Image, 1000); // Downscale to max 1MB
// downscaledImage: "data:image/jpeg;base64,/9j/4AAQSkZJRg..." // Downscaled base64 image

exportTableToCSV

Exports an HTML table to CSV format, with options to download the file or return the content.

exportTableToCSV(tableElement, download, downloadName)

Parameters:

  • tableElement (string|HTMLElement): The ID of the HTML table element or the table element itself
  • download (boolean): Whether to download the CSV file (default: true)
  • downloadName (string): The name of the CSV file to download (default: 'table.csv')

Returns:

  • (string|null): The CSV content as a string, or null if the table is not found or has no rows

Example:

// Using table ID
const csvContent = exportTableToCSV('myTable', true, 'export.csv');

// Using table element const tableElement = document.querySelector('#myTable'); const csvContent = exportTableToCSV(tableElement, false); // Returns content without downloading

Usage

These utility functions are part of the ICRE Library and can be imported as follows:

import { downscaleImage, exportTableToCSV } from 'icre-lib';

For more information about the ICRE Library, please refer to the main documentation.

Monetize your
open-source work

Supercharge your OSS projects by selling npm packages. Get started in just 5 minutes.