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

image-contrast

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-contrast - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

21

index.js

@@ -1,3 +0,2 @@

function getImageData(context, selector) {
function getImageElement(selector) {
var element = document.querySelectorAll(selector)[0];

@@ -9,2 +8,7 @@

return element;
}
function getImageData(context, element) {
if (element.tagName !== 'IMG') {

@@ -57,2 +61,3 @@ throw new Error('image-contrast:: invalid origin');

* @param {object} options
* @param {string} options.url - image url
* @param {string} options.imageData - data of a image extracted from a canvas

@@ -64,2 +69,3 @@ * @param {string} options.from - dom selector of the original image

module.exports = function contrastImage(options) {
var element;
var data;

@@ -70,10 +76,15 @@ var factor

if (!options || !options.contrast || (!options.imageData && !options.from)) {
if (!options || !options.contrast || (!options.url && !options.imageData && !options.from)) {
throw new Error('image-contrast:: invalid options object');
}
if (options.imageData) {
if (options.url) {
element = document.createElement('img');
element.setAttribute('src', options.url);
data = getImageData(context, element);
} else if (options.imageData) {
data = options.imageData;
} else if (options.from) {
data = getImageData(context, options.from);
element = getImageElement(options.from);
data = getImageData(context, element);
}

@@ -80,0 +91,0 @@

{
"name": "image-contrast",
"version": "0.0.2",
"version": "0.0.3",
"description": "Small library to apply a contrast transformation to a image",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -36,2 +36,4 @@ # image-contrast

```js
var imageContrast = require('image-contrast');
var canvas = document.createElement('canvas');

@@ -59,1 +61,12 @@ var context = canvas.getContext('2d');

```
### From image url:
```js
var imageContrast = require('image-contrast');
imageContrast({
url: "http://lorempixel.com/400/200",
to: '#target-5',
contrast: 30
});
```
var imageContrast = require('../index');
window.onload = function () {
//Usage 1:
imageContrast({

@@ -16,2 +18,3 @@ from: '#original',

//Usage 2:
var canvas = document.createElement('canvas');

@@ -41,2 +44,14 @@ var context = canvas.getContext('2d');

//Usage 3:
imageContrast({
url: "http://lorempixel.com/400/200",
to: '#target-5',
contrast: 30
});
imageContrast({
url: "http://lorempixel.com/400/200",
to: '#target-6',
contrast: 70
});
}

Sorry, the diff of this file is not supported yet

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