从大照片生成图块 (iOs PhotoScroller)
我正在学习 WWDC 会议#104 以掌握 UIScrollViews。我需要创建一个脚本或找到一个工具或编写一个脚本来从一些大的 jpg 照片生成 CATiledLayer 所需的图块。
需要 1000 500 和 250 比例因子,并且生成的图块需要遵循如下命名模式:
name_scale_col_row.jpg
对于我可以用于此目的的工具或脚本有什么建议,还是我需要编写一个?
编辑:我正在编写自己的小 bash 脚本。这就是我到目前为止所做的:
#!/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 photoscroller 示例图块的命名约定。任何建议、改进表示赞赏。
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 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?
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
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该脚本将自动生成您需要的所有不同分辨率的图块:
http://www.mikelin.ca/blog/2010/06/iphone-splitting-image-into-tiles-for-faster-loading-with-imagemagick/
一个小注意事项:该脚本将以 100、50 等比例因子命名所有内容,而不是 1000、500 等。您可以通过在 TilingView.m 的tileForScale: 方法中将 1000 更改为 100 来对此进行调整在 PhotoScroller 示例中。
This script will automatically generate all the tiles you need at all the different resolutions:
http://www.mikelin.ca/blog/2010/06/iphone-splitting-image-into-tiles-for-faster-loading-with-imagemagick/
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.
我也在寻找一个生成图块的工具,并发现 Photoshop(CS3 或更高版本)包含一个为名为 Zoomify 的工具创建 JPEG 图块的选项。从菜单中选择“文件”>“出口> Zoomify...并在“浏览器选项”中填写 256 x 256 像素的tileSize。
单击 [确定] 后,将创建一个包含 256 像素图块的文件夹 TileGroup0。
这些文件的名称为:
zoomlevel-column-row.jpg
,而 Photoscroller 的示例文件的名称为filename_scale_column_row.png
(0-0-0.jpg
) code> 文件可以被丢弃)。因此,相应地重命名 jpg 文件(1- = 125_、2- = 250_、3- = 500_
等)或仅修复tileForScale 中的
(TilingView.m) 加载正确的 jpg 文件。tileName
: row:col:I was also looking for a tool to generate tiles and found out Photoshop (CS3 or later) includes an option to create JPEG tiles for a tool called Zoomify. From the menu choose File > Export > Zoomify... and in 'Browser Options' fill in the tileSize of 256 x 256 pixels.
After clicking [OK] a folder TileGroup0 will be created with the 256 pixel tiles.
The files are named:
zoomlevel-column-row.jpg
, whereas Photoscroller's example files are namedfilename_scale_column_row.png
(the0-0-0.jpg
file can be discarded). So rename the jpg-files accordingly (1- = 125_, 2- = 250_, 3- = 500_
, etc.) or just fixtileName
intileForScale:row:col:
(TilingView.m) to load the correct jpg file.我正在使用两个工具 - Tilen 来切碎图像,不幸的是,这会开始平铺编号为 1,然后使用更好的重命名来调整图块编号并向名称添加适当的前缀和后缀。他们一起做得很好。
I'm using two tools--Tilen for chopping up the image, which unfortunately starts tile numbering at 1, and then Better Rename for adjusting the tile numbering and adding appropriate prefixes and suffixes to the names. Together they do a great job.