beetlebug▾
/

ztk::photo

Resizes, crops, turns, and mirrors a photo, and reads the EXIF orientation of an image file.

ztk::photo SUBCOMMAND ?ARG ...?

Description

The operations of ztk on the pixels of a photo, for a thumbnail, a crop, or a photo from a phone. The photo command of Tk has none of these, so they are a command of their own and the photo command keeps the subcommands of Tk. The code is ztk's own, so each platform gives the same pixels.

SRC and DST are names of photos, and DST can be SRC. DST gets the size of the result, with -width and -height 0, and the -density of SRC. A blend of pixels works on the colors times their alpha, so a clear pixel gives no dark edge.

A photo from a phone: set o [ztk::photo orientation $bytes]; image create photo p -data $bytes; ztk::photo orient p p $o; ztk::photo resize p thumb 200 0. A photo that reads a file leaves its orientation alone, as in Tk.

Subcommands

SubcommandDescription
ztk::photo resizeScales a photo to a size.
ztk::photo cropCuts a region out of a photo.
ztk::photo rotateTurns a photo anticlockwise.
ztk::photo flipMirrors a photo left to right, or top to bottom.
ztk::photo orientationGives the EXIF orientation of the bytes of an image file.
ztk::photo orientTurns and mirrors a photo so an image of an EXIF orientation shows upright.

Examples

% image create photo s -width 2 -height 1
> s put {{red blue}}
> image create photo d
> ztk::photo flip s d horizontal
> d get 0 0
0 0 255

Errors

% ztk::photo
wrong # args: should be "ztk::photo subcommand ?arg ...?"
-errorcode NONE

% ztk::photo bogus
unknown or ambiguous subcommand "bogus": must be crop, flip, orient, orientation, resize, or rotate
-errorcode NONE

% ztk::photo flip nope nope horizontal
image "nope" doesn't exist or is not a photo image
-errorcode NONE

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.10

See also