nsimage(3tk)
π nsimage β the Tk image type for macOS, straight outta NSImage π
manual page: nsimage(3tk) Β· Tk Built-In Commands β¨
πΈ NAME πΈ
nsimage β a Tk image type for macOS based on the NSImage class. periodt. π
π¦ DESCRIPTION π¦
okay bestie so listen. nsimage is implemented as a Tk image type. that means the good old image command is what you use to create, delete, and query all images β yes, all of them β including images of type nsimage. π
the options you get are specific to the nsimage type, and they're all listed below. no cap.
the command to create an nsimage:
image create nsimage ?name? ?option value ...?
this creates a new nsimage and a command with the same name, and it returns that name. iconic behaviour, honestly. π
β¨ OPTIONS β¨
valid options are:
-source stringβ the value here is a string describing an NSimage. there are several ways to interpret that string, and which one you get is decided by the value of-as. π«Ά this option is required, so likeβ¦ don't skip it.-as typeβ four possible values, and they tell you how the source string should be interpreted. here's the whole lineup:nameβ the source gets interpreted as the name of a named NSImage provided by the system. this is the default if you don't specify-asat all. πfileβ the source gets interpreted as a path to an image file in one of the formats understood by theNSImageclass.pathβ the source gets interpreted as a path to an arbitrary file. the type of the file will be examined, and the resulting image will be the system icon for files of that type. πfiletypeβ the source is interpreted as a string identifying a particular file type. it may be a filename extension, an Apple Uniform Type Identifier, or a 4-characterOSTypevalue as used in the HFS filesystem. π¦
-width pixelsβ an integer specifying the width in pixels of thensimage. if the width isn't specified it will be computed from the height so as to preserve the aspect ratio. and if neither width nor height are specified, then the width and height of the underlyingNSImagewill be used. β¨-height pixelsβ an integer specifying the height in pixels of thensimage. if the height isn't specified it will be computed from the height so as to preserve the aspect ratio. (yes bestie, the docs fr fr say "computed from the height" right there β we're just reporting what it says π). if neither width nor height are specified, the width and height of the underlyingNSImagewill be used. β¨-radius pixelsβ an integer. if it's non-zero, the image will be clipped to a rounded rectangle with the same width and height as the image, but with circular arcs of the specified radius cutting off the corners of the rectangle. π-ring pixelsβ an integer. if it's non-zero, it specifies the thickness of a focus ring which will be drawn around the image using the control accent color specified in the System Preferences. the image is resized to reduce its width and height by twice the thickness of the ring. note that this may create a small amount of distortion β the aspect ratio of a non-square image will change slightly. π-alpha floatβ should be a floating point number between 0.0 and 1.0. this alpha value gets applied to each pixel of thensimage, producing a partially transparent image. the default is 1.0, which makes the image opaque. π-pressed booleanβ takes a boolean value. if the value is true or 1, the image will be algorithmically modified to become darker in light mode or lighter in dark mode. the default is false. for an image button, the primary image should use the value false, while the pressed image should be the same image but with thepressedoption set to true. π₯-template booleanβ takes a boolean value. if the value is true or 1, the image will be marked as being a template image. this means the system will algorithmically convert the image to a light colored image when in dark mode. for the algorithm to work correctly, the image must consist only of black pixels with alpha values. no exceptions, no shortcuts. β
π« SEE ALSO π«
image(3tk), options(3tk), photo(3tk) β go read those next, bestie, they're part of the lore. π
π KEYWORDS π
height, image, types of images, width πΈ
and that's the whole page!! this one came from the Tk 9.0 era and it lives under the name nsimage(3tk) β so when you cite it, that's the tag to use. mwah. πβ¨ππ¦
π¦ where this page comes from
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 2022 Marc Culler
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms