2012年11月15日木曜日

iOSステータスバーカッター -ステータスバー切り取ります!-

少し前に流行っていた、iOSのステータスバーを切り取るアプリ、あれのMac版です。
正直(・・・いるか?)と思ってましたが、アプリ練習用にはいい感じのテーマ。
メジャーどころは説明いらずなのがいいですね!

iOSステータスバーカッター

先に言っておくと、App Storeにはもっとちゃんとしたアプリが無料であるので、実用にはそちらを使うといいと思います。
僕のはお遊び用なので、その辺多めに見てね☆(ゝω・)vキャピ

Status Barred App
カテゴリ: 開発ツール
価格: 無料

注意



あまり書くことないのですが、すごく大事なことがひとつ。
ImageMagickをインストールしていないと動きません。

既存のコマンドだと中央からしか切り取れなかったので、ImageMagickなら無料だしコレ使っとけばいいだろっていう考え。
なにか手段があるのかもしれませんが、断念しました・・・

ImageMagickのインストール先によって動かないことがあるかもしれません。
まあそういうのはよくあることなので、書き換えるなり置き換えるなりしてください。


使いかた



普通に実行する方法と、Dropletとして使う方法があります。
実行した場合は、ファイルを選択するダイアログが出るので、選択してゴー。
Dropletの場合は、ファイルをガーッとD&Dしてゴー。
複数選択できるので、その辺は使いやすいかもです。
元ファイルは上書きされるので、気をつけましょう。

iOSステータスバーカッター

では今回のコードはこちら。

(*
iOS機のスクリーンショットからステータスバーを切り取る
・実行/Droplet両用
・要ImageMagick
遊び人からギーク系に転職したのでMacPortsいれてみた - How2すいとー
http://www.hw2-suito.com/archives/591
・iPhone 5まで対応 (2012/11/14)
*)

property screen_size_h : {"480", "1024", "960", "1136", "2048"} --iOS機の縦サイズ{iPhone 3GS,iPad,iPhone 4/4S,iPhone 5/iPad 2}
property status_bar_size : {"20", "40"}

set input to ""

--droplet
on open input
my runscript(input)
end open

--実行
if input = "" then
set input to choose file with prompt "iOSのスクリーンショットを選択" default location (path to desktop) with multiple selections allowed
end if
my runscript(input)

on runscript(input)
repeat with afile in input
set asize to my retImageSize(afile)
set size_check to my duplicate_check(screen_size_h, asize)
if a_num_list of size_check < 2 then --縦サイズからステータスバーのサイズ決定
set status_bar to item 1 of status_bar_size
else
set status_bar to item 2 of status_bar_size
end if
set item 2 of asize to (item 2 of asize) - status_bar
set apath to POSIX path of (afile as alias)
do shell script "/opt/local/bin/mogrify -crop " & item 1 of asize & "x" & item 2 of asize & "+0+" & status_bar & " " & (quoted form of apath)
end repeat
end runscript


-- AS Hole(AppleScriptの穴) By Piyomaru Software » ImageEventsで画像の縦横サイズを取得する » Blog Archive
-- http://piyocast.com/as/archives/1256
on retImageSize(anAlias)
tell application "Image Events"
launch
set thisImage to open anAlias
set b to dimensions of thisImage
close thisImage
end tell
return b
end retImageSize


(*
2つのリストから重複するアイテムを抜き出す
return:{duplication_word:{重複アイテム},a_num_list:{alistの該当ナンバー}, b_num_list:{blistの該当ナンバー}}
*)
on duplicate_check(alist, blist)
set duplication_word to {}
set a_num_list to {}
set b_num_list to {}
set c to {duplication_word:{}, a_num_list:{}, b_num_list:{}}
set a_num to 0
set b_num to 0
repeat with n in alist
set a_num to a_num + 1
repeat with m in blist
set b_num to b_num + 1
if n contains m then --なぜか=だと動かない
set end of duplication_word to n
set end of a_num_list to a_num
set end of b_num_list to b_num
end if
end repeat
set b_num to 0
end repeat
set duplication_word of c to duplication_word
set a_num_list of c to a_num_list
set b_num_list of c to b_num_list
return c
end duplicate_checks

0 件のコメント:

コメントを投稿