Blurred border using Mogrify
Blurred border using Mogrify
Hello,
I would like mogrify to provide me with such a frame around a photo:
http://www.flickr.com/photos/hvhe1/2595892962/
That is, the photo is blurred over 1 to 2cm on its edges, and the
blurred area is separated from the sharp image using a light user
defined color border of 2-3pixels.
Eventually, as an alternative, I would like to get the following:
- provided an image as input, mogrify would expand a copy of it so
that the copy is 2-4cm larger & higher.
- blur the copy
- built the final picture from the superposition of the original image
on top of the blurred image (with a 2-3 pixel border between the two)
Can somebody help me get the proper command lines please please
please?
Best regards,
Mathieu
I would like mogrify to provide me with such a frame around a photo:
http://www.flickr.com/photos/hvhe1/2595892962/
That is, the photo is blurred over 1 to 2cm on its edges, and the
blurred area is separated from the sharp image using a light user
defined color border of 2-3pixels.
Eventually, as an alternative, I would like to get the following:
- provided an image as input, mogrify would expand a copy of it so
that the copy is 2-4cm larger & higher.
- blur the copy
- built the final picture from the superposition of the original image
on top of the blurred image (with a 2-3 pixel border between the two)
Can somebody help me get the proper command lines please please
please?
Best regards,
Mathieu
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Blurred border using Mogrify
Do you have to use mogrify? It is much more limited in what it can do. The convert syntax is much more flexible.
What version is your IM?
There are a lot of bordering examples at http://www.imagemagick.org/Usage/crop/#frame
I have a script http://www.fmwconcepts.com/imagemagick/ ... /index.php that will put a picture frame around an image. Also in Anthony's Examples somewhere, he has an even better technique.
http://www.imagemagick.org/Usage/
What version is your IM?
There are a lot of bordering examples at http://www.imagemagick.org/Usage/crop/#frame
I have a script http://www.fmwconcepts.com/imagemagick/ ... /index.php that will put a picture frame around an image. Also in Anthony's Examples somewhere, he has an even better technique.
http://www.imagemagick.org/Usage/
Re: Blurred border using Mogrify
Hi!
Thanks for your reply!
I wanted to use mogrify since there is a Lightroom plugin which quite pleases me so far, as long as I wanted plain colored borders...
But I guess there is the possibility to use convert as well... it actually looks like I have to use composite as well...
And at the end, I'm almost faster/neater doing it directly into the GIMP!?
Should I use convert & composite, does that mean that I am going through 3 jpeg compressions? One to get the original, one for the blur version, and one for the final image? I spent a lot of time set up a workflow based on RAW to keep the sharpness as high as possible. Having to undergo so much lossy compression does not suit me.
Does anyone have any other suggestion?
Thanks for your reply!
I wanted to use mogrify since there is a Lightroom plugin which quite pleases me so far, as long as I wanted plain colored borders...
But I guess there is the possibility to use convert as well... it actually looks like I have to use composite as well...
And at the end, I'm almost faster/neater doing it directly into the GIMP!?
Should I use convert & composite, does that mean that I am going through 3 jpeg compressions? One to get the original, one for the blur version, and one for the final image? I spent a lot of time set up a workflow based on RAW to keep the sharpness as high as possible. Having to undergo so much lossy compression does not suit me.

Does anyone have any other suggestion?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Blurred border using Mogrify
If you do everything in one command line or if you use non-jpg temporaries (such as png or miff), you will not be compressing at each stage.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Blurred border using Mogrify
The convert command can to composition as well.
Mogrify however is basically a limited form of convert but
However I do have ideas to achieving these effects in IM v7 when development starts on this, by making "mogrify" a wrapper program for a "convert" command.
Anyway
In fact something similer to what your example shows is present in IM examples, in Thumbnails, Self Framing.
Hmmm in your case you don't want to enlarge the original image to create a blured frame. you just want to blur it directly.
Off the top of my head, here is a solution...

The first -composite creates a masked blurred and lighter border to the original image. The second overlays a frame around that border.
I'll add an example into IM examples at the 'self frame' section.
Mogrify however is basically a limited form of convert but
- saving images back into the source image file. Convert can do this to, you just save the image to the same file you read the image from
- mogrify does not allow direct use of multiple image sequence operators (like +clone, -composite, or -flatten) as it interfers with its handling of a 'list' of images to process.
However I do have ideas to achieving these effects in IM v7 when development starts on this, by making "mogrify" a wrapper program for a "convert" command.
Anyway
In fact something similer to what your example shows is present in IM examples, in Thumbnails, Self Framing.
Hmmm in your case you don't want to enlarge the original image to create a blured frame. you just want to blur it directly.
Off the top of my head, here is a solution...
Code: Select all
convert robin.jpg \( +clone -blur 10x4 -fill white -colorize 30% \) \
\( +clone -gamma 0 -shave 20x20 \
-bordercolor white -border 20x20 \) \
-composite \
\( +clone -gamma 0 -shave 20x20 \
-bordercolor white -border 2x2 \
-bordercolor black -border 18x18 \) \
-compose screen -composite \
robin_border.jpg

