npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

instantlight-js

v1.1.0

Published

InstantLight SDK for JavaScript

Downloads

4

Readme

InstantLight SDK for JavaScript

The InstantLight SDK allows you to manipulate lighting in images with or without prompts and change the background while editing the light. This SDK is easy to use and integrates with any JavaScript project.

Installation

Install the SDK using npm:

npm install instantlight-js

Usage/ Initialization

First, require the SDK in your JavaScript file and set up the API client with your API key and user email.

const { APIClient, ImageGeneration } = require('instantlight-js');

// Initialize API client
const apiClient = new APIClient('https://api.fotographer.ai/instantLight', 'your-api-key', '[email protected]');

// Initialize ImageGeneration with the API client
const imageGeneration = new ImageGeneration(apiClient);

Modes of Operation

The SDK supports three modes of operation for editing images:

Mode 0: Edit light without a prompt and with a prompt Mode 2: Edit light while changing the background Mode 0: Edit Light Without a Prompt To edit the light in an image without using a prompt, set the mode parameter to 0.

const imageData = {
  foreground_image64: 'base64_encoded_foreground_image',
  background_image64: 'base64_encoded_background_image',
  prompt: '',
  mode: 0,
  prompt_strength: 0.0,
  inf_factor: 1.00,
  mask_strength: 0.5,
  image_width: 1400,
  image_height: 1400,
  additional_prompt: '',
  negative_prompt: '',
  lights: [] // Specify the lighting parameters as needed
};

imageGeneration.getImageGen(imageData)
  .then(response => {
    // Handle the response containing the edited image
    console.log(response);
  })
  .catch(error => {
    console.error('Error editing light:', error);
  });

Mode 0: Edit Light With a Prompt To edit the light in an image using a prompt, set the mode parameter to 1 and provide a prompt.

const imageData = {
  foreground_image64: 'base64_encoded_foreground_image',
  background_image64: 'base64_encoded_background_image',
  prompt: 'neon light',
  mode: 1,
  prompt_strength: 4.0,
  inf_factor: 1.00,
  mask_strength: 0.5,
  image_width: 1400,
  image_height: 1400,
  additional_prompt: '',
  negative_prompt: '',
  lights: [] // Specify the lighting parameters as needed
};

imageGeneration.getImageGen(imageData)
  .then(response => {
    // Handle the response containing the edited image
    console.log(response);
  })
  .catch(error => {
    console.error('Error editing light with prompt:', error);
  });

Mode 2: Edit Light and Change Background To edit the light and change the background of an image, set the mode parameter to 2.

const imageData = {
  foreground_image64: 'base64_encoded_foreground_image',
  background_image64: 'base64_encoded_background_image',
  prompt: 'sunset background',
  mode: 2,
  prompt_strength: 4.0,
  inf_factor: 1.00,
  mask_strength: 0.5,
  image_width: 1400,
  image_height: 1400,
  additional_prompt: '',
  negative_prompt: '',
  lights: [] // Specify the lighting parameters as needed
};

imageGeneration.getImageGen(imageData)
  .then(response => {
    // Handle the response containing the edited image
    console.log(response);
  })
  .catch(error => {
    console.error('Error editing light and changing background:', error);
  });

Handling API Responses Here's an example of how to Prepare the data and handle API responses, including saving the edited image and any mask image to disk:

const imageToBase64 = async (imagePath) => {
    const image = await loadImage(imagePath);
    const canvas = createCanvas(image.width, image.height);
    const ctx = canvas.getContext('2d');
    ctx.drawImage(image, 0, 0);
    return canvas.toDataURL().split(',')[1];
};

const imageDataMode0 = {
  foreground_image64: await imageToBase64('path_to_foreground_image.png'),
  background_image64: await imageToBase64('path_to_background_image.png'),
  prompt: '',
  mode: 0,
  prompt_strength: 0.0,
  inf_factor: 1.00,
  mask_strength: 0.5,
  image_width: 1400,
  image_height: 1400,
  additional_prompt: '',
  negative_prompt: '',
  lights: [] // Specify the lighting parameters as needed
};

imageGeneration.getImageGen(imageDataMode0)
  .then(response => {
    console.log('Response Keys:', Object.keys(response));

    if (response.image) {
      const imageBuffer = Buffer.from(response.image, 'base64');
      fs.writeFileSync('output_image_mode0.png', imageBuffer);
      console.log('Image retrieved and saved as output_image_mode0.png.');

      if (response.mask_image) {
        const maskBuffer = Buffer.from(response.mask_image, 'base64');
        fs.writeFileSync('output_mask_image_mode0.png', maskBuffer);
        console.log('Mask retrieved and saved as output_mask_image_mode0.png.');
      }
    } else {
      console.error("Response does not contain 'image'");
    }

    fs.writeFileSync('response_log_mode0.txt', JSON.stringify(response, null, 2));
  })
  .catch(error => {
    console.error('Error editing light:', error);
  });

API Reference APIClient The APIClient class handles the communication with the backend API.

Methods constructor(baseURL, apiKey, userEmail): Initializes the API client with the base URL, API key, and user email. post(endpoint, jsonData): Sends a POST request to the specified endpoint with the provided JSON data. ImageGeneration The ImageGeneration class uses the APIClient to edit images.

Methods constructor(apiClient): Initializes the ImageGeneration class with an APIClient instance. getImageGen(imageData): Edits the image based on the provided image data and returns a promise with the response.