image(3tk)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– image(3tk) β€” Tk Built-In Commands πŸ’–

okay bestie, sit down, grab a strawberry πŸ“, because today we're talking about image, the Tk command that literally creates, deletes and interrogates images. yes it does all three. it's giving multitasking queen πŸ‘‘


✨ NAME ✨

image β€” create and manipulate images πŸŽ€


🌸 SYNOPSIS 🌸

image option ?arg ...?

πŸ¦‹ DESCRIPTION πŸ¦‹

The image command is used to create, delete, and query images. It can take several different forms, depending on the option argument. The legal forms are, and I need you to memorize these fr fr:

  • image create type ?name? ?option value ...? β€” creates a new image, plus a command with the exact same name, and returns that name. type says what kind of image it is, and it has to be one of the types currently defined (e.g., bitmap). name is what you're naming the image; if you leave it out, Tk picks a name of the form imagex, where x is an integer. you can throw in any number of option-value pairs, which give configuration options for the brand new image. the legal set of options is defined separately for each image type β€” scroll down for the deets on the built-in image types. if an image already exists under the name you gave, it gets replaced with the new image, and any instances of that image will redisplay with the new contents. πŸ’€
⚠️ important bestie: the image command will silently overwrite any procedure that may currently be defined by the given name, so choose the name wisely. it's recommended to use a separate namespace for image names (e.g., ::img::logo, ::img::large). protect your names, protect your peace 🫢
  • image delete ?name name ...? β€” deletes each of the named images and returns an empty string. if there are instances of those images displayed in widgets, the images will not actually be deleted until all of the instances are released. however, the association between the instances and the image manager will be dropped. existing instances will retain their sizes but redisplay as empty areas. and if a deleted image gets recreated with another call to image create, the existing instances will use the new image. iconic behavior honestly ✨
  • image height name β€” returns a decimal string giving the height of image name in pixels. πŸ“
  • image inuse name β€” returns a boolean value saying whether or not the image given by name is in use by any widgets.
  • image names β€” returns a list containing the names of all existing images. the whole roster πŸ‘‘
  • image type name β€” returns the type of image name (that's the value of the type argument to image create back when the image was created).
  • image types β€” returns a list whose elements are all of the valid image types (i.e., all of the values that may be supplied for the type argument to image create).
  • image width name β€” returns a decimal string giving the width of image name in pixels. πŸ“

Additional operations (e.g. writing the image to a file) may be available as subcommands of the image instance command. see the manual page for the particular image type for details. iykyk πŸ’…


🌈 BUILT-IN IMAGE TYPES 🌈

The following image types are defined by Tk so they will be available in any Tk application. individual applications or extensions may define additional types. main character energy for these four:

  • bitmap β€” each pixel in the image displays a foreground color, a background color, or nothing. see the bitmap manual entry for more information.
  • photo β€” displays a variety of full-color images, using dithering to approximate colors on displays with limited color capabilities. see the photo manual entry for more information.
  • nsimage β€” this type is only available in the Aqua platform. it is a full-color image which may be created from a named system image. it has options designed to facilitate the use of these images in buttons. an nsimage can be based on an a template image, which is an anti-aliased 2-color image format that automatically interchanges black and white in response to changes between the light and dark modes on macOS. an nsimage can also generate an alternate pressed variant which is lighter in dark mode and darker in light mode. these are for use in image buttons. see the nsimage manual entry for more information. πŸŒ—

πŸŽ€ SEE ALSO πŸŽ€

bitmap(3tk), options(3tk), photo(3tk), nsimage(3tk)


⭐ KEYWORDS ⭐

height, image, types of images, width


and that's the whole page bestie, no cap πŸ’œ this one's straight outta Tk 4.0, so if you ever forget a flag just come back here and vibe check yourself. mwah 🫢✨

πŸ“¦ where this page comes from