Implement This Filter

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Implement This Filter

Post 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".
snibgo's IM pages: im.snibgo.com
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post 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 ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Implement This Filter

Post by snibgo »

Huh? You really want to type them at the command prompt? Just type them, but change every "%%" to "%". Good luck with that.
snibgo's IM pages: im.snibgo.com
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post 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 ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Implement This Filter

Post 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?
snibgo's IM pages: im.snibgo.com
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post 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
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post 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 ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Implement This Filter

Post 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
snibgo's IM pages: im.snibgo.com
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Implement This Filter

Post 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.)
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Implement This Filter

Post 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.
Last edited by fmw42 on 2013-11-03T16:22:57-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Implement This Filter

Post by snibgo »

That's a heroic effort, fmw. The Windows version looks and works fine.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Implement This Filter

Post 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.
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post 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 ?
johnthomas1433
Posts: 16
Joined: 2013-11-02T06:35:23-07:00
Authentication code: 6789

Re: Implement This Filter

Post 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
Post Reply