nano-banana-1
v1766993.9.5
Published
Professional integration for https://supermaker.ai/image/nano-banana/
Readme
nano-banana-1
A lightweight JavaScript utility for performing basic image manipulations, primarily focused on resizing and format conversion. Simplifies common image processing tasks within Node.js environments.
Installation
Install the package using npm: bash npm install nano-banana-1
Usage
Here are several examples demonstrating how to use nano-banana-1 in your projects:
1. Resizing an Image:
This example demonstrates resizing an image to a specific width while maintaining aspect ratio. javascript const nanoBanana = require('nano-banana-1');
async function resizeImage() {
try {
const resizedImagePath = await nanoBanana.resizeImage('./input.jpg', './output_resized.jpg', { width: 200 });
console.log(Image resized successfully to: ${resizedImagePath});
} catch (error) {
console.error('Error resizing image:', error);
}
}
resizeImage();
2. Converting Image Format:
Convert an image from one format (e.g., PNG) to another (e.g., JPEG). javascript const nanoBanana = require('nano-banana-1');
async function convertImageFormat() {
try {
const convertedImagePath = await nanoBanana.convertImageFormat('./input.png', './output.jpg', 'jpeg');
console.log(Image converted successfully to: ${convertedImagePath});
} catch (error) {
console.error('Error converting image:', error);
}
}
convertImageFormat();
3. Resizing and Converting in a Single Operation:
Combine resizing and format conversion for efficient image processing. javascript const nanoBanana = require('nano-banana-1');
async function resizeAndConvert() {
try {
const outputImagePath = await nanoBanana.processImage('./input.png', './output_processed.jpg', { width: 300, format: 'jpeg' });
console.log(Image resized and converted successfully to: ${outputImagePath});
} catch (error) {
console.error('Error processing image:', error);
}
}
resizeAndConvert();
4. Handling Errors:
Properly handle potential errors during image processing. javascript const nanoBanana = require('nano-banana-1');
async function processImageWithErrorHandler() {
try {
const outputImagePath = await nanoBanana.resizeImage('./nonexistent_image.jpg', './output.jpg', { width: 100 });
console.log(Image processed successfully: ${outputImagePath});
} catch (error) {
console.error('Error processing image:', error.message); // Log the error message
}
}
processImageWithErrorHandler();
5. Using with Promises:
Employ promises for asynchronous operation management. javascript const nanoBanana = require('nano-banana-1');
nanoBanana.resizeImage('./input.jpg', './output_promise.jpg', { width: 150 })
.then(resizedImagePath => {
console.log(Image resized via promise: ${resizedImagePath});
})
.catch(error => {
console.error('Error resizing image via promise:', error);
});
API Summary
resizeImage(inputPath, outputPath, options): Resizes an image.inputPath: Path to the input image.outputPath: Path to save the resized image.options: An object with the following properties:width(optional): The desired width of the image.height(optional): The desired height of the image. If only one dimension is provided, the other is calculated to maintain aspect ratio.
convertImageFormat(inputPath, outputPath, format): Converts an image to a different format.inputPath: Path to the input image.outputPath: Path to save the converted image.format: The desired image format (e.g., 'jpeg', 'png', 'webp').
processImage(inputPath, outputPath, options): Resizes and/or converts an image format.inputPath: Path to the input image.outputPath: Path to save the processed image.options: An object with properties for resizing (width,height) and format conversion (format).
License
MIT
This package is part of the nano-banana-1 ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/image/nano-banana/
