High Quality Image ScrollView using cropped tiled images.

Overview

THTiledImageView

Build Status Code Coverage Version platform License Swift 4.0

Feature

  • πŸ–Ό THTiledImageView fully support UIScrollView. You can subclass it and use it.
  • πŸ“‘ Support Async Image Downloading & Caching.
  • πŸ” You can set different tiled images based on user's zoom scale.
  • πŸ”ͺ Support Image Cutting Extension Method to generate tiled images.

Demo

THTileImageView

Installation

CocoaPods

You can install the latest release version of CocoaPods with the following command

$ gem install cocoapods

Simply add the following line to your Podfile:

pod "Kingfisher"
pod "THTiledImageView"

Then, run the following command:

$ pod install

Requirements

THTiledImageView is written in Swift 4, and compatible with iOS 9.0+. We use Kingfisher library for image downloading and caching. So you need to install Kingfisher also to use THTiledImageView.

How to use

  1. THTiledImageScrollView is subclass of UIScrollVIew. Create THTiledImageScrollView from Storyboard or programmatically.
class ViewController: UIViewController {
    @IBOutlet weak var tileImageScrollView: THTiledImageScrollView!
}
  1. Create dataSource class that conforms THTiledImageViewDataSource.
class ViewController: UIViewController {
    @IBOutlet weak var tileImageScrollView: THTiledImageScrollView!

    var dataSource: THTiledImageViewDataSource?
}
  1. Here is THTiledImageViewDataSource options that you can use.
func setupExample(tileImageBaseURL: URL, imageSize: CGSize, tileSize: [CGSize], thumbnail: URL) {

    dataSource = MyTileImageViewDataSource(tileImageBaseURL: tileImageBaseURL, imageSize: imageSize, tileSize: tileSize)

    guard let dataSource = dataSource else { return }

    dataSource.thumbnailImageName = "bench"

    // User can see this level of tiles when they zoom in the image
    dataSource.maxTileLevel = 3

    // User can see this level of tiles when they zoom out the image
    dataSource.minTileLevel = 1

    // Allowable maximum level of scrollView zoom
    dataSource.maxZoomLevel = 8

    dataSource.imageExtension = "jpg"

    // Local Image For Background
    dataSource.setBackgroundImage(url: thumbnail)

    // Remote Image For Background
    dataSource.backgroundImageURL = URL(string: "Image URL goes here")
    dataSource.requestBackgroundImage { _ in }

    // size of scrollView Frame
    dataSource.scrollViewSize = setScrollViewSize()

    tileImageScrollView.set(dataSource: dataSource)
}

Async Image Downloading & Caching

From Version 0.3.0, We support setting tile image from remote server.

  • Set the base URL that you want to download image, and set the accessFromServer option to true.
dataSource.tileImageBaseURL = URL(string: "http://127.0.0.1:5000")
dataSource.accessFromServer = true
  • Put tiled images on your Server. Take a look at our image path rules to use downloading.

Zoom and Tile Level

THTiledImageView's zoom level and tile level can be set separately.

Zoom Level

UIScrollView's Zoom level. Default minimum zoom level is scale aspect fit size of scrollView. maximum zoom level is allowable zoom in level.

Tile Level

Tiled images can be shown at specific zoom level based on tile level. For example, if you set (minTileLevel, maxTileLevel) = (1, 5), You can set 5 different images by tile level.

Tile level 1 can be used wide range of image.

Tile level 5(or more than 1) can be used narrow range of image.

Cutting Image

❗️ Cutting and rendering images cannot be done simultaneously. You should cut images first(from another viewController), and render the image.

We offer you image cutting function(UIImage.saveTileOf(size:name:withExtension:). Specify the size of tiles by levels.

// size and level will be 512-1, 256-2, 128-3(size-level).
let tiles: [CGSize] = [CGSize(width: 512, height: 512),
                       CGSize(width: 256, height: 256), CGSize(width: 128, height: 128)]

// static function
UIImage.saveTileOf(size: tiles, name: "bench", withExtension: "jpg")

Tiled Images path

Tiled images will be saved on your cache directory. Path of the cache directory:

let cachesPath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)[0] as String

If imagefile saved successfully, you can see images from cache directory. Here is the rule of directory path and image file name rules.

Path Rules ./imageName/imageSize/{imageName_imageSize_level_x_y}.jpg
Example    ./bench/256/bench_256_1_0_0.jpg

❗️ If you create images on your own, you need to obey the path rules to use THTileImageView.

Tiled Images path For Server

  1. Put tiles on your server. path of image should looks like this.
http://127.0.0.1:5000/bench/256/bench_256_1_0_0.jpg

All you need to do is go to the cache directory and take out and put that directory to your server.

THTiledImageScrollViewDelegate

