Difference between revisions of "Template:ImageTG"
From Species-ID
Line 1: | Line 1: | ||
<includeonly><!-- | <includeonly><!-- | ||
** First store values for 100% scaling: ** | ** First store values for 100% scaling: ** | ||
− | -->{{#ifexpr:{{#pos:{{{1}}}|_10x.}} |<!--then-->{{#vardefine: | + | -->{{#ifexpr:{{#pos:{{{1}}}|_10x.}} |<!--then-->{{#vardefine:tgpx1|589}}{{#vardefine:tglabel|200 µm}} }}<!-- |
− | -->{{#ifexpr:{{#pos:{{{1}}}|_20x.}} |<!--then-->{{#vardefine: | + | -->{{#ifexpr:{{#pos:{{{1}}}|_20x.}} |<!--then-->{{#vardefine:tgpx1|589}}{{#vardefine:tglabel|100 µm}} }}<!-- |
− | -->{{#ifexpr:{{#pos:{{{1}}}|_40x.}} |<!--then-->{{#vardefine: | + | -->{{#ifexpr:{{#pos:{{{1}}}|_40x.}} |<!--then-->{{#vardefine:tgpx1|595}}{{#vardefine:tglabel|50 µm}} }}<!-- |
− | -->{{#ifexpr:{{#pos:{{{1}}}|_63x.}} |<!--then-->{{#vardefine: | + | -->{{#ifexpr:{{#pos:{{{1}}}|_63x.}} |<!--then-->{{#vardefine:tgpx1|354}}{{#vardefine:tglabel|20 µm}} }}<!-- |
− | -->{{#ifexpr:{{#pos:{{{1}}}|_100x.}}|<!--then-->{{#vardefine: | + | -->{{#ifexpr:{{#pos:{{{1}}}|_100x.}}|<!--then-->{{#vardefine:tgpx1|295}}{{#vardefine:tglabel|10 µm}} }}<!-- |
** The value above are correct for full size display, but need to be corrected for scaled images, relative to original imagewidth/desired imagewidth ** | ** The value above are correct for full size display, but need to be corrected for scaled images, relative to original imagewidth/desired imagewidth ** | ||
--> | --> | ||
− | {{#vardefine: | + | {{#vardefine:tgpx2| |
− | {{#expr: {{#var: | + | {{#expr: {{#var:tgpx1}} * |
{{#if: {{#pos: {{{width|250px}}} |px}} | {{#if: {{#pos: {{{width|250px}}} |px}} | ||
|<!--then: is px-number, strip px ####NOT YET DONE!### and calculate ratio:--> {{{width}}} / {{#mediawidth: {{{1}}} }} | |<!--then: is px-number, strip px ####NOT YET DONE!### and calculate ratio:--> {{{width}}} / {{#mediawidth: {{{1}}} }} | ||
Line 17: | Line 17: | ||
<!--(end vardefine)-->}} | <!--(end vardefine)-->}} | ||
− | '''TEST''' | + | '''TEST''' tgpx1={{#var:tgpx1}} - tglabel={{#var:tglabel}} - mediawidth={{#mediawidth: {{{1}}} }} '''END TEST''' |
<!-- | <!-- | ||
Line 37: | Line 37: | ||
#if: {{{7|}}} | {{!}}{{{7}}} | #if: {{{7|}}} | {{!}}{{{7}}} | ||
}} | }} | ||
− | |{{Scalebar|{{#var: | + | |{{Scalebar|{{#var:tgpx2}}px|{{#var:tglabel}} {{{caption|}}}}} |
}}</includeonly><noinclude> | }}</includeonly><noinclude> | ||
Revision as of 10:52, 17 December 2008
Description
This template is a specialized template to render a specific kind of microscopic photos by T. Gräfenhan. The major function of this template is to calculate a scale bar correctly for the magnification factors signaled by a special code ("_63x.") in the file name. Other images may have different naming conventions; the template may then be copied to a different name and the code adjusted. The images have a maximum size of 2560px if uncropped, but may be cropped.
Parameters
- width: either number + px for fixed width in pixel, or number, interpreted as percentage relative to original size.
- caption: You must pass the caption in a named parameter!
- a sequence of unnamed parameters, covering the standard image functionality (thumb, left, caption, etc.).
Usage
- {{ImageTG|File:x.png|caption=Your caption text here|width=250px}}
- Fully equivalent to: [[File:x.png|250px|Your caption text here]]
- {{ImageTG|File:x.png|thumb|left|width=15|upright|caption=Your caption text}}
- This scales the image to 15% of original size.
Dependendencies
Depends on Extension:StringFunctions, Extension:MediaFunctions, Extension:Variables.