jimp-dev/jimp

I tried to add instagram filters from this code

Open

#1,015 opened on May 19, 2021

View on GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (785 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (13,218 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Hi I tried these instagram filter from this source code

https://github.com/girliemac/filterous-2/blob/master/lib/instaFilters.js#L135

I think you need to add these two function

	rgbAdjust: function rgbAdjust(rgbAdj,cb) {
		this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
			var red = this.bitmap.data[idx];
			var green = this.bitmap.data[idx + 1];
			var blue = this.bitmap.data[idx + 2];
			red *= rgbAdj[0]
			green *= rgbAdj[1]
			blue *= rgbAdj[2]
			this.bitmap.data[idx] = red < 255 ? red : 255;
			this.bitmap.data[idx + 1] = green < 255 ? green : 255;
			this.bitmap.data[idx + 2] = blue < 255 ? blue : 255;
		});

		if ((0, _utils.isNodePattern)(cb)) {
			cb.call(this, null, this);
		}

		return this;
	},

and

colorFilter: function colorFilter(rgbColor,cb) {
  this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
    var adj = rgbColor[3];
    var red = this.bitmap.data[idx];
    var green = this.bitmap.data[idx + 1];
    var blue = this.bitmap.data[idx + 2];
    red -= (red - rgbColor[0]) * adj;
    green  -= (green - rgbColor[1]) * adj;
    blue -= (blue - rgbColor[2]) * adj;
    this.bitmap.data[idx] = red < 255 ? red : 255;
    this.bitmap.data[idx + 1] = green < 255 ? green : 255;
    this.bitmap.data[idx + 2] = blue < 255 ? blue : 255;
  });

  if ((0, _utils.isNodePattern)(cb)) {
    cb.call(this, null, this);
  }

  return this;
},

in plugin color, it's help shorten image manipulation. and in sepia color filterous-2 has value to change sepia intensity

Contributor guide