image(3tk)
π 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.typesays what kind of image it is, and it has to be one of the types currently defined (e.g.,bitmap).nameis what you're naming the image; if you leave it out, Tk picks a name of the formimagex, wherexis 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: theimagecommand 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 toimage create, the existing instances will use the new image. iconic behavior honestly β¨image height nameβ returns a decimal string giving the height of imagenamein pixels. πimage inuse nameβ returns a boolean value saying whether or not the image given bynameis 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 imagename(that's the value of thetypeargument toimage createback 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 thetypeargument toimage create).image width nameβ returns a decimal string giving the width of imagenamein 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 thebitmapmanual entry for more information.photoβ displays a variety of full-color images, using dithering to approximate colors on displays with limited color capabilities. see thephotomanual 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. annsimagecan 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. annsimagecan 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 thensimagemanual 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
- 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) 1994 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms