Template:Image label marker
Usage
[edit]Purpose
[edit]The purpose of this template is to allow accurate placement of an image and/or text label over another source image, irrespective of scaling of the source image. It is based on the {{Image label}} template. However, a drawback with that template is that the placement gets slightly inaccurate if you scale the source image (because of the way calculations are done), and thus you might have to manually recalculate the placement.
This template also has similarities with the {{Overlay}} template. That template however sadly doesn't allow for scaling. It is also limited to 30 labels, although for most purposes that is probably more than enough.
This template is however much more bloated than either of those templates, and you might want to consider if you can use one of the templates that are simpler and easier to use.
Example usage
[edit]This template assumes you first introduce a background image by calling {{Image label begin}}. By doing so this also requires it to be ended with {{Image label end}}. Example with two smilies placed as the “eyes” on this beach image.
{{Image label begin | image=Beach Smile.jpg | width=250 | float=right | title=Example }} {{Image label marker | x=1079 | y=1033 | image=Face-grin.svg | marker_size=15 | width=250 | x_orig=2749 }} {{Image label marker | x=1601 | y=1020 | image=Face-grin.svg | marker_size=15 | width=250 | x_orig=2749 }} {{Image label end}}
For full list of available options/parameters see further below. In this example the following are used
width = 250
is the width of the scaled image. This should correspond to the width you supplied when using {{Image label begin}}.x_orig = 2749
is in this example the width of the original beach image, which can be found out through various methods. One way to find out is the way Wikipedia/Commons lists it below the image where it says “Full resolution” when you view the image information and its license.x = 1079
is the x-coordinate on the full resolution image where the is to be placed. There are various methods to find out this, and depends on what tools you have available.y = 1033
is the y-coordinate on the full resolution image where the is to be placed.image = Face-grin.svg
is the image to be used as a marker, since the default marker image is not used.marker_size = 15
is the width of the marker image .
If scaling the beach image down (or up), the only changes that need to be done is changing every occurrence of the width parameter, and the placement of overlying marker images (and their corresponding text) should scale accordingly.
{{Image label begin | image=Beach Smile.jpg | width=150 | float=right | title=Example }} {{Image label marker | x=1079 | y=1033 | image=Face-grin.svg | marker_size=15 | width=150 | x_orig=2749 }} {{Image label marker | x=1601 | y=1020 | image=Face-grin.svg | marker_size=15 | width=150 | x_orig=2749 }} {{Image label end}}
Minimal use skeleton
[edit]{{Image label marker | x_marker_orig = | y_marker_orig = | x_scaled = | x_orig = | text = }}
If you want to use a different marker/image than the default Red pog.svg
, you can add it with
| image = | marker_size =
Full skeleton
[edit]{{Image label marker | x_marker_orig = | y_marker_orig = | x_scaled = | y_scaled = | x_orig = | y_orig = | text = | image = | marker_size = | x_adjust = | y_adjust = | x_textadjust = | y_textadjust = | show_image = | text_color = | text_align = | text_width = | font_size = | style = }}
Please note that many of these parameters are used in calculations. Due to constraints the template will think a parameter that is given, but is actually empty or contains spaces, still has a value and thus will give an error during calculations. The error might look something like this: Expression error: Missing operand for +..
Examples
[edit]«Riksforsamlingen på Eidsvoll 1814» painted by Oscar Wergeland
[edit]Calculations
[edit]yorig
yscaled |
|
xorig
xscaled |
Default calculations used for placing the marker image. With the use of the template's parameter options xadjust and yadjust the placement can be slightly modified.
and
Where yscaled by default is calculated from the percentage the image is resized
Default calculations for the text placement, more specifically the upper left corner of the text's bounding box. The calculation inherits xadjust and yadjust from the marker image's placement. With the use of the template's parameter options xtextadjust and ytextadjust the text placement can be additionally modified.
and
Template parameters
[edit]None of the template parameters are technically required, however not supplying a few of them will make the template behave oddly, or make the use of this template unnecessary. For this reason some of the parameters are listed as "required".
Parameter name | Alternate names | Required | Description | Recommended values |
---|---|---|---|---|
x_marker_orig | x x-marker-orig |
yes | The horizontal x-location on the original image where you want the centre of the marker to be located. | 1 … xorig |
y_marker_orig | y y-marker-orig |
yes | The vertical y-location on the original image where you want the centre of the marker to be located. | 1 … yorig |
x_scaled | scale width x-scaled |
yes | The width of the resized image in pixels. Default is scaling it down (or up) to 250 pixels.
|
1 … xorig |
y_scaled | height y-scaled |
no | The calculated height of the resized image in pixels. Note that the actual image height is implicitly set with {{Image label begin}}. Thus yscaled is mainly used internally, and by default it is calculated based on xscaled. If you do use this parameter, then you should also fill in a value for yorig or the calculations will end up wrong. | 1 … yorig |
x_orig | width_orig x-orig width-orig |
yes | The width of the original image in pixels. If this value isn't corresponding with the original image's actual width, the calculations may be faulty. | 1 … ? |
y_orig | height_orig y-orig height-orig |
no | The height of the original image in pixels. If this value isn't corresponding with the original image's actual height, the calculations may be faulty. You need to fill in a value for this parameter if you already used the yscaled parameter option, otherwise the calculations will end up wrong. | 1 … ? |
text | no | The text accompanying the marker image and shown close to the calculated (x, y) position. Default is no text. | Any text | |
image | no | The image placed at the calculated (x, y) position. Default is Red pog.svg .
|
Any image | |
marker_size | marker-size | no | The size (height and width) of the marker image that is placed. Default is 7 pixels wide. If the size is set to 0 , then no image will be shown. It is assumed the shown marker image is a square so the height is equal to its width. If it is not a square you can modify the placement with the xadjust and/or yadjust options.
|
0 … ? |
x_adjust | x-adjust | no | A number of pixels you want the marker image to be moved horizontally after the initial scaling calculation has been done. Use for example if after calculation a rounding error moves the marker image a bit off from its wanted position. Default is 0 .
|
-xscaled … +xscaled |
y_adjust | y-adjust | no | A number of pixels you want the marker image to be moved vertically after the initial scaling calculation has been done. Use for example if the marker image is not a square, or if after calculation a rounding error moves the marker image a bit off from its wanted position. Default is 0 .
|
-yscaled … +yscaled |
x_textadjust | x-textadjust | no | A number of pixels you want the text's upper left corner to be moved horizontally after the initial scaling calculation has been done. Use for example if after calculation a rounding error or the font size moves the text's upper left corner a bit off from its wanted position. If a marker image was shown the default value is 3 pixels to give a little room between the image and the text. Otherwise the default is 0 .
|
-xscaled … +xscaled |
y_textadjust | y-textadjust | no | A number of pixels you want the text's upper left corner to be moved vertically after the initial scaling calculation has been done. Use for example if after calculation a rounding error or the font size moves the text's upper left corner a bit off from its wanted position. Default is 0 .
|
-yscaled … +yscaled |
show_image | showimage show-image |
no | If this parameter contains anything else than its default value yes then the marker image will not be shown. Another way to do the same is to set the marker_size to 0 .
|
Any text or value |
text_color | color text-color |
no | CSS-option specifying the color of the text accompanying the marker image. This value follows the valid options for specifying a web color with CSS. Default is black .
|
predefined color name or
|
text_align | text-align | no | CSS-option specifying the alignment of the accompanying marker text. Default value is left .
|
left , right , center , justify
|
text_width | text-width | no | CSS-option specifying the column width of the text accompanying the marker image. By default this is not set and follows the browser's calculations. Note that you need to add the units px or % etc., or otherwise the CSS the template generates will be incorrect.
|
auto , 1px … +xscaledpx , 1% … 100%
|
font_size | font-size | no | CSS-option specifying the font size of the text accompanying the marker image. This value follows the valid options for specifying a font size with CSS. Predefined relative font sizes are xx-small , x-small , small , medium , large , x-large , xx-large , or it can be specified with a number in points pt , pixels px , ems em , percent % , cm , etc. By default this is not set and follows the text, font and style around the image.
|
F.ex. 10pt , 20px , 1.5em , 125% , …
|
style | no | Any other CSS you want applied to the text. You need to write this out in full and as valid CSS. This will be applied to the whole text's (rectangle) bounding box, so if you want some CSS applied to only parts of the text you should not use this option, but instead use |
Any valid CSS |
See also
[edit]- {{Annotated image}}, allows text notes to overlap image, allows cropping
- {{Image label}}, an alternative
- {{Overlay}} - places up to 30 marker images of various chooseable kinds over a base image with optional grid and legend
- {{Superimpose}} - places one image over another
- {{Superimpose2}} - places up to 50 image layers over one another
- {{Location map}} - places a single image over another at a map coordinate location
- {{Lageplan}}, related template to Location map with specific features