Page 1 of 1

How to fade or feather the outer 20pixels to pure white

Posted: 2016-11-29T13:20:39-07:00
by tbayle
Starting with a jpg. I want to fade the last 20 pixels on all four edges to white, so when the image is presented on a white background web page you do not see the edge of the image. Need final output to also be jpg if possible.

Here's a link to a dropbox folder with an example image.

https://www.dropbox.com/sh/4mibp578dd4s ... V9Nia?dl=0

Re: How to fade or feather the outer 20pixels to pure white

Posted: 2016-11-29T14:13:11-07:00
by Bonzo
You could check out Anthony's examples

Re: How to fade or feather the outer 20pixels to pure white

Posted: 2016-11-29T14:15:05-07:00
by snibgo
@tbayle: Your link is broken.

See the recent thread viewtopic.php?f=1&t=30917

Re: How to fade or feather the outer 20pixels to pure white

Posted: 2016-11-30T05:47:32-07:00
by tbayle
Not sure what happened to the dropbox link but here's the full address.

https://www.dropbox.com/sh/4mibp578dd4s ... V9Nia?dl=0

Re: How to fade or feather the outer 20pixels to pure white

Posted: 2016-11-30T09:30:22-07:00
by GeeMack
tbayle wrote:Starting with a jpg. I want to fade the last 20 pixels on all four edges to white, so when the image is presented on a white background web page you do not see the edge of the image. Need final output to also be jpg if possible.
If you want a 20 pixel fade to white on all the edges of your image, you can create a 20 pixel high strip that fades from white to none, then composite that over all four edges of the original. A command like this (with IM 6.9.6 on Windows) will take any size input image...

Code: Select all

convert input.jpg gradient:white-none[1x20!] -background none -virtual-pixel edge ^
   ( -clone 0 -crop x20+0+0 ) ( -clone 0 -crop 20x+0+0 -rotate 90 ) ^
   ( -clone 1-3 +append -distort affine "0,0 %[w],0" )^
   ( -clone 0,4 -composite -rotate 90 -clone 4 -composite -rotate 90 ^
      -clone 4 -composite -rotate 90 -clone 4 -composite -rotate 90 ) ^
   -delete 0--2 -quality 100 output.jpg
It creates a 20 pixel high overlay, longer than either the width or height of the input image, that fades from white to transparent. Then it composites that overlay strip over each edge of the image, one side at a time, by rotating the input and applying the overlay until all four sides are done. Every side of the resulting image fades across exactly 20 pixels and ends in pure white at the outer edge.

If you have a lot of images to process you can use a command like that in a "for" loop.

Re: How to fade or feather the outer 20pixels to pure white

Posted: 2016-11-30T12:09:30-07:00
by tbayle
I copied your code and created a batch file, but received errors when I ran it.

1. must specify image size 'white-none' @ error/gradient.c/ReadGRADIENTImage/116.
2. invalid argument for option Affine: 'require at least 1 CPs' @ error/distort.c/GenerateCoefficients/466.
3. no such image '-clone' @ error/convert.c/ConvertImageCommand/940.

Also tried doubling up on the % being I'm running it from a batch file but still failed. Running 6.7.2 on windows.

Code: Select all

convert input.jpg gradient:white-none[1x20!] -background none -virtual-pixel edge ^
   ( -clone 0 -crop x20+0+0 ) ( -clone 0 -crop 20x+0+0 -rotate 90 ) ^
   ( -clone 1-3 +append -distort affine "0,0 %[w],0" )^
   ( -clone 0,4 -composite -rotate 90 -clone 4 -composite -rotate 90 ^
      -clone 4 -composite -rotate 90 -clone 4 -composite -rotate 90 ) ^
   -delete 0--2 -quality 100 output.jpg