Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 24 May 2013, 16:44
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
Project suggestion: fix proportions of background image
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [8 Posts]  
Author Message
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 6866
Location: Perth, Western Australia

PostPosted: 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
View user's profile Send private message Visit poster's website 
GuestToo
Puppy Master

Joined: 04 May 2005
Posts: 4078

PostPosted: 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
View user's profile Send private message 
GuestToo
Puppy Master

Joined: 04 May 2005
Posts: 4078

PostPosted: 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
View user's profile Send private message 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: 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
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: 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
View user's profile Send private message Visit poster's website 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 6866
Location: Perth, Western Australia

PostPosted: 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
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: 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
View user's profile Send private message Visit poster's website 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 6866
Location: Perth, Western Australia

PostPosted: 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
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [8 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0591s ][ Queries: 12 (0.0046s) ][ GZIP on ]