GWIS
(+cat) |
(update with notes about logic) |
||
Line 4: | Line 4: | ||
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. |
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 |
||
+ | |||
+ | Finally, if the image is too small (say: pixelcount must be ≥317200 (640*480)), we tile it 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. |
||
+ | |||
+ | |||
+ | |||
Revision as of 22:19, 29 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
Finally, if the image is too small (say: pixelcount must be ≥317200 (640*480)), we tile it 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.