You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not quite sure if the title is accurate to Sharp's internal algorithm, but joinChanneldoes appear to exhibit an unusual behavior at least somewhere.
As a very simple example to reproduce, I'm extracting all 4 channels as raw from a colorful PNG, then joining those channels into a new instance of image. The expected result should be 1:1 duplicate of the original.
importsharpfrom'sharp';constorig=sharp('./colors.png');// decompose into individual RGBA channel values// concept taken from https://github.com/lovell/sharp/issues/1757#issuecomment-503653509constchannels=['red','green','blue','alpha'];constdecompose=channels.map(channel=>orig.extractChannel(channel).raw().toBuffer());const[r,g,b,a]=awaitPromise.all(decompose);// copy dimensions from originalconst{ info }=awaitorig.toBuffer({resolveWithObject: true});constmetadata={raw: {
...info,channels: 1,background: 'transparent'}};// join/compose all 4 decomposed channels to create an original-alikeconstdupe=sharp(r,metadata).joinChannel([g,b,a],metadata);// exportdupe.toFile('./colors-dupe.png');
Things seem to appear nice and fine until this point - the export is still 1:1 with the original. However, any further manipulation on the dupe from here on, will result in only the red channel being affected. As an example, rotating by 90 degrees:
And if not that then, by extension, would it be possible to somewhat work this around using the composite method? Not trying to be troublesome or anything, just looking for different perspectives to achieve things 🙂
I'm not quite sure if the title is accurate to Sharp's internal algorithm, but
joinChannel
does appear to exhibit an unusual behavior at least somewhere.As a very simple example to reproduce, I'm extracting all
4
channels asraw
from a colorful PNG, then joining those channels into a new instance of image. The expected result should be 1:1 duplicate of the original.Things seem to appear nice and fine until this point - the export is still 1:1 with the original. However, any further manipulation on the
dupe
from here on, will result in only thered
channel being affected. As an example, rotating by 90 degrees:This is my exact concern, as one would normally expect all 4 channels being manipulated as a whole.
In order to verify it's only the
red
channel being manipulated:colors-dupe.png
in GIMP.Channels
panel (next toLayers
panel).red
.red
channel appears rotated by 90 degrees.The text was updated successfully, but these errors were encountered: