jimp-dev/jimp

I tried to add instagram filters from this code

Open

#1015 aperta il 19 mag 2021

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)JavaScript (785 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (13.218 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor