New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

photonify

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

photonify

Photonify is a utility to manage multipart image uploads and automatically process them with fingerprinting and storage.

  • 3.0.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Photonify

Photonify is a utility to manage image uploads and automatically process them into fingerprinted files. The plugin also supports S3 uploads.

Installation

NPM
npm install photonify
Yarn
yarn add photonify

Usage

  • Photonify has a method called processFiles that will create four resized photos for you by default. The arguments passed to this method will differ slightly depending on filesystem vs. S3 storage.
  • Both examples are below:
Filesystem Storage:

Parameters:

  • File Array: Buffer[] - Required
  • outputDest: String - Required
  • outputFormat: String
  • sizes: String

Example with Custom Sizes:

import { processFiles } from "photonify";

const imageBuffer = req.file.buffer;

const result = await processFiles([imageBuffer], {
  outputDest: path.join(__dirname, "resized_images"),
  sizes: {
    lg: {
      width: 500,
      height: 250,
    },
    md: {
      width: 250,
      height: 125,
    },
  },
});
S3 Storage:

Parameters:

  • File Array: Buffer[] - Required
  • storage: String - Required
  • s3Config: any - Required details here
  • s3Bucket: String - Required
  • outputFormat: String

Example:

import { processFiles } from "photonify";

const imageBuffer = req.file.buffer;

const result = await processFiles([imageBuffer], {
  storage: "s3",
  s3Config: {
    region: "us-west-1",
  },
  s3Bucket: "photonify",
});

Photonify Uses Sharp

Removing Files

  • Photonify has support for removing files from S3
  • Note: No support for local filesystem removal is added to Photonify. You are encouraged to use the built-in fs.unlink method instead.
Removing S3 Files:

Parameters:

  • File Names: String[] - Required
  • storage: String - Required
  • s3Config: any - Required details here
  • s3Bucket: String - Required

Example:

import { removeFiles } from "photonify";

await removeFiles(["file1.jpg", "file2.jpg"], {
  storage: "s3",
  s3Config: {
    region: "us-west-1",
  },
  s3Bucket: "photonify",
});

Example App

  • You can see a working example application that uses Express JS here.
  • This example uses the Multer plugin to access multipart file data.

FAQs

Package last updated on 29 Jan 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc