SlideShare a Scribd company logo
1 of 48
Download to read offline
2015/07/19 11:58
1/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
いまさら聞けないいまさら聞けない
画像自動処理画像自動処理
@kanayannet
Gunma.web #20
2015/07/19 11:58
2/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
きょう話す事きょう話す事
なぜ今この話?
よくある処理
比較的よくある処理
ちょっと聞かないかも?しれない処理
思わぬ罠
まとめ
2015/07/19 11:58
3/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
怖い話怖い話....
ちまたで偉い人が画像や通信の最適化など
色々話されていますが..
2015/07/19 11:58
4/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
全くの偶然です全くの偶然です!!
タイミングが被っただけです。
ごめんなさい。
不備がございましたらご容赦ください。 m(__)m
2015/07/19 11:58
5/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
なぜ今この話なぜ今この話??
最近、画像処理に関わる事が多いよな∼
不具合調整
過去の遺産..orz
2015/07/19 11:58
6/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
過去の遺産過去の遺産 == 悪悪??
必ずきっかけ、経緯があるはず。
作った時は良かれと思ってやった事。
2015/07/19 11:58
7/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
経緯経緯 == ユーザの要望ユーザの要望
と考えて成功、失敗談を話せれば..
興味を持ってもらえる話になりそう。
2015/07/19 11:58
8/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
よくある画像処理よくある画像処理
画面に収まりきらない大きい画像を
表示させる場合
2015/07/19 11:58
9/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
「縮小して表示して!」「縮小して表示して!」
2015/07/19 11:58
10/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
HTMLHTMLタグで調整する方法もタグで調整する方法も
ありますがありますが....
<<imgimg srcsrc==""画像ファイル名"" widthwidth==""横幅"" heightheight==""高さ"">>
2015/07/19 11:58
11/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
画像容量は小さくならない画像容量は小さくならない
アクセス頻度が高いサイトでトラフィック
(通信量)平気?
ユーザの通信環境は平気?
携帯電話は平気?
2015/07/19 11:58
12/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
表示する大きさに画像を表示する大きさに画像を
convertconvert
容量は結果小さくなる。
2015/07/19 11:58
13/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
一つ一つの画像に対して一つ一つの画像に対して
都度行う都度行う
2015/07/19 11:58
14/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
手動でやると面倒臭い手動でやると面倒臭い
一般ユーザはやりたがらない。
2015/07/19 11:58
15/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
自動で縮小自動で縮小
ImageMagick
2015/07/19 11:58
16/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
プログラムから呼び出せるプログラムから呼び出せる
convert -resize 400x300 input.jpg output.jpg
今回のコマンドはImageMagickメインで解説します。
2015/07/19 11:58
17/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
よくある画像処理よくある画像処理 終了終了
Are You OK ?
2015/07/19 11:58
18/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
比較的よくある画像処理比較的よくある画像処理
画像を一覧で表示したい場合
小さい画像を並べますよね?
2015/07/19 11:58
19/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
全体的に小さくすると全体的に小さくすると
メインの被写体が見えずらくなる場合がある。
2015/07/19 11:58
20/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
例例
2015/07/19 11:58
21/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
小さくしてみた小さくしてみた
2015/07/19 11:58
22/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
どうするのどうするの??
Crop
2015/07/19 11:58
23/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
CropCropの定義の定義
画像から xxPX を抜き出す
2015/07/19 11:58
24/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
コマンドでやるとこんな感じですね。コマンドでやるとこんな感じですね。
convert -crop 横x縦+横の切抜位置+縦の切抜位置 input.jpg output.jpg
2015/07/19 11:58
25/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
Before -> AfterBefore -> After
2015/07/19 11:58
26/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
切抜位置の適切な数値は切抜位置の適切な数値は....
サイトのユーザがアップする画像の特徴を反映する必要がある。
ユーザに委ねたい時は javascriptなどで簡単に切り抜けるGUI
用意...(ry
2015/07/19 11:58
27/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
比較的よく聞く話比較的よく聞く話::終了終了
2015/07/19 11:58
28/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
ちょっと聞かないちょっと聞かない
画像処理画像処理
2015/07/19 11:58
29/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
アニメアニメGIFGIF
みなさん知ってますよね?
2015/07/19 11:58
30/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
アニメアニメGIFGIF にも色々ありますよ。にも色々ありますよ。
2015/07/19 11:58
31/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
パラパラアニメ方式パラパラアニメ方式
一枚一枚を連続で再生
2015/07/19 11:58
32/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
フレーム差分の最適化フレーム差分の最適化
動きがある部分の差分情報で再生する方式
先ほどのパラパラアニメよりも容量が小さい
参考(英語)
http://www.imagemagick.org/Usage/anim_opt/#opt_trans
2015/07/19 11:58
33/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
これをこれを -resize option-resize option だけでだけで
convertconvert するとすると......
画像の容量が大幅に増える場合があります(汗)
差分アニメでは無くなってしまう。
黒い部分が変に混ざる場合も..(壊れる)
2015/07/19 11:58
34/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
こうすると上手くいくこうすると上手くいく
convert input.gif -coalesce -layers OptimizeTransparency -resize 横x縦
output.gif
2015/07/19 11:58
35/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
ちょっと聞かないちょっと聞かない
画像処理画像処理::終了終了
2015/07/19 11:58
36/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
思わぬ罠思わぬ罠
2015/07/19 11:58
37/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
画像の横、縦の取得方法画像の横、縦の取得方法((コマンドコマンド))
identify input.gif
2015/07/19 11:58
38/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
こんな情報が返却させるこんな情報が返却させる
input.gif GIF 116x116 116x116+0+0 PseudoClass 256c 5kb
2015/07/19 11:58
39/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
ところでアニメところでアニメgifgif ってどうなんだろってどうなんだろ??
2015/07/19 11:58
40/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
むむむむ!!
input.gif[0] GIF 236x42 236x42+0+0 PseudoClass 256c 4e+01kb
input.gif[1] GIF 236x42 236x42+0+0 PseudoClass 128c 4e+01kb
input.gif[2] GIF 236x42 236x42+0+0 PseudoClass 128c 4e+01kb
input.gif[3] GIF 236x42 236x42+0+0 PseudoClass 256c 4e+01kb
input.gif[4] GIF 236x42 236x42+0+0 PseudoClass 256c 4e+01kb
2015/07/19 11:58
41/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
これってこれって 22枚目から枚目から
サイズ大きくとかあるサイズ大きくとかある??
2015/07/19 11:58
42/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
あるねあるね......
2015/07/19 11:58
43/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
identifyidentify で確認で確認
atack.gif[0] GIF 32x31 1216x1201+16+15 8-bit sRGB 8c 21.8KB 0.000u
0:00.000 atack.gif[1] GIF 1200x1105 1216x1201+2+9 8-bit sRGB 8c 21.8KB
0.000u 0:00.000 atack.gif[2] GIF 1200x1132 1216x1201+3+8 8-bit sRGB 8c
21.8KB 0.000u 0:00.000
2015/07/19 11:58
44/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
これを考慮し忘れるとこれを考慮し忘れると......
atack.gif[0] GIF 32x31
だけで横幅を認識 -> PGは縮小する必要なしと判断
2015/07/19 11:58
45/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
convertconvert されずにされずに すり抜けるすり抜ける
2015/07/19 11:58
46/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
余談余談
imagemagick の option はかなりあるよ
http://www.imagemagick.org/script/command-line-
options.php
2015/07/19 11:58
47/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
まとめまとめ
画像処理は奥が深い
ImageMagick の optionの数 パネエ
アニメGIF怖い!
2015/07/19 11:58
48/48 ページhttp://localhost:3000/image_convert.md?print-pdf=1#/4/2
ご清聴ご清聴
ありがとうございましたありがとうございました

More Related Content

More from Net Kanayan (20)

Open source
Open sourceOpen source
Open source
 
Http2入門の入門
Http2入門の入門Http2入門の入門
Http2入門の入門
 
Es6 cognition
Es6 cognitionEs6 cognition
Es6 cognition
 
ES6 はじめました
ES6 はじめましたES6 はじめました
ES6 はじめました
 
Fxos lt
Fxos ltFxos lt
Fxos lt
 
Ssl
SslSsl
Ssl
 
Blueberrypi
BlueberrypiBlueberrypi
Blueberrypi
 
Browser push notifications
Browser push notificationsBrowser push notifications
Browser push notifications
 
Windows store app html
Windows store app htmlWindows store app html
Windows store app html
 
Sass less
Sass lessSass less
Sass less
 
Ll xcode
Ll xcodeLl xcode
Ll xcode
 
Web creed
Web creedWeb creed
Web creed
 
Js mvc
Js mvcJs mvc
Js mvc
 
Tdd&peapro
Tdd&peaproTdd&peapro
Tdd&peapro
 
J S Smartphone
J S SmartphoneJ S Smartphone
J S Smartphone
 
Nseg jquery mobile
Nseg jquery mobileNseg jquery mobile
Nseg jquery mobile
 
Smart phone gunma.web
Smart phone gunma.webSmart phone gunma.web
Smart phone gunma.web
 
Smart phone
Smart phoneSmart phone
Smart phone
 
2010 12gunmaweb
2010 12gunmaweb2010 12gunmaweb
2010 12gunmaweb
 
Html5 css3 websocket
Html5 css3 websocketHtml5 css3 websocket
Html5 css3 websocket
 

Image convert