Page 2 of 3

Re: Implement This Filter

Posted: 2013-11-02T18:57:22-07:00
by snibgo
These are all Windows "bat" commands, not bash. Paste them into a file and execute it. For example, paste into a file called "hello.bat" than at the command line type "hello".

Re: Implement This Filter

Posted: 2013-11-02T20:07:41-07:00
by johnthomas1433
snibgo wrote:These are all Windows "bat" commands, not bash. Paste them into a file and execute it. For example, paste into a file called "hello.bat" than at the command line type "hello".
Yes. I meant bat. How to implement it at command prompt ?

Re: Implement This Filter

Posted: 2013-11-02T20:38:29-07:00
by snibgo
Huh? You really want to type them at the command prompt? Just type them, but change every "%%" to "%". Good luck with that.

Re: Implement This Filter

Posted: 2013-11-02T21:40:33-07:00
by johnthomas1433
As a matter of fact, I did try it, but its not working..

Code: Select all

    
FOR /F "usebackq" %L IN (`identify -format "WIDTH=%w\nHEIGHT=%h" e.jpg`) DO set %L
FOR /F %i IN ('identify -ping -format "%[fx:max(%WIDTH%,%HEIGHT%)]" xc:') DO set MAX=%i
FOR /F %i IN ('identify -ping -format "%[fx:int(%MAX%*sqrt(2)+0.5)]" xc:') DO set DIM=%i
convert -size %DIM%x%DIM% radial-gradient:  -gravity Center -crop %MAX%x%MAX%+0+0 +repage -resize "%WIDTH%x%HEIGHT%^!" vig_mask.png
Its giving me errors as shown below.
Image

What am I doing wrong ?

Re: Implement This Filter

Posted: 2013-11-02T23:28:01-07:00
by snibgo
Pasting those commands into a command window works fine for me.

Code: Select all

D:\web\im>    FOR /F "usebackq" %L IN (`identify -format "WIDTH=%w\nHEIGHT=%h" e.jpg`) DO set %L

D:\web\im>set WIDTH=334

D:\web\im>set HEIGHT=334

D:\web\im>    FOR /F %i IN ('identify -ping -format "%[fx:max(%WIDTH%,%HEIGHT%)]" xc:') DO set MAX=%i

D:\web\im>set MAX=334

D:\web\im>    FOR /F %i IN ('identify -ping -format "%[fx:int(%MAX%*sqrt(2)+0.5)]" xc:') DO set DIM=%i

D:\web\im>set DIM=472

D:\web\im>    convert -size %DIM%x%DIM% radial-gradient:  -gravity Center -crop%MAX%x%MAX%+0+0 +repage -resize "%WIDTH%x%HEIGHT%^!" vig_mask.png
The values for WIDTH, HEIGHT, MAX and DIM will depend on your source file (effect.jpg). I used the left-hand square of the image you supplied.

You are, I hope, getting values for WIDTH etc? If not, did you run the first command I put on this thread?

Re: Implement This Filter

Posted: 2013-11-03T00:12:36-07:00
by johnthomas1433
snibgo wrote:Pasting those commands into a command window works fine for me.

Code: Select all

D:\web\im>    FOR /F "usebackq" %L IN (`identify -format "WIDTH=%w\nHEIGHT=%h" e.jpg`) DO set %L

D:\web\im>set WIDTH=334

D:\web\im>set HEIGHT=334

D:\web\im>    FOR /F %i IN ('identify -ping -format "%[fx:max(%WIDTH%,%HEIGHT%)]" xc:') DO set MAX=%i

D:\web\im>set MAX=334

D:\web\im>    FOR /F %i IN ('identify -ping -format "%[fx:int(%MAX%*sqrt(2)+0.5)]" xc:') DO set DIM=%i

D:\web\im>set DIM=472

D:\web\im>    convert -size %DIM%x%DIM% radial-gradient:  -gravity Center -crop%MAX%x%MAX%+0+0 +repage -resize "%WIDTH%x%HEIGHT%^!" vig_mask.png
The values for WIDTH, HEIGHT, MAX and DIM will depend on your source file (effect.jpg). I used the left-hand square of the image you supplied.

You are, I hope, getting values for WIDTH etc? If not, did you run the first command I put on this thread?
Width and Height are getting set. But MAX and DIM are not getting set

Re: Implement This Filter

Posted: 2013-11-03T00:18:02-07:00
by johnthomas1433
I dont know what happened, but its working now. I can generate the vignette mask. Thanks!
Is there a way to use this vignette mask in the original image without having to save it to vig_mask.png ?

Re: Implement This Filter

Posted: 2013-11-03T00:38:36-07:00
by snibgo
Yes. The two convert commands can be combined:

Code: Select all

"%IM%convert" ^
  e.jpg ^
  ( -clone 0 -modulate 100,0,100 ) ^
  ( -size %DIM%x%DIM% ^
    radial-gradient: ^
    -gravity Center -crop %MAX%x%MAX%+0+0 +repage ^
    -resize "%WIDTH%x%HEIGHT%^!" -negate -write mpr:VIG_MASK -level 50%%,95%% ^
  ) ^
  -composite ^
  ( -clone 0 -modulate 90,100,100 ) ^
  ( mpr:VIG_MASK -level 60%%,100%% ) ^
  -composite ^
  e3.png

