GWIS

From ThorxWiki
(Difference between revisions)
Jump to: navigation, search
(update with notes about logic)
(saner 'too small' method)
Line 20: Line 20:
 
So! If the image is smaller, then we test edges. If all are the same, we center and set background solid. Otherwise, we scale it.
 
So! If the image is smaller, then we test edges. If all are the same, we center and set background solid. Otherwise, we scale it.
   
If taller, wider or bigger, then we scale it. However, if the scaled-size is within 10%(?) of the display size (% of pixels), then we stretch/zoom (configurable?) instead
+
If taller, wider or bigger, then we scale it. However, if the scaled-size is within 10%(?) of the display size (% of pixels), then we stretch/zoom (configurable?) instead. (thus within 10% either way: d_aspect*.909 < image aspect < d_aspect*1.1)
   
Finally, if the image is too small (say: pixelcount must be ≥317200 (640*480)), we tile it instead.
+
Finally, if the image is too small (say: scaling would require more than 3x(?) upscale, we tile it (or ignore it and restart?) instead
   
 
Next up, setting the background shading.
 
Next up, setting the background shading.

Revision as of 01:20, 30 May 2011

GNOME's Wallpaper Intelligently Set

This is the script that I use to set my GNOME wallpaper, after I became dissatisfied with the automatic changers that were available.

This script is cronnable, and attempts to intelligently handle images that are bigger, smaller, taller and wider than the display. By looking at relative sizes, aspect ratios, and edge colours, it will set the image to the appropriate type, and specify the background colours and gradient to match.

How?

First up, select an image. That much is easy. Working out how to display it is... tricky.

First up, some terminology of size

smaller
Image is smaller than display in both dimensions
taller
Image is taller, but width is unstated
wider
Image is wider, but height is unstated
bigger
Image is both taller and wider

...and aspect

shorter
Image aspect is shorter than display aspect
thinner
Image aspect is thinner than display aspect
identical
Image aspect matches display aspect!

So! If the image is smaller, then we test edges. If all are the same, we center and set background solid. Otherwise, we scale it.

If taller, wider or bigger, then we scale it. However, if the scaled-size is within 10%(?) of the display size (% of pixels), then we stretch/zoom (configurable?) instead. (thus within 10% either way: d_aspect*.909 < image aspect < d_aspect*1.1)

Finally, if the image is too small (say: scaling would require more than 3x(?) upscale, we tile it (or ignore it and restart?) instead

Next up, setting the background shading.

Shading is only applicable to centered and scaled images. So we detect the edge colours of the image so we know what we're working with.

Centered - we only have centered if we're setting a solid background. scaled - if the visible edges are the same, then we set solid. Otherwise, we set a gradient across from one display-edge edge to the other. (ie: if image is shorter, then horizontal-gradient. if thinner, then vertical gradient)





Note: this is tuned currently for a single monitor. Multiple monitors are assumed to all be the same resolution, and we only look at monitor res. Multimonitor setups can have 'spanned' However, the logic for spanned is the same as that for 'centered/scaled' - just with the display size across the WHOLE display, not just per-monitor.

Personal tools
Namespaces

Variants
Actions
Navigation
meta navigation
More thorx
Tools