Scaling just one channel
Scaling just one channel
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!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Scaling just one channel
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.
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
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?
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: Scaling just one channel
( and ) have to be escaped to \( and \) on Linux, % must be escaped to %% in Windows batch files. Line continuation is \ on Linux, ^ on Windows.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Scaling just one channel
see Using IM on Windows, DOS scripts...
http://www.imagemagick.org/Usage/windows/#scripts
http://www.imagemagick.org/Usage/windows/#scripts
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Scaling just one channel
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.
[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
Try putting the distort options within " " e.g. -distort SRT "1.01 0"
Re: Scaling just one channel
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.
[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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Scaling just one channel
What IM version and platform are you using? Is it old? Are directories set up for the write permission?
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: Scaling just one channel
What does result do? It reads like an input file, but this doesn't look like your intent.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"'
/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
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.
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.