从大照片生成图块(iOs PhotoScroller) [英] Generate tiles from large photos (iOs PhotoScroller)
问题描述
我正在研究 WWDC会话#104,以掌握UIScrollViews .我需要创建一个脚本或找到一个工具或编写一个脚本,以从一些大的jpg照片生成CATiledLayer所需的图块.
I'm studdying the WWDC session #104 for mastering UIScrollViews. I need to create a script or find a tool or write a script to generate the tiles needed for the CATiledLayer from some large jpg photo.
需要1000 500和250比例因子,并且生成的图块需要遵循这样的命名模式:
1000 500 and 250 scale factors are needed and the generated tiles need to respect a naming pattern like this:
name_scale_col_row.jpg
对于我可以用于此目的的工具或脚本的任何建议,还是我需要编写一个建议?
Any suggestion for a tool or script that I could use for this or do I need to write one?
编辑:我正在编写自己的小bash脚本.这是我到目前为止所做的:
EDIT: I'm working on my own little bash script. This is what I did until now:
#!/bin/sh
file_list=`ls | grep png`
for i in 25 50 100; do
for file in $file_list; do
convert $file -scale ${i}%x${i}% -crop 256x256 \
-set filename:tile "%[fx:page.x/256]_%[fx:page.y/256]" \
+repage +adjoin "${file%.*}_${i}0_%[filename:tile].${file#*.}"
done
done
当然,它远非一个真正的工具,但它可以正常工作,并尊重Apple photocroller示例瓷砖的命名约定.任何建议,改进表示赞赏.
Of cours it's far from being a real tool but it works and respect the Apple photoscroller example naming convention for tiles. Any suggestion, improvement appreciated.
推荐答案
此脚本将自动生成您需要的所有不同分辨率的所有图块:
This script will automatically generate all the tiles you need at all the different resolutions:
一个小提示:该脚本将使用100、50等比例因子而不是1000、500等来命名所有内容.您可以通过在TilingView.m中的tileForScale:方法中将1000更改为100来对此进行调整. PhotoScroller示例.
A small heads up: that script will name everything with 100, 50, etc. scale factors rather than 1000, 500, etc. you can adjust for this by changing 1000 to 100 in the tileForScale: method in TilingView.m in the PhotoScroller example.
这篇关于从大照片生成图块(iOs PhotoScroller)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!