1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

tcl/tkで画像をリサイズする

Last updated at Posted at 2018-07-27

任意の大きさの画像を読み込んで描画エリアの大きさにあわせて描画しようとしたところ、意外と標準コマンドだけでできなかった。
標準コマンドでできるのは整数倍に拡大縮小だけで(何故・・・)、pure tclな実装もあったけど遅すぎて使い物にならず。
Imgtoolsでうまくできたのでメモを残しておく。
wish8.6が動いている前提です。

セットアップ
$ wget https://downloads.sourceforge.net/project/tkimgtools/0.3/imgtools-0.3.tar.gz
$ tar xzf imgtools-0.3.tar.gz
$ cd imgtools-0.3
$ ./configure
$ make
resize_img.tcl
#!/usr/bin/env wish

lappend auto_path {./imgtools-0.3}
package require imgtools 0.3
wm geometry . 640x480
canvas .c -bg blue
pack .c -expand 1 -fill both
image create photo dst_img
image create photo src_img -file 1.png
::imgtools::scale src_img 640x480 dst_img
.c create image 0 0 -image dst_img -anchor nw
実行
$ wish resize_img.tcl

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?