display -backdrop doesn't work as described in manual

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
archguest

display -backdrop doesn't work as described in manual

Post by archguest »

This is in connection with the issue I tried to post in user forum. Now I think it is either a bug in the code or ambiguity in documentation. If I run

Code: Select all

display -backdrop -background '#3f3f3f' -flatten -window root Downloads/archlinux-logo-light-90dpi.png
I get the image in the centre of the screen, black background around it and tiling within it to show 'transparent' areas. Shouldn't the image be filled with the background colour instead? Also, why doesn't the backdrop option honour the background colour when setting the colour of the areas around the image (the desktop)? Please advise.

I'm using imagemagick version 6.6.2-10 on Arch Linux.
archguest

Re: display -backdrop doesn't work as described in manual

Post by archguest »

On further experiment and with much appreciated help from a member fmw42 I have discovered that the order of arguments matters!

This arrangement of arguments ignores -background option and gives white background for transparent parts:

Code: Select all

display -backdrop -background '#3f3f3f' -flatten -window root Downloads/archlinux-logo-light-90dpi.png
This gives the correct background #3f3f3f for transparent parts:

Code: Select all

display -flatten -backdrop -window root -background '#3f3f3f' Downloads/archlinux-logo-light-90dpi.png
Imagemagick command line options page does not mention that order of arguments is important and neither does the manual for display.

Is this how it is supposed to be?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: display -backdrop doesn't work as described in manual

Post by fmw42 »

Is flatten really necessary?

This works just fine for me:


display -background gray -backdrop logo2t.png


as does this

display -background "#cccccc" -backdrop logo2t.png


On my mac osx tiger, IM 6.6.3.1 Q16

Order is important as you have to tell -backdrop what color you want prior to invoking -backdrop. IM is like that with respect to settings before options.
archguest

Re: display -backdrop doesn't work as described in manual

Post by archguest »

fmw42 wrote:Is flatten really necessary?
Without flatten it gives me "checkboard" tile instead of background colour.

If I run

Code: Select all

display -background '#3f3f3f' -flatten -backdrop Downloads/archlinux-logo-light-90dpi.png
it gives me what I would like to have on my root window - the image is centered and background colour fills the entire application window (which is the size of the screen), but if I add -window root anywhere in the line, the image is centered and the background around it is black! :'(
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: display -backdrop doesn't work as described in manual

Post by fmw42 »

The Mac seems to use display somewhat differently from other Unix platforms. I have trouble with transparency. When doing:

display logo2t.png

or

convert logo2t.png show:

I don't even see the window frame and transparency is right through to the desktop (no checkerboard), which is very annoying. I have mentioned this before but so far it has not been fixed. It would be nice to have the checkerboard showing and a frame around the window.

The only way I can get a checkerboard background is:

convert -size 320x240 tile:checks.gif logo2t.png -compose over -composite show:


display -texture checks.gif logo2t.png

IGNORES the -texture option


When I add -window root anywhere in the command, then I get nothing displayed.

display -background '#3f3f3f' -backdrop logo2t.png

gives me a new full screen window with the transparent image centered in a gray background of color "#3f3f3f" and the transparent areas show through to this color.
Last edited by fmw42 on 2010-07-29T12:41:48-07:00, edited 2 times in total.
archguest

Re: display -backdrop doesn't work as described in manual

Post by archguest »

fmw42 wrote: display -background '#3f3f3f' -backdrop logo2t.png

gives me a new full screen window with the transparent image centered in a gray background of color "#3f3f3f" and the transparent areas show through to this color.
Yes, if I understand you correctly this is what I am getting too. The trick is to extend this behaviour onto the root window and it doesn't work. I wonder if this could be considered a bug, otherwise what use is -window root if you can't control what is being displayed around the centered image?

I got around this problem now by doing it in two steps - flattening the image first with convert and then setting a wallpaper with xsetbg (from xloadimage suite) which can set the background around the image correctly.

The irony is that imagemagick works with transparent PNGs but can't update the root window correctly, xsetbg does not play well with transparency in PNGs but can set the background around image to requested value.

Thank you for your help, you gave an invaluable hint which led to a good workaround.

(Quite astounding how something as simple as this can take half-a-day. Setting an image centered on a solid background is something Windows, OS X, GNOME and KDE all can do but no simple tool alone appears to be capable of.)
Post Reply