User:Duesentrieb/POTD
POTD [1] is a tool written by Duesentrieb for A page providing the Picture of the Day in different resolutions via a stable URL. See User:Duesentrieb/Tools for other tools I wrote.
Please use the talk page for questions and comments. If I do not respond, please leave a quick note on my talk page at the german wikipedia.
Currently, a POTD is shown for three projects:
- commons (taken from commons:Template:Potd) - id is commons
- english Wikipedia (taken from en:Template:Pic_of_the_day) - id is enwiki
- german Wikipedia (taken from de:Benutzer:Überraschungsbilder/Vorlage - private project) - id is dewiki-bdk
Instructions
[edit]The aim of the POTD page is to provide a Picture of the Day in various resolutions, plus several types of meta-info about the image, using a stable, unchanging URL. That is, you can use the same URL to retrieve data about the current POTD every day. The following URL patterns are supported:
- In the URLs below, replace commons with the id of the wiki project you want the POTD from - the available projects and their ids are listed above; replace 800x600 by the resolution you want - available are: 200x150, 400x300, 800x600, 1024x768, 1280x1024, 1600x1200, full (unscaled); images are box-fitted to the requested resolution, without padding. If the image is an SVG, and the resolution is not "full", a pixelized PNG version is returned
- http://tools.wikimedia.de/~daniel/potd/potd.php/commons/800x600 [dead link] - redirect to the 800x600 pixel version' of the current POTD (for other resolutions, see explanation in the paragraph above); you can use this on your desktop or any HTML page - if you want to use this on a high traffic site, please cache it locally!
- http://tools.wikimedia.de/~daniel/potd/commons/potd-800x600.snippet - HTML snippet showing the 800x600 pixel version of the current POTD (for other resolutions, see explanation in the paragraph above); you can embed this into any HTML page - if you want to use this on a high traffic site, please cache it locally!
- http://tools.wikimedia.de/~daniel/potd/commons/potd-800x600.html - HTML page showing the 800x600 pixel version of the current POTD (for other resolutions, see explanation in the paragraph above); the image is overlayed by a source line, and links to the original description page on the wiki. Intended for use on desktop background.
- http://tools.wikimedia.de/~daniel/potd/potd.php/commons/home - redirect to the description page of the current POTD
- http://tools.wikimedia.de/~daniel/potd/commons/potd.html - description page of the current POTD, including upload history, as a HTML snippet; you can embed this into any HTML page - if you want to use this on a high traffic site, please cache it locally!
- http://tools.wikimedia.de/~daniel/potd/potd.php/commons/credits - same as above.
- http://tools.wikimedia.de/~daniel/potd/commons/potd.url - the URL of the current POTD's description page, as a plain text file. Handy for scripting.
- http://tools.wikimedia.de/~daniel/potd/commons/potd.name - the canonical name of the current POTD, as a plain text file. Handy for scripting.
- http://tools.wikimedia.de/~daniel/potd/commons/potd.page.wiki - description page of the current POTD, as plain wiki text
- http://tools.wikimedia.de/~daniel/potd/commons/potd.page.xml - description page of the current POTD, in MediaWiki export format
- http://tools.wikimedia.de/~daniel/potd/commons/potd.meta.json - meta data of the current POTD, in JSON format
- http://tools.wikimedia.de/~daniel/potd/commons/potd.meta.phps - meta data of the current POTD, as a serialized PHP object
- http://tools.wikimedia.de/~daniel/potd/commons/potd.meta.xml - meta data of the current POTD, in XML format (POX)
POTD on your homepage
[edit]To present the POTD on some HTML page, you can do the following:
- In the examples below, replace commons with the id of the wiki project you want the POTD from - the available projects and their ids are listed in the top section; replace 200x150 by the resolution you want - available are: 200x150, 400x300, 800x600, 1024x768, 1280x1024, 1600x1200, full (unscaled); images are box-fitted to the requested resolution, without padding. If the image is an SVG, and the resolution is not "full", a pixelized PNG version is returned.
- Note: if you want to use this on a high traffic site, please cache any resources you load!
Use the picture directly
[edit]the following tag would show the current picture of the day:
<img src="http://tools.wikimedia.de/~daniel/potd/potd.php/commons/200x150"/>
Note that most images require at least to credit the creator - so link to the description page on wiki:
<a href="http://tools.wikimedia.de/~daniel/potd/potd.php/commons/home">credits</a>
Use the HTML snippet
[edit]For example, with PHP, you could do the following:
<?php print file_get_contents("http://tools.wikimedia.de/~daniel/potd/commons/potd-200x150.snippet"); ?>
This results in the current POTD being shown, with a byline stating name and source, and linking back to the image's description page on the wiki, for credits and license info.
Use the RSS feed
[edit]Many homepage kits, blogs, etc allow you to embed RSS feeds into your pages. You can embed the Picture of the Day using this URL:
http://tools.wikimedia.de/~daniel/potd/commons/potd-200x150.rss
POTD on your desktop
[edit]Most operating systems (or, more precisely, desktop environments) let you specify a URL of an image or HTML page to be used as your desktop background (aka "wallpaper"), along with a refresh time. This way, you can have to POTD on your computer's desktop, updated automatically every day.
- In the examples below, replace commons with the id of the wiki project you want the POTD from - the available projects and their ids are listed in the top section; replace 600x800 by the resolution you want for your screen - available are: 200x150, 400x300, 800x600, 1024x768, 1280x1024, 1600x1200, full (unscaled); images are box-fitted to the requested resolution, without padding. If the image is an SVG, and the resolution is not "full", a pixelized PNG version is returned.
Linux/KDE
[edit]This info is for KDE 3.5.5 - it's probably similar in other versions In the desktop configuration, select Background and the Advanced Options and add an entry for the POTD. Make sure the "Background" option is set to "no image". You can fetch the POTD in several ways:
- using kwebdesktop: set Command to kwebdesktop %x %y %f http://tools.wikimedia.de/~daniel/potd/commons/potd-800x600.html and Preview cmd to kwebdesktop %x %y %f http://tools.wikimedia.de/~daniel/potd/commons/potd-200x150.html
- raw image using wget: set Command to wget -O %f http://tools.wikimedia.de/~daniel/potd/potd.php/commons/800x600 and Preview cmd to wget -O %f http://tools.wikimedia.de/~daniel/potd/potd.php/commons/200x150
- html page using wget: set Command to wget -O %f http://tools.wikimedia.de/~daniel/potd/commons/potd-800x600.html and Preview cmd to wget -O %f http://tools.wikimedia.de/~daniel/potd/commons/potd-200x150.html
- processed image using fetchpotd (see POTD fetching below): set Command to fetchpotd %f commons 800x600 800x600 and Preview cmd to fetchpotd %f commons 200x150 160x100
In any case, please set the refresh time to 30 minutes or more.
Linux/Gnome
[edit]Run this command:
gconftool -t string –set /desktop/gnome/background/picture_filename ~/potd-1600×1200.jpg
- this doesn't quite work for two reasons: a) you have to somehow update that file periodically, which is of course the tricky interresting part, and should be described. and b) the file extension may change (jpg, jpeg, png, PNG, etc...). So, anyone with a bit of experience with gnome, please add more info -- Duesentrieb 12:54, 26 March 2007 (UTC)
To use feh to download the image, and set the desktop: feh --bg-scale http://tools.wikimedia.de/~daniel/potd/potd.php/commons/1600x1200
Windows
[edit]Activate the "Active Desktop" feature and point it to http://tools.wikimedia.de/~daniel/potd/commons/potd-800x600.html
On Windows Vista (which has no Active Desktop), you could run this PowerShell script regularly to download a picture that you point your Desktop background to.
# parameters: # $suffix will determine which type of pictures are downloaded. You want to point your desktop background # to a particular file, so you cannot have different suffixes # $size determines what size of the POTD you will download Param ([string]$suffix = "jpg", [string]$size = "full") $urlroot = "http://tools.wikimedia.de/~daniel/potd" $redirecturl = $urlroot + "/potd.php/commons/" + $size $nameurl = $urlroot + "/commons/potd.name" $filename = $env:USERPROFILE + "\Pictures\potd." + $suffix $name = $Null; $WebClient = new-object System.Net.WebClient; $WebClient.Encoding = [System.Text.Encoding]::Default; $WebClient.Proxy = [System.Net.WebRequest]::DefaultWebProxy; $WebClient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials; $name= $WebClient.DownloadString($nameurl); if($name.Contains($suffix)) { $WebClient.DownloadFile($redirecturl, $filename); }
Mac OS X
[edit]I guess it's pretty much the same as for other systems, but I don't have a mac. Please fill in this info if you are confident about it
something like this should work. deleting old images is missing, and no idea how to execute it on a regular basis. -- ∂ 00:04, 27 March 2007 (UTC)
#!/bin/bash #URL=http://tools.wikimedia.de/~daniel/potd/potd.php/commons/1024x768 #URL=http://tools.wikimedia.de/~daniel/potd/potd.php/dewiki-bdk/1024x768 URL=http://tools.wikimedia.de/~daniel/potd/potd.php/enwiki/1024x768 # changing the name is important. # somebody has to cleanup afterwards... FILE=/tmp/potd_$(date +%y%m%d%H%M%S) curl -L "$URL" >"$FILE" osascript - <<! tell application "Finder" select window of desktop set myFile to POSIX file "$FILE" as string set desktop picture to file myFile end tell !
POTD as screensaver
[edit]Some programs can use to an RSS "picture feed" as a screensaver - Google's Picasa can do it for Windows, for example.
POTD fetching
[edit]- In the examples below, replace commons with the id of the wiki project you want the POTD from - the available projects and their ids are listed in the top section; replace 600x800 by the resolution you want - available are: 200x150, 400x300, 800x600, 1024x768, 1280x1024, 1600x1200, full (unscaled); images are box-fitted to the requested resolution, without padding. If the image is an SVG, and the resolution is not "full", a pixelized PNG version is returned.
Fetch the POTD image using wget:
wget http://tools.wikimedia.de/~daniel/potd/potd.php/commons/800x600
The resulting file will be called something like potd-800x600.jpg, but the file extension may vary (.png for a PNG file, etc)
Fetch the POTD page using wget:
wget http://tools.wikimedia.de/~daniel/potd/commons/potd-800x600.html
The resulting file is 800x600.html
Fetcher script creating a custom-fit rendering of the current potd, with the image's description URL superimposed as a watermark (also useful as a desktop background updater script):
#bin/bash if [ -z "$1" ]; then echo "USAGE: "`basename "$0"`" <targetfile> [wiki] [fetchsize] [screensize]" echo " See http://meta.wikimedia.org/wiki/User:Duesentrieb/POTD for wiki ids." echo " Currently supported: commons, enwiki, dewiki-bdk" echo " fetchsize and screensize must look like 800x600" exit 1 fi f="$1" wiki="${2:-commons}" sz="${3:-1280x1024}" sc="${4:-1280x800}" home=`wget -O - http://tools.wikimedia.de/~daniel/potd/"$wiki"/potd.url` wget -O - http://tools.wikimedia.de/~daniel/potd/potd.php/"$wiki"/"$sz" | convert -verbose -size "${sc}" - -scale "${sc}>" -gravity center -crop "${sc}"+0+0\! -background black -flatten "$f" mogrify -gravity north -stroke wheat -fill wheat -pointsize 15 -strokewidth 1 -font Courier -draw "text 0,10 '$home'" "$f"
This is a bash script, and requires wget and ImageMagick to be installed. Use it like this: scriptname <targetfile> [wiki] [fetchsize] [screensize]. Parameters are:
- targetfile - the file you want to write to.
- wiki - the project id, as specified at the top of this page. Default is commons.
- fetchsize - the resolution to fetch (see above for a list of available resolutions). Should be greater than or equal to screensize. Default is 1280x1024
- screensize - the resolution you want the output file to have. Default is 1280x800.
For example, to get the Picture of the Day of the german Wikipedia, for an 1280x800 screen, use the following line:
fetchpotd filename dewiki-bdk 1280x1024 1280x800
This will fetch the 1280x1024 pixel version of the current picture of the day, and fit to your 1280x800 screen, without distortion.
TODO
[edit]- handle if-modified-since/not-modified
- provide uploader/author names (from information template, or self + uploader) as plain text