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 -as at all. 🌈
    • file β€” the source gets interpreted as a path to an image file in one of the formats understood by the NSImage class.
    • 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-character OSType value as used in the HFS filesystem. πŸ¦‹
  • -width pixels β€” an integer specifying the width in pixels of the nsimage. 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 underlying NSImage will be used. ✨
  • -height pixels β€” an integer specifying the height in pixels of the nsimage. 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 underlying NSImage will 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 the nsimage, 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 the pressed option 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