Page 1 of 1
Scaling just one channel
Posted: 2010-12-08T10:45:05-07:00
by b3and1p
Hi everyone. I want to create a chromatic aberration effect in IM. I want to scale the blue channel and the green channel from the center at different amounts, how would I go about doing this? For instance lets say I want to scale the blue channel 2% and the green channel 1% while leaving the red channel untouched. Can this be done in one command? Thanks guys!
Re: Scaling just one channel
Posted: 2010-12-08T10:58:09-07:00
by fmw42
See clones and parenthesis process at
http://www.imagemagick.org/Usage/basics/#parenthesis
convert image -channel rgb -separate \
\( -clone 1 -distort SRT "1.01 0" \) \
\( -clone 2 -distort SRT "1.02 0" \) \
-delete 1-2 -combine result
This shows little change, but if you exaggerate the scaling to say 1.1 and 1.2, then you can see the changes very well.
So, the above seems to work OK; whereas using -resize in place of -distort SRT gives an error about the images that are to be combined are not the same size.
Re: Scaling just one channel
Posted: 2010-12-09T13:29:36-07:00
by b3and1p
Do you have to put the first "\" characters in there for it to work? Or is that just so you can have a new line?
Re: Scaling just one channel
Posted: 2010-12-09T13:34:46-07:00
by GreenKoopa
( and ) have to be escaped to \( and \) on Linux, % must be escaped to %% in Windows batch files. Line continuation is \ on Linux, ^ on Windows.
Re: Scaling just one channel
Posted: 2010-12-09T16:09:32-07:00
by anthony
Re: Scaling just one channel
Posted: 2010-12-10T14:13:52-07:00
by b3and1p
I got this error in my log. Do I have the wrong version of IM installed? Did I format something incorrectly?
[2010-12-10T16:29:34+00:00] Executing '/usr/local/bin/convert imageA.jpg -channel rgb -separate \( -clone 1 -distort SRT 1.01 0 \) \( -clone 2 -distort SRT 1.02 0 \) -delete 1-2 -combine result -quality 100 "/home/test/public_html/ImageB.jpg"'
[2010-12-10T16:30:12+00:00] Return error. Output:
[2010-12-10T16:30:12+00:00]
Errors:
convert: unable to open image `0': @ error/blob.c/OpenBlob/2584.
convert: no decode delegate for this image format `0' @ error/constitute.c/ReadImage/532.
convert: unable to open image `0': @ error/blob.c/OpenBlob/2584.
convert: no decode delegate for this image format `0' @ error/constitute.c/ReadImage/532.
convert: unable to open image `result': @ error/blob.c/OpenBlob/2584.
convert: no decode delegate for this image format `result' @ error/constitute.c/ReadImage/532.
Re: Scaling just one channel
Posted: 2010-12-10T14:28:24-07:00
by Bonzo
Try putting the distort options within " " e.g. -distort SRT "1.01 0"
Re: Scaling just one channel
Posted: 2010-12-11T09:10:00-07:00
by b3and1p
Hmm, still not working.
[2010-12-11T16:06:04+00:00] Executing '/usr/local/bin/convert imageA.jpg -channel rgb -separate \( -clone 1 -distort SRT "1.01 0" \) \( -clone 2 -distort SRT "1.02 0" \) -delete 1-2 -combine result -quality 100 "/home/test/public_html/imageB.jpg"'
[2010-12-11T16:06:07+00:00] Return error. Output:
[2010-12-11T16:06:07+00:00]
Errors:
convert: unable to open image `result': @ error/blob.c/OpenBlob/2584.
convert: no decode delegate for this image format `result' @ error/constitute.c/ReadImage/532.
Re: Scaling just one channel
Posted: 2010-12-11T10:21:15-07:00
by fmw42
What IM version and platform are you using? Is it old? Are directories set up for the write permission?
Re: Scaling just one channel
Posted: 2010-12-11T11:19:21-07:00
by GreenKoopa
b3and1p wrote:Hmm, still not working.
[2010-12-11T16:06:04+00:00] Executing '/usr/local/bin/convert imageA.jpg -channel rgb -separate \( -clone 1 -distort SRT "1.01 0" \) \( -clone 2 -distort SRT "1.02 0" \) -delete 1-2 -combine result -quality 100 "/home/test/public_html/imageB.jpg"'
What does
result do? It reads like an input file, but this doesn't look like your intent.
/usr/local/bin/convert imageA.jpg -channel rgb -separate \( -clone 1 -distort SRT "1.01 0" \) \( -clone 2 -distort SRT "1.02 0" \) -delete 1-2 -combine
result -quality 100 "/home/test/public_html/imageB.jpg"
Re: Scaling just one channel
Posted: 2010-12-11T12:13:35-07:00
by b3and1p
Yea I am dumb! I didn't realise "result" was the output because I didn't see a .png. Sorry, stupid mistake on my part.
And this works! I wanted a subtle effect. here is what it looks like:
http://placesnapdev02.s3.amazonaws.com/ ... 2de1_o.jpg
here it is without that effect:
http://placesnapdev02.s3.amazonaws.com/ ... 4748_o.jpg
You can really see it towards the edges of the picture. Thanks guys! I ended up using 1.005 and 1.01. I wanted it to be really subtle like a real chromatic aberration.