Page 1 of 3

Blurred border using Mogrify

Posted: 2008-09-23T07:44:26-07:00
by ellocomateo
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

Re: Blurred border using Mogrify

Posted: 2008-09-23T09:40:34-07:00
by fmw42
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/

Re: Blurred border using Mogrify

Posted: 2008-09-23T09:55:46-07:00
by ellocomateo
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?

Re: Blurred border using Mogrify

Posted: 2008-09-23T12:17:38-07:00
by fmw42
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.

Re: Blurred border using Mogrify

Posted: 2008-09-23T22:32:35-07:00
by anthony
The convert command can to composition as well.
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.
See IM examples, Basics, Mogrify for more information and methods to use convert to process multiple images in the same way that mogrify does.

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
Image
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.

Re: Blurred border using Mogrify

Posted: 2008-09-23T22:46:09-07:00
by ellocomateo
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

Re: Blurred border using Mogrify

Posted: 2008-09-26T07:36:17-07:00
by ellocomateo
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

Re: Blurred border using Mogrify

Posted: 2008-09-26T10:34:52-07:00
by fmw42
there are differences for Windows!

see:

http://www.imagemagick.org/Usage/api/#windows

Re: Blurred border using Mogrify

Posted: 2008-09-26T11:51:30-07:00
by ellocomateo
Thank you very much!!

Re: Blurred border using Mogrify

Posted: 2008-09-28T22:44:33-07:00
by anthony
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.

Re: Blurred border using Mogrify

Posted: 2009-04-16T00:22:08-07:00
by kilowatt
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 8)

Re: Blurred border using Mogrify

Posted: 2009-04-16T09:30:52-07:00
by fmw42
It would help if we could see you command line in order to find your problem

Re: Blurred border using Mogrify

Posted: 2009-04-16T10:11:58-07:00
by kilowatt
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

Re: Blurred border using Mogrify

Posted: 2009-04-16T12:05:50-07:00
by fmw42
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

Re: Blurred border using Mogrify

Posted: 2009-04-16T12:57:58-07:00
by kilowatt
i'm on mac os. i need the \\ because the command gets called from applescript.