Page 1 of 1

composite -blur results in black area

Posted: 2013-07-03T08:55:36-07:00
by horen
I am composing an image from two input images - one with text and one background image.
When using the composite -blur option I get black areas to the right and to the bottom of the overlaying text. Example here:

Image


This is my imagemagick command:

Code: Select all

composite -blur 400 -geometry +16+193 example.png background.jpg result.png
I have tried the repage and trim commands to avoid the black areas but that did not work.

Does anyone have a good tip for me?

Re: composite -blur results in black area

Posted: 2013-07-03T09:16:24-07:00
by snibgo
Have you tried it without "-geometry +16+193"? What do you want geometry to do?

Are example.png and background.jpg the same size?

Re: composite -blur results in black area

Posted: 2013-07-03T09:31:23-07:00
by fmw42
try the convert syntax. it is more current.

But note it must have a mask image. One image and a mask image and the output image. I am not sure it supports -geometry

see
http://www.imagemagick.org/Usage/mapping/#blur

Re: composite -blur results in black area

Posted: 2013-07-03T10:23:48-07:00
by horen
@snibgo: I use geometry to position the text layer on the background image.

I need this option since the positioning comes from a user input. I don't know how big the two images are.

@fmw42: That's the reason as well why I can't use the convert command.

Re: composite -blur results in black area

Posted: 2013-07-03T11:42:12-07:00
by snibgo
@horen: as fmw42 says, "composite -blur" needs a mask, which must be the same size as the other input image. If you don't need a mask, I suggest you don't use "composite", and certainly not "composite -blur".

As far as I know, "composite" can do nothing that "convert" can't do.

Re: composite -blur results in black area

Posted: 2013-07-03T12:16:33-07:00
by fmw42
I am not sure why you want to use -compose blur. It looks like you just want to overlay text onto a background image. That can be done without -compose blur, just using -compose over. If you need the text to be blurred or the background blurred, then blur those images first and then compose them. That can all be done in one convert command such as

convert backgroundimage \( textimage -blur 0xbluramt \) -geometry ... -compose over -composite result

That assumes you want to blur the textimage and it has transparency so that you only see the text and not the full background of the textimage.


see
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/compose/#over

Re: composite -blur results in black area

Posted: 2013-07-03T14:12:18-07:00
by horen
Well I wanted to use it for a script in the same context as the other -compose options like e.g. hard-light (see http://www.imagemagick.org/script/compose.php) - so in the same syntax and order:

Code: Select all

-compose blur 400
instead of

Code: Select all

-compose hard-light
Your proposal to blur the image before overlaying is a workaround, doesn't solve or explain my inital problem though.

Re: composite -blur results in black area

Posted: 2013-07-03T14:52:32-07:00
by fmw42
-compose blur is a very unique compose method designed for one thing. You cannot use it in the same context as all the other compose methods. -compose blur requires one image only and one same size mask. The other compose methods use two images (a background and a foreground which can be of different sizes) and an optional mask generally used when the foreground, background and mask images are all the same size.

Re: composite -blur results in black area

Posted: 2013-07-03T15:02:50-07:00
by snibgo
@horen: If you explain what you are trying to do, we can suggest ways of doing it. Ideally, if you supply source images, we can test exact commands rather than general principles.

Re: composite -blur results in black area

Posted: 2013-07-04T02:43:23-07:00
by horen
@snibgo: Like the other compose methods (linear-burn, multiply, difference, etc.) I would like to offer blur as a "blending effect option" for the user.
You can find the source images here:
Text: http://imgur.com/uEzr12x,dGZX7sG#0
Background: http://imgur.com/uEzr12x,dGZX7sG#1


@fmw42: I have thought about your proposal to first blur and then overlay the text but I don't think that would actually blur since the blur depends on the background (see my example image in the first post)

Re: composite -blur results in black area

Posted: 2013-07-04T08:21:13-07:00
by snibgo
Okay. I'm not sure exactly what a blur blending effect option would look like. Possibilities include:

1. Blur the black text and place it over the background.

Code: Select all

convert ^
  background.jpg ^
  ( text.png -blur 0x2 -geometry +16+193 ) ^
  -compose Over -composite b1.jpg
2. Blur the background, then place the black text over it.

Code: Select all

convert ^
  ( background.jpg -blur 0x5 ) ^
  ( text.png -geometry +16+193 ) ^
  -compose Over -composite b2.jpg
3. Blur the background where the letters are, and leave the rest of the background alone.

Code: Select all

convert ^
  background.jpg ^
  ( +clone -blur 0x10 ) ^
  ( +clone -fill White -colorize 100 ^
    ( text.png -geometry +16+193 ) ^
    -composite  ^
  ) ^
  -compose Over -composite b3.jpg
4. Blur the background except where the letters are.

Code: Select all

convert ^
  background.jpg ^
  ( +clone -blur 0x10 ) ^
  ( +clone -fill White -colorize 100 ^
    ( text.png -geometry +16+193 ) ^
    -composite  ^
    -negate ^
  ) ^
  -compose Over -composite b4.jpg
I have varied the degree of blurring so the words are always readable.

Windows script. This uses "^" for line continuation. Adjust for other languages.

Re: composite -blur results in black area

Posted: 2013-07-04T10:13:38-07:00
by fmw42
@fmw42: I have thought about your proposal to first blur and then overlay the text but I don't think that would actually blur since the blur depends on the background (see my example image in the first post)
You can achieve that by using a mask to control the blending of the text with the background. It is the same as putting the mask into the alpha channel of the text image.

Snibgo has covered all the non transparent options as we still do not know what part you want blurred

One simple way without blurring (though it can be added as per snibgo's examples)

convert background \( textimage -alpha set -channel A -evaluate set 50% +channel \) -geometry +16+193 -compose over -composite

This will blend the text equally with the background during the composition. You can control the blend amount by changing 50%. Larger values show more text and smaller values show more background.

If on windows leave off the two \ and make % into %%.