The first -composite creates a masked blurred and lighter border to the original image. The second overlays a frame around that border.
I'll add an example into IM examples at the 'self frame' section.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Blurred border using Mogrify
YES! Thank you very much! You kick started me on this issue!
I confess I did not read further the thumbnail section, since my aim was not to get thumbnail, but full size images...
I am looking forward to using the next version!
Best regards
Mathieu
I confess I did not read further the thumbnail section, since my aim was not to get thumbnail, but full size images...
I am looking forward to using the next version!

Best regards
Mathieu
Re: Blurred border using Mogrify
I actually have another question!
You proposed the following code:
convert robin.jpg \( +clone -blur 10x4 -fill white -colorize 30% \) \
\( +clone -gamma 0 -shave 20x20 \
-bordercolor white -border 20x20 \) \
-composite \
\( +clone -gamma 0 -shave 20x20 \
-bordercolor white -border 2x2 \
-bordercolor black -border 18x18 \) \
-compose screen -composite \
robin_border.jpg
Is the syntax the same under windows & linux?
What is the meaning exactly of the "\" at the end of line, should I write everything on a single line under windows?
I'll test it again, step by step, but I have some issue.
Help would be much appreciated!
Mathieu
You proposed the following code:
convert robin.jpg \( +clone -blur 10x4 -fill white -colorize 30% \) \
\( +clone -gamma 0 -shave 20x20 \
-bordercolor white -border 20x20 \) \
-composite \
\( +clone -gamma 0 -shave 20x20 \
-bordercolor white -border 2x2 \
-bordercolor black -border 18x18 \) \
-compose screen -composite \
robin_border.jpg
Is the syntax the same under windows & linux?
What is the meaning exactly of the "\" at the end of line, should I write everything on a single line under windows?
I'll test it again, step by step, but I have some issue.
Help would be much appreciated!
Mathieu
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Blurred border using Mogrify
Yes the command is for the environment I use.
Shell Scripts and UNIX command line.
The command style varies depending on your enviroment. DOS scripts has some very specific needs with quoting, percents and hats '^'.
PHP wraps, the shell script in an extra layer of quoting and API handling which can make it a nightmare.
Perl command line calls can simplify the call avoiding the need to call the shell at all. That reduces the change of some user input 'spoofing' the command for 'evil' purposes. But that then requires you to separate the options and arguments (usally on whitespace) yourself, instead of letting the shell do this.
Of course you also have other API interfaces when give you more control over the individual steps, and can handle multiple image sequences or in-memory databases of images, but at a cost of more programming, and less examples to follow. Usually though doing from command line first then converting to the direct API interface works well.
Shell Scripts and UNIX command line.
The command style varies depending on your enviroment. DOS scripts has some very specific needs with quoting, percents and hats '^'.
PHP wraps, the shell script in an extra layer of quoting and API handling which can make it a nightmare.
Perl command line calls can simplify the call avoiding the need to call the shell at all. That reduces the change of some user input 'spoofing' the command for 'evil' purposes. But that then requires you to separate the options and arguments (usally on whitespace) yourself, instead of letting the shell do this.
Of course you also have other API interfaces when give you more control over the individual steps, and can handle multiple image sequences or in-memory databases of images, but at a cost of more programming, and less examples to follow. Usually though doing from command line first then converting to the direct API interface works well.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Blurred border using Mogrify
Hi,
this command is almost perfect. I've altered to have a blurred frame of 30px around my images. But the frame 'crops' my images.
How can I place the original image inside the frame without loosing those 30px on each side?
I tried to play with the resize command but I could not figure out how to resize (enlarge) an image by a given amount of pixels.
thanks in advance
KW.
ps: Sorry for my english
this command is almost perfect. I've altered to have a blurred frame of 30px around my images. But the frame 'crops' my images.
How can I place the original image inside the frame without loosing those 30px on each side?
I tried to play with the resize command but I could not figure out how to resize (enlarge) an image by a given amount of pixels.
thanks in advance
KW.
ps: Sorry for my english

- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Blurred border using Mogrify
It would help if we could see you command line in order to find your problem
Re: Blurred border using Mogrify
my command line looks like this:
Code: Select all
convert image.jpg \\( +clone -blur 10x4 -fill white -colorize 30% \\) \\( +clone -gamma 0 -shave 30x30 -bordercolor white -border 30x30 \\) -composite \\( +clone -gamma 0 -shave 30x30 -bordercolor white -border 1x1 -bordercolor black -border 29x29 \\) -compose screen -composite image.jpg
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Blurred border using Mogrify
are you on unix or windows. if the latter, you don't need the \\ before parentheses. see http://www.imagemagick.org/Usage/api/#windows
with -shave, you probably need to add +repage. see http://www.imagemagick.org/Usage/crop/#shave
you may also want to use -geometry to specify any offsets. see http://www.imagemagick.org/Usage/compose/#geometry
http://www.imagemagick.org/Usage/layers/#convert
with -shave, you probably need to add +repage. see http://www.imagemagick.org/Usage/crop/#shave
you may also want to use -geometry to specify any offsets. see http://www.imagemagick.org/Usage/compose/#geometry
http://www.imagemagick.org/Usage/layers/#convert
Re: Blurred border using Mogrify
i'm on mac os. i need the \\ because the command gets called from applescript.