Re: Implement This Filter

Posted: 2013-11-03T00:50:55-07:00
by johnthomas1433
I just tried this code, and I'm getting the original image as the output (without any vignette or any modifications)

Code: Select all

convert e.jpg ( -clone 0 -modulate 100,0,100 ) ( -size %DIM%x%DIM% radial-gradient: -gravity Center -crop %MAX%x%MAX%+0+0 +repage -resize "%WIDTH%x%HEIGHT%^!" -negate -write mpr:VIG_MASK -level 50%,95% ) -composite ( -clone 0 -modulate 90,100,100 ) ( mpr:VIG_MASK -level 60%,100% ) -composite e3.png
The entire command is written in a single line. I'm not getting any errors either. Just that no effect is being applied.

Re: Implement This Filter

Posted: 2013-11-03T06:42:03-07:00
by snibgo
Pasting your command into a command window works for me.

What values do you have for WIDTH, HEIGHT, DIM and MAX? Please post e.jpg and e3.png. (Put them somewhere like dropbox.com and paste the URLs here.)

Re: Implement This Filter

Posted: 2013-11-03T15:46:26-07:00
by fmw42
Here is my conversion of the PS tutorial into IM commands. Note this is limited to a square image of the size of the car image. For other square sizes, the circle arguments must be modified accordingly. For non-square image, replace the circle with an ellipse.

Image

Unix

Code: Select all

convert car.jpg \
\( +clone -level 10x100% \) \
\( -clone 0 -fill black -colorize 100 -fill white -draw "circle 160,160 320,160" -blur 0x50 \) \
\( -clone 2 -negate -clone 1 -clone 0 -reverse  -compose over -composite \) -delete 0,1 \
\( +clone -level 0x90% \) \
\( -clone 1 -clone 2 -clone 0 -compose over -composite \) -delete 1,2 \
\( +clone -colorspace sRGB -intensity rec709luminance -colorspace gray -set colorspace RGB -colorspace sRGB \
    +level-colors "#3a0a59","#fea957" -level 5x85% -alpha set -channel a -evaluate set 70% +channel \) \
\( -clone 1 -clone 2 -clone 0 -compose over -composite \) -delete 0,1,2 \
\( +clone -fill "#1b1b1b" -colorize 100 -alpha set -channel a -evaluate set 70% +channel +clone +swap \
    -compose screen -composite \) \
\( +clone -fill "#d29901" -colorize 100 -alpha set -channel a -evaluate set 50% +channel +clone +swap \
    -compose colordodge -composite \) \
\( -clone 0 -fill black -colorize 100 -fill white -draw "circle 160,160 290,160" -blur 0x50 \) \
 -delete 0 -alpha off -compose over -composite car_toaster.jpg
Windows (please correct if in error)

Code: Select all

convert car.jpg ^
( +clone -level 10x100%% ) ^
( -clone 0 -fill black -colorize 100 -fill white -draw "circle 160,160 320,160" -blur 0x50 ) ^
( -clone 2 -negate -clone 1 -clone 0 -reverse  -compose over -composite ) -delete 0,1 ^
( +clone -level 0x90%% ) ^
( -clone 1 -clone 2 -clone 0 -compose over -composite ) -delete 1,2 ^
( +clone -colorspace sRGB -intensity rec709luminance -colorspace gray -set colorspace RGB -colorspace sRGB ^
    +level-colors "#3a0a59","#fea957" -level 5x85%% -alpha set -channel a -evaluate set 70%% +channel ) ^
( -clone 1 -clone 2 -clone 0 -compose over -composite ) -delete 0,1,2 ^
( +clone -fill "#1b1b1b" -colorize 100 -alpha set -channel a -evaluate set 70%% +channel +clone +swap ^
    -compose screen -composite ) ^
( +clone -fill "#d29901" -colorize 100 -alpha set -channel a -evaluate set 50%% +channel +clone +swap ^
    -compose colordodge -composite ) ^
( -clone 0 -fill black -colorize 100 -fill white -draw "circle 160,160 290,160" -blur 0x50 ) ^
-delete 0 -alpha off -compose over -composite car_toaster.jpg

Image


I will build a script for this shortly.

Re: Implement This Filter

Posted: 2013-11-03T16:03:38-07:00
by snibgo
That's a heroic effort, fmw. The Windows version looks and works fine.

Re: Implement This Filter

Posted: 2013-11-03T16:13:34-07:00
by fmw42
snibgo wrote:That's a heroic effort, fmw. The Windows version looks and works fine.
Thanks. It did take a few hours to get it all working correctly. The tutorial was a little obscure for those not fully familiar with PS.

Re: Implement This Filter

Posted: 2013-11-03T19:55:26-07:00
by johnthomas1433
The windows versions does look good! Thanks!

So if I want to have this filter to be applied to various images of different sizes, how to go about it ?

Re: Implement This Filter

Posted: 2013-11-03T20:04:19-07:00
by johnthomas1433
snibgo wrote:Pasting your command into a command window works for me.
What values do you have for WIDTH, HEIGHT, DIM and MAX? Please post e.jpg and e3.png. (Put them somewhere like dropbox.com and paste the URLs here.)
e.jpg
Image

e3.jpg
Image

Windows command
Image