ztk::photo resize
Scales a photo to a size.
ztk::photo resize SRC DST WIDTH HEIGHT ?-filter smooth|nearest?
Description
A 0 for WIDTH or HEIGHT keeps the aspect ratio of SRC: the other side is rounded, and at least 1. smooth, the default, averages the area under each new pixel along a side that gets smaller, and blends the 2 nearest pixels along a side that gets larger; one side and then the other. nearest uses the pixel under the middle of each new pixel. The largest side is 8,192.
Returns
An empty string.
Examples
% image create photo s -width 4 -height 2
> s put {{red red blue blue} {red red blue blue}}
> image create photo t
> ztk::photo resize s t 2 0
> list [image width t] [image height t] [t get 0 0] [t get 1 0]
2 1 {255 0 0} {0 0 255}
% image create photo s2 -width 2 -height 1
> s2 put {{black white}}
> ztk::photo resize s2 s2 1 1
> s2 get 0 0
128 128 128
Errors
% image create photo e1 -width 2 -height 2; ztk::photo resize e1 e1 0 0
bad size "0 0": the width and the height must be 0 or more, and one more than 0
-errorcode NONE
% image create photo e2 -width 2 -height 2; ztk::photo resize e2 e2 4 4 -filter cubic
bad filter "cubic": must be smooth or nearest
-errorcode NONE
% image create photo e3 -width 2 -height 2; ztk::photo resize e3 e3 4
wrong # args: should be "ztk::photo resize src dst width height ?-filter smooth|nearest?"
-errorcode NONE
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.10