| Author |
Message |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 6874 Location: Perth, Western Australia
|
Posted: Sat 03 Dec 2005, 19:47 Post subject:
Project suggestion: fix proportions of background image |
|
The utility "xli" is used to render an image on the root window.
xli is executed from within /root/.xinitrc when X starts.
There is also a script for choosing the background image; /usr/sbin/set-bkgrnd.
PROBLEM:
For certain combinations of screen resolution and image dimensions, we get the image rendered with white/black space on the sides of the image.
SOLUTION:
Automatically resize the image to match the screen dimensions.
xli itself is capable of doing this. It has "-zoomx" and "-zoomy" options, but the problem is they are expressed as a percentage, whereas we need exact pixel dimensions. ...a script could perform some calculation to work out the percentage.
Anyway, there could be a little script, maybe built into set-bkgrnd. that resizes the chosen image. Or it could be done in .xinitrc.
But, how to read an image dimensions from the commandline?
|
|
Back to top
|
|
 |
GuestToo
Puppy Master
Joined: 04 May 2005 Posts: 4078
|
Posted: Sat 03 Dec 2005, 21:14 Post subject:
|
|
i think the only background-setting shell commands in .xinitrc should be 1 line that calls the appropriate scripts
maybe something like sh /etc/background &
|
|
Back to top
|
|
 |
GuestToo
Puppy Master
Joined: 04 May 2005 Posts: 4078
|
Posted: Sat 03 Dec 2005, 21:58 Post subject:
|
|
| Quote: | | how to read an image dimensions from the commandline? |
maybe something like
xli -identify *.png | awk '{print $4}'
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Sat 03 Dec 2005, 22:37 Post subject:
|
|
| Code: | #!/usr/bin/puppybasic
include "/usr/lib/wxbasicscript/basefunctions.inc"
' PB-Back
' calculates best quality-settings for xli
pic = argvtostring()
if pic = "" then
print "usage: PB-Back <imagefilename>"
end
end if
shell( "xli -identify \"" & pic & "\" >/tmp/PB-Back.tmp" )
picinfo = readfile( "/tmp/PB-Back.tmp" )
picinfo = cutleft( picinfo , "is a ")
picinfo = cutrightfromleft( picinfo , " ")
picwidth = cutright( picinfo , "x")
picheight = cutleft( picinfo , "x")
screensize = xwin_screensize()
screenwidth = screensize[0]
screenheight = screensize[1]
percentheight = (screenheight / picheight ) * 100
percentwidth = (screenwidth / picwidth ) * 100
'shell ( "xli -onroot -colordither -colors 256 -smooth -xzoom " & percentwidth & " -yzoom " & percentheight & " \"" & pic & "\"")
shell ( "xli -onroot -smooth -colordither -xzoom " & percentwidth & " -yzoom " & percentheight & " \"" & pic & "\"")
'print "scaling image x:"& percentwidth & "% y:" & percentheight & "%"
removefile( "/tmp/PB-Back.tmp" )
|
Greets, Mark
Last edited by MU on Sun 04 Dec 2005, 02:59; edited 3 times in total
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Sat 03 Dec 2005, 22:54 Post subject:
|
|
It creates quite good results.
The relatively small image:
http://dotpups.de/pics/puppy/PB-Back/PB-Back2.jpg
Set as Background:
http://dotpups.de/pics/puppy/PB-Back/PB-Back1.jpg
here I added -colors 256 to xli to simulate a 256-color-Display:
http://dotpups.de/pics/puppy/PB-Back/PB-Back3.jpg
Mark
|
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 6874 Location: Perth, Western Australia
|
Posted: Sun 04 Dec 2005, 22:14 Post subject:
|
|
Incredible!
I'll check it out tonight, see how to incorporate it into 1.0.7alpha.
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Mon 05 Dec 2005, 02:19 Post subject:
|
|
Barry, I made a small enhancement.
-smooth just makes sense, if the picture is scaled.
If it has the same size as the monitor, it looks less "blured" without smoothing.
So this version checks that.
| Code: | #!/usr/bin/puppybasic
include "/usr/lib/wxbasicscript/basefunctions.inc"
' PB-Back
' calculates best quality-settings for xli
pic = argvtostring()
if pic = "" then
print "usage: PB-Back <imagefilename>"
end
end if
shell( "xli -identify \"" & pic & "\" >/tmp/PB-Back.tmp" )
picinfo = readfile( "/tmp/PB-Back.tmp" )
picinfo = cutleft( picinfo , "is a ")
picinfo = cutrightfromleft( picinfo , " ")
picwidth = cutright( picinfo , "x")
picheight = cutleft( picinfo , "x")
screensize = xwin_screensize()
screenwidth = screensize[0]
screenheight = screensize[1]
percentheight = (screenheight / picheight ) * 100
percentwidth = (screenwidth / picwidth ) * 100
smooth = ""
if screenwidth != picwidth then
smooth = " -smooth "
end if
if screenheight != picheight then
smooth = " -smooth "
end if
'shell ( "xli -onroot " & smooth & " -colors 256 -colordither -xzoom " & percentwidth & " -yzoom " & percentheight & " \"" & pic & "\"")
shell ( "xli -onroot " & smooth & " -colordither -xzoom " & percentwidth & " -yzoom " & percentheight & " \"" & pic & "\"")
'print "scaling image x:"& percentwidth & "% y:" & percentheight & "%"
removefile( "/tmp/PB-Back.tmp" )
|
mark
|
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 6874 Location: Perth, Western Australia
|
Posted: Mon 05 Dec 2005, 08:18 Post subject:
|
|
Mark,
Ok, will do.
Note, it's already announced on the News page,
www.puppylinux.com/news.htm
|
|
Back to top
|
|
 |
|