Replicating Photoshop's filters and adjustments in code

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
Stefan Monov
Posts: 1
Joined: 2017-01-11T14:26:56-07:00
Authentication code: 1151

Replicating Photoshop's filters and adjustments in code

Post by Stefan Monov »

Ok, I realize this is a really broad topic, but I thought: why not? This is not StackOverflow where broad topics or topics asking for links are closed.

Do you know of a resource with descriptions of how to implement the various Photoshop filters and adjustments? Or just plain has implementations of them?

E.g. Chrome filter; Black and White adjustment.

I'm not asking for the blend modes because descriptions and implementations of those are easily found on the web.

There's pieces of info here and there, e.g. see:
But it's too little, too scattered and often wrong.

Even if it's not a single resource, I'd appreciate links to sites that explain that stuff for even just one or several Photoshop filters/adjs.

And just to bring something to the table myself:

The PS "Photo filter" adjustment is implemented like this (pseudocode):

Code: Select all

Image photoFilter(Image src, RGB tint, bool preserveLuminance) {
	Image muld = blend(BLEND_MULTIPLY, src, tint);
	if(preserveLuminance) {
		return blend(BLEND_LUMINANCE, muld, src);
	} else {
		return muld;
	}
}
... where, of course, blend(BLEND_LUMINANCE...) is implemented with the HCL colorspace as implemented in ImageMagick.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Replicating Photoshop's filters and adjustments in code

Post by fmw42 »

I have tried to reverse engineer a few as unix shell scripts with Imagemagick. You can find my scripts at my link below. But I know of no comprehensive resource, since photoshop is a closed tool and I know of no explanations of the details of their code. A google search sometimes will come up with tutorials on how to do some specific filter. That is the resource from which I started some of my attempts. With other filters, I just played around with the PS controllers and some understanding of what might be going on to make an attempt to reproduce similar results.
ivanhoe90
Posts: 4
Joined: 2017-07-26T16:08:36-07:00
Authentication code: 1151

Re: Replicating Photoshop's filters and adjustments in code

Post by ivanhoe90 »

Hi, I am making a program www.Photopea.com, which should have the full support for PSD files. And since PSD files can have Adjustment layers and Smart Filters, I have to implement PS adjustments and filters, too.

I have been implementing PS adjustments and filters for several years now. You can see what I already have at Photopea.com .
Post Reply