Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
@edifice.io/image-resizer
Advanced tools
The ImageResizer
class provides functionality to resize and compress image files. Below is an overview of its methods and usage.
changeDimension(height: number, maxHeight: number, width: number, maxWidth: number): { height: number; width: number }
This private static method adjusts the height and width of an image to fit within the specified maximum dimensions while maintaining the aspect ratio.
renameFileNameExtension(filename: string, newExtension: string): string
This private static method changes the file extension of a given filename to the specified new extension.
resizeImage(image: HTMLImageElement, fileName: string, maxWidth: number, maxHeight: number, compressFormat = "jpeg", quality = 80): Promise<File>
This private static method resizes an image to the specified dimensions and compresses it to the specified quality. It returns a promise that resolves to a File
object.
resizeImageFile(file: File, maxWidth: number = 1440, maxHeight: number = 1440, quality: number = 80): Promise<File>
This public static method resizes and compresses an image file. It returns a promise that resolves to the resized image file.
To use the ImageResizer
class, you can call the resizeImageFile
method with the image file and desired dimensions:
import ImageResizer from "./ImageResizer";
const fileInput = document.getElementById("fileInput") as HTMLInputElement;
fileInput.addEventListener("change", async (event) => {
const file = (event.target as HTMLInputElement).files?.[0];
if (file) {
try {
const resizedFile = await ImageResizer.resizeImageFile(
file,
800,
600,
70,
);
console.log("Resized file:", resizedFile);
} catch (error) {
console.error("Error resizing image:", error);
}
}
});
resizeImageFile
method only supports JPEG format for compression.FAQs
Edifice Image Resizer
The npm package @edifice.io/image-resizer receives a total of 57 weekly downloads. As such, @edifice.io/image-resizer popularity was classified as not popular.
We found that @edifice.io/image-resizer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.