GithubHelp home page GithubHelp logo

nvdnkpr / imagescout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kaishin/imagescout

0.0 2.0 0.0 938 KB

A Swift implementation of fastimage. Supports PNG, GIF, and JPEG.

License: MIT License

imagescout's Introduction

Travis

ImageScout is a Swift implementation of fastimage. It allows you to find the size and type of a remote image by downloading as little as possible.

Why?

Sometimes you need to know the size of a remote image before downloading it, such as using a custom layout in a UICollectionView.

How?

ImageScout parses the image data as it is downloaded. As soon as it finds out the size and type of image, it stops the download. The downloaded data is below 60 KB in most cases.

Install

Use Git submodules. You want to add the file(s) in source to your Xcode project.

Usage

The only method you will be using is scoutImageWithURI(), with the following full signature:

func scoutImageWithURI(URI: String, completion: (NSError?, CGSize, ScoutedImageType) -> ())

Here's an example:

let scout = ImageScout()

scout.scoutImageWithURI("http://.../image-scout-logo.png") { error, size, type in
  if let unwrappedError = error {
    println(unwrappedError.code)
  } else {
    println("Size: \(size)")
    println("Type: \(type.rawValue)")
  }
}

If the image is not successfully parsed, the error will contain more info about the reason. In that case, the size is going to be CGSizeZero and the type .Unsupported.

  • Error code 100: Invalid URI parameter.
  • Error code 101: Image is corrput or malformatted.
  • Error code 102: Not an image or unsopported image format URL.

Compatibility

  • iOS 7.0 and above.
  • Compiles with Xcode 6.1 and above.

License

See LICENSE.

imagescout's People

Watchers

Navid Nikpour avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.