Generate tiles from large photos (iOs PhotoScroller)

大兔子大兔子 提交于 2019-12-04 10:01:45

问题


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.


回答1:


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.




回答2:


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 named filename_scale_column_row.png (the 0-0-0.jpg file can be discarded). So rename the jpg-files accordingly (1- = 125_, 2- = 250_, 3- = 500_, etc.) or just fix tileName in tileForScale:row:col: (TilingView.m) to load the correct jpg file.




回答3:


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.



来源:https://stackoverflow.com/questions/4403263/generate-tiles-from-large-photos-ios-photoscroller

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!