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 Imagemagick.

  • 1.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Photonify

Photonify is a utility to manage multipart image uploads and automatically process them with Imagemagick. The plugin also supports S3 uploads.

Installation

npm install photonify

Usage

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

Parameters:

  • data: Buffer - Required
  • fileName: String - Required
  • fingerprint: Boolean
  • storage: String

Example:

const params = {
	data: req.files.photo.data,
	fileName: req.files.photo.name,
	fingerprint: true,
	storage: "s3"
};

photonify
.process(params)
.then((images) => {
	res.status(201).json(images);
});
Filesystem Storage:

Parameters:

  • data: Buffer - Required
  • fileName: String - Required
  • dest: String - Required
  • fingerprint: Boolean
  • storage: String

Example:

const params = {
	data: req.files.photo.data,
	fileName: req.files.photo.name,
	dest: "./public/images",
	fingerprint: true,
	storage: "filesystem"
};

photonify
.process(params)
.then((images) => {
	res.status(201).json(images);
});

Using S3

  • Note: If you want to use S3 the plugin makes the assumption that you have the following three environment variables set up:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_BUCKET_NAME
  • You can read more about getting these values from the AWS access keys documentation.
  • A good plugin for setting up these environment variables is called dotenv.

Removing Files

  • Photonify has support for removing files from the filesystem or S3 as well.
Removing S3 Files:

Parameters:

  • keys: Array - Required
  • storage: String - Required

Example:

photonify.remove({
	keys: [photo.photo_large_key, photo.photo_medium_key, photo.photo_small_key],
	storage: "s3"
})
.then((result) => {
	photo
	.destroy()
	.then(() => {
		res.sendStatus(200);
	})
	.catch((err) => {
		res
		.status(400)
		.json(err);
	});
});
Removing Filesystem Files:

Parameters:

  • keys: Array - Required
  • storage: String - Required
  • source: String - Required

Example:

photonify.remove({
	keys: [photo.photo_large_key, photo.photo_medium_key, photo.photo_small_key],
	storage: "filesystem",
	source: __dirname + "/images"
})
.then((result) => {
	photo
	.destroy()
	.then(() => {
		res.sendStatus(200);
	})
	.catch((err) => {
		res
		.status(400)
		.json(err);
	});
});

Example App

  • You can see a working example application that uses express here.
  • This example uses the express-fileupload plugin to access multipart file data.

FAQs

Package last updated on 13 Feb 2017

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