Page 1 of 1

Centering image on screen

Posted: 2011-04-20T10:46:59-07:00
by viper-2
I use IM to display an image for a few seconds via a simple animation loop. The image is always displayed in the top left-hand corner of my monitor screen. So far, using "backdrop" appears to be the only way to center the image on the screen. Unfortunately, using "backdrop" occupies the entire screen.

Is there a simple way to display a centered image that does not cover my screen entirely (other than making areas of the image transparent)?

Thank you

agt

--
Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: agt@codeartnow.com

Re: Centering image on screen

Posted: 2011-04-20T12:49:44-07:00
by fmw42
try this:


display -geometry 640x480+200+100 logo:


works for me on IM 6.6.9.5 Q16 Mac OSX Tiger to move the window 200 to the right and 100 down. You can also try just using

display -geometry 100%x100%+200+100 logo:

which works but I get a small thumbnail image as well. Unfortunately, -gravity center does not help in the display on my system; that is the combination of -gravity center and -geometry 640x480+0+0 does not make it centered.

Re: Centering image on screen

Posted: 2011-04-20T15:00:27-07:00
by viper-2
I had tried "gravity -Center", but my version of IM doesn't recognize this option. I should install the latest version from source.

Also, I need to look more closely at the "gravity"option as it seemed (at first glance) to be more for positioning, say text, within an image as opposed to positioning the image relative to the screen coordinates.

Something that uses "center" instead of coordinates is what I'm looking for as the image will be displayed on screens of varying size and resolution - but thanks.

agt


--
Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: agt@codeartnow.com

Re: Centering image on screen

Posted: 2011-04-20T16:44:53-07:00
by anthony
Window placement (beyond X window -geometry specifications) is actually a function of YOUR window manager, not the application!!!!!

In my OpenBox window manager I have a RC file in which I can specify excatly which 'desktop' and where on the screen I want specific applications. Typically I can 'name' the application to make it special for that specific task.

Another alternative is to use other X window, window management tools, like xdotool, xwit, and wmctrl which will let you move, request window resize, iconify, de-iconify, any window you like!


I have used such tools to create a shell scripted X window application out of various utility programs. especially X window display tools that allow some remote control of the image displayed.

"display" does allow some remote control of the displayed contents. Even "animate" does.

I have used this fact in a shell script that displays one image, then creates a 'fade to new image' animation whcih it then passes to animate, to action. After that it picks a new image and repeats the process. The point was that the next image and the fade to that image is picked on the fly. --- And it worked!!!

See scripts..
http://www.imagemagick.org/Usage/script ... show_morph
and one where a external script or the user specifies the next image
http://www.imagemagick.org/Usage/scripts/slideshow_next

Re: Centering image on screen

Posted: 2011-04-20T16:59:36-07:00
by fmw42
Also, I need to look more closely at the "gravity"option as it seemed (at first glance) to be more for positioning, say text, within an image as opposed to positioning the image relative to the screen coordinates.
-gravity works well for positioning when compositing one image relative to another bigger one.

see http://www.imagemagick.org/Usage/compose/#compose_terms and http://www.imagemagick.org/Usage/layers/#convert

Re: Centering image on screen

Posted: 2011-04-20T18:49:44-07:00
by viper-2
Is there a way to use "backdrop" so that the backdrop colour is transparent? This would center the image but allow the other "X window activity" to show through.

agt

--
Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: agt@codeartnow.com

Re: Centering image on screen

Posted: 2011-04-20T19:52:07-07:00
by fmw42
Have you explored combinations of -backdrop and -geometry and -gravity and -background none in the same display command from the options at http://www.imagemagick.org/script/display.php

In my tests, it does not look like -background none or -background transparent or -background "rgba(0,0,0,0)" are recognized colors.

Re: Centering image on screen

Posted: 2011-04-21T07:09:18-07:00
by viper-2
fmw42 wrote:Have you explored combinations of -backdrop and -geometry and -gravity and -background none in the same display command from the options at http://www.imagemagick.org/script/display.php.
I'll have to update my version of IM for gravity options to be recognized. Somehow I had the distinct impression that the "background" option did not pertain to the backdrop that fills the screen, but related to the canvas and images . I'm pretty much a newbie with graphics so here goes. Thanks fmw42!

Interesting animation scripts Anthony, I'll bookmark for future reference.

agt
--
Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: agt@codeartnow.com

Re: Centering image on screen

Posted: 2011-04-21T09:24:24-07:00
by fmw42
viper-2 wrote:
fmw42 wrote:Have you explored combinations of -backdrop and -geometry and -gravity and -background none in the same display command from the options at http://www.imagemagick.org/script/display.php.
I'll have to update my version of IM for gravity options to be recognized. Somehow I had the distinct impression that the "background" option did not pertain to the backdrop that fills the screen, but related to the canvas and images . I'm pretty much a newbie with graphics so here goes. Thanks fmw42!

Interesting animation scripts Anthony, I'll bookmark for future reference.

agt
--
Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: agt@codeartnow.com

I am no expert on this either. I was just trying various combinations of what looked like perhaps useful options for display. Unfortunately, I could not get anything to work the way you want with transparency, though -geometry did move the window. As Anthony says, it is also a factor of your version of X11 and your operating system. I am on a Mac and have had numerous issues, for example, when the image has transparency even the window frame goes transparent, thus it is hard to find the boundary of the image. For me -gravity did not help. Though in other applications such as compositing it works in concert with -geometry. I think your issue is needing some way of building the transparent background. But on my system, the colors with transparency are not recognized by -background. So I don't know exactly how to help.

Fred

Re: Centering image on screen

Posted: 2011-04-21T11:03:33-07:00
by viper-2
fmw42 wrote:Unfortunately, I could not get anything to work the way you want with transparency, though -geometry did move the window. As Anthony says, it is also a factor of your version of X11 and your operating system.... I think your issue is needing some way of building the transparent background. But on my system, the colors with transparency are not recognized by -background. So I don't know exactly how to help.

Fred
I'm only getting simple colour recognition with "background" too. I'm actually calling imagemagick with "animate' as a sort of pseudo splash screen at the start of an application. I think I'll just use a default setting for the size and offsets that will look good for most screen sizes, and forget about backdrop as this "takes over" the users' entire screen. Since "gravity" isn't working on my debian lenny box I won't use it as it won't work on some users' systems either.

When I find the time, I'll code a proper splash screen in Python.

Thanks for trying Fred.

Cheers!

agt
--
Freedom - no pane, all gaiGN!

Code Art Now
http://codeartnow.com
Email: agt@codeartnow.com