You can use UIScrollViewDelegate methods from THTiledImageScrollViewDelegate.

public protocol THTiledImageScrollViewDelegate: class {
    func didScroll(scrollView: THTiledImageScrollView)
    func didZoom(scrollView: THTiledImageScrollView)
}

See our example for more details.

License

THTiledImageView is released under the MIT license. See LICENSE for details.

You might also like...
WhiteAndFluffyTest - Scroll images and add them to your favourites via image page
WhiteAndFluffyTest - Scroll images and add them to your favourites via image page

Image service application Scroll images and add them to your favourites via imag

FlaneurImagePicker is an iOS image picker that allows users to pick images from different sources (ex: user's library, user's camera, Instagram...).                            It's highly customizable.
FlaneurImagePicker is an iOS image picker that allows users to pick images from different sources (ex: user's library, user's camera, Instagram...). It's highly customizable.

FlaneurImagePicker is a highly customizable iOS image picker that allows users to pick images from different sources (ex: device's library, device's c

An image download extension of the image view written in Swift for iOS, tvOS and macOS.
An image download extension of the image view written in Swift for iOS, tvOS and macOS.

Moa, an image downloader written in Swift for iOS, tvOS and macOS Moa is an image download library written in Swift. It allows to download and show an

AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.

URLImage URLImage is a SwiftUI view that displays an image downloaded from provided URL. URLImage manages downloading remote image and caching it loca

AYImageKit is a Swift Library for Async Image Downloading, Show Name's Initials and Can View image in Separate Screen.
AYImageKit is a Swift Library for Async Image Downloading, Show Name's Initials and Can View image in Separate Screen.

AYImageKit AYImageKit is a Swift Library for Async Image Downloading. Features Async Image Downloading. Can Show Text Initials. Can have Custom Styles

A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image.

QRDecode A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image. QRDecode

Convert the image to hexadecimal to send the image to e-paper

ConvertImageToHex Convert the image to hexadecimal to send the image to e-paper Conversion Order // 0. hex둜 λ³€ν™˜ν•  이미지 var image = UIImage(named: "sample

Twitter Image Pipeline is a robust and performant image loading and caching framework for iOS clients

Twitter Image Pipeline (a.k.a. TIP) Background The Twitter Image Pipeline is a streamlined framework for fetching and storing images in an application

Image-cropper - Image cropper for iOS

Image-cropper Example To run the example project, clone the repo, and run pod in

Comments
  • Async Image Setting

    Async Image Setting

    Issue #4

    • Support getting and downloading Cropped Images from remote url(server). All works can be done asynchronously.

    Sub Issue

    • Give Setting Background Image options.
    1. local URL
    2. remote URL
    feature enhancement 
    opened by hcn1519 1
Releases(0.3.2.1)
Owner
null
An implementation of High Pass Skin Smoothing using Apple's Core Image Framework

YUCIHighPassSkinSmoothing An implementation of High Pass Skin Smoothing using CoreImage.framework Available on both OS X and iOS. Ports A MetalPetal b

Yu Ao 1.2k Dec 17, 2022
APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS.

APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS. It's built on top of a modified version of libpng wit

Wei Wang 2.1k Dec 30, 2022
An extremely high-performance, lightweight, and energy-efficient pure Swift async web image loader with memory and disk caching for iOS and ο£Ώ Watch.

KFSwiftImageLoader KFSwiftImageLoader is an extremely high-performance, lightweight, and energy-efficient pure Swift async web image loader with memor

Kiavash Faisali 343 Oct 29, 2022
A pure Swift high-performance asynchronous image loading framework. SwiftUI supported.

Longinus Longinus is a pure-Swift high-performance asynchronous web image loading,caching,editing framework. It was learned from Objective-C web image

Qitao Yang 290 Dec 17, 2022
πŸ“· A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component ?? v2.0.0-alpha now open!

Muukii 2.8k Jan 3, 2023
πŸ“· A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component ?? v2.0.0-alpha now open!

Muukii 2.8k Jan 2, 2023
Agrume - πŸ‹ An iOS image viewer written in Swift with support for multiple images.

Agrume An iOS image viewer written in Swift with support for multiple images. Requirements Swift 5.0 iOS 9.0+ Xcode 10.2+ Installation Use Swift Packa

Jan Gorman 601 Dec 26, 2022
Image viewer (or Lightbox) with support for local and remote videos and images

Table of Contents Features Focus Browse Rotation Zoom tvOS Setup Installation License Author Features Focus Select an image to enter into lightbox mod

Nes 534 Jan 3, 2023
Jogendra 113 Nov 28, 2022
React-native-image-generator - Library to generate images from layers

react-native-image-generator Library for generate images from other images Insta

Evgeny Usov 13 Nov 16, 2022