What happens when a channel gets separated?

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: What happens when a channel gets separated?

Post by snibgo »

Wikipedia shows the same process as IM "-separate":

Code: Select all

for (var i = 0; i < data.length; i += 4) {
    var grayscale = data[i];
    data[i]     = grayscale; // red
    data[i + 1] = grayscale; // green
    data[i + 2] = grayscale; // blue
}
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: What happens when a channel gets separated?

Post by fmw42 »

OK. So your javascript needs all 3 channels the same. But where do you save the file to disk and in what format?
baxter stockman
Posts: 16
Joined: 2015-07-31T12:35:27-07:00
Authentication code: 1151

Re: What happens when a channel gets separated?

Post by baxter stockman »

I post it back to the canvas and then save it as a png:

Code: Select all

var dataURL = canvas.toDataURL('image/png');
baxter stockman
Posts: 16
Joined: 2015-07-31T12:35:27-07:00
Authentication code: 1151

Re: What happens when a channel gets separated?

Post by baxter stockman »

@snibgo: so does that mean a channel separation is just taking one value and then using the same value for all three channels?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: What happens when a channel gets separated?

Post by snibgo »

Yes.
snibgo's IM pages: im.snibgo.com
Post Reply