12
11

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.

画像サイズを取得するコマンド

Posted at

retina対応でspriteの画像サイズが奇数になっていると、潰れちゃったりするので、
画像サイズを取得する方法を考えてみました。
「画像サイズを取得 コマンド」をググるidentifyを使っている記事が多くみられたのですが、
file コマンドでも代用できますね、必要に応じてawkコマンド必要な列だけ取得するのにも使えると思います。

$  identify -format '%wx%h\n' *
36x36
50x22
46x46
68x36
68x36
10x9
10x10
26x70
26x70

$ file *                           
sprite_arrowleft.png:  PNG image data, 36 x 36, 8-bit/color RGBA, non-interlaced
sprite_bottom.png:     PNG image data, 50 x 22, 8-bit/color RGBA, non-interlaced
sprite_close.png:      PNG image data, 46 x 46, 8-bit/color RGBA, non-interlaced
sprite_exp.png:        PNG image data, 68 x 36, 8-bit/color RGB, non-interlaced
sprite_new.png:        PNG image data, 68 x 36, 8-bit/color RGB, non-interlaced
sprite_slickball0.png: PNG image data, 10 x 9, 8-bit grayscale, non-interlaced
sprite_slickball1.png: PNG image data, 10 x 10, 8-bit grayscale, non-interlaced
sprite_slickleft.png:  PNG image data, 26 x 70, 8-bit gray+alpha, non-interlaced
sprite_slickright.png: PNG image data, 26 x 70, 8-bit gray+alpha, non-interlaced

画像のリサイズにはmogrifyコマンドを使いました

(縦横比保持)
$ mogrify -geometry 10x10 sprite_slickball0.png

(縦横比保持しない)
$ mogrify -geometry 10x10! sprite_slickball0.png 
12
11
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
12
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?