3.0.10 • Published 3 months ago

photonify v3.0.10

Weekly downloads
1
License
ISC
Repository
github
Last release
3 months ago

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:

const imageBuffer = req.file.buffer;

const result = await photonify.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:

const imageBuffer = req.file.buffer;

const result = await photonify.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 Name: String - Required
  • storage: String - Required
  • s3Config: any - Required details here
  • s3Bucket: String - Required

Example:

await photonify.remove("somefile.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.
3.0.10

3 months ago

3.0.8

3 months ago

3.0.7

3 months ago

3.0.9

3 months ago

3.0.4

3 months ago

3.0.3

3 months ago

3.0.2

3 months ago

3.0.1

3 months ago

3.0.6

3 months ago

3.0.5

3 months ago

3.0.0

3 months ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago