Giter Club home page Giter Club logo

imagescout's People

Contributors

bananita avatar esttorhe avatar kaishin avatar konradzdunczyk avatar sidraval avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imagescout's Issues

Didnot have any message in output window

let scout = ImageScout()

    scout.scoutImageWithURI("http://f.hiphotos.baidu.com/zhidao/pic/item/5d6034a85edf8db16efebe470b23dd54574e74c5.jpg") { error, size, type in
        if let unwrappedError = error {
            print(unwrappedError.code)
        } else {
            print("Size: \(size)")
            print("Type: \(type.rawValue)")
        }
    }

Error in ios 9.3

Hi, i use IOS 9.3 and the log not print anithing

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)")
}
}

Currently tail recursion is not guaranteed in Swift

This is especially problematic in Debug mode, where no tail recursion exists! I found this when some JPEGs crashed my App. This could also easily be used as an attack vector with specially crafted data.

My Solution for parsing JPEGs is to translate the parse function into a looped version:

private typealias JPEGParseTuple = (data: NSData, offset: Int, segment: JPEGHeaderSegment)

private enum JPEGParseResult {
    case Size(CGSize)
    case Tuple(JPEGParseTuple)
}

private static func parseJPEG(tuple: JPEGParseTuple) -> JPEGParseResult {
    let data = tuple.data
    let offset = tuple.offset
    let segment = tuple.segment

    if segment == .EOISegment
        || (data.length <= offset + 1)
        || (data.length <= offset + 2) && segment == .SkipSegment
        || (data.length <= offset + 7) && segment == .ParseSegment {
            return .Size(CGSizeZero)
    }
    switch segment {
    case .NextSegment:
        let newOffset = offset + 1
        var byte = 0x0; data.getBytes(&byte, range: NSRange(location: newOffset, length: 1))

        if byte == 0xFF {
            return .Tuple(JPEGParseTuple(data, offset: newOffset, segment: .SOFSegment))
        } else {
            return .Tuple(JPEGParseTuple(data, offset: newOffset, segment: .NextSegment))
        }
    case .SOFSegment:
        let newOffset = offset + 1
        var byte = 0x0; data.getBytes(&byte, range: NSRange(location: newOffset, length: 1))

        switch byte {
        case 0xE0...0xEF:
            return .Tuple(JPEGParseTuple(data, offset: newOffset, segment: .SkipSegment))
        case 0xC0...0xC3, 0xC5...0xC7, 0xC9...0xCB, 0xCD...0xCF:
            return .Tuple(JPEGParseTuple(data, offset: newOffset, segment: .ParseSegment))
        case 0xFF:
            return .Tuple(JPEGParseTuple(data, offset: newOffset, segment: .SOFSegment))
        case 0xD9:
            return .Tuple(JPEGParseTuple(data, offset: newOffset, segment: .EOISegment))
        default:
            return .Tuple(JPEGParseTuple(data, offset: newOffset, segment: .SkipSegment))
        }

    case .SkipSegment:
        var length = UInt16(0)
        data.getBytes(&length, range: NSRange(location: offset + 1, length: 2))

        let newOffset = offset + Int(CFSwapInt16(length)) - 1
        return .Tuple(JPEGParseTuple(data, offset: Int(newOffset), segment: .NextSegment))

    case .ParseSegment:
        var size = JPEGSize(); data.getBytes(&size, range: NSRange(location: offset + 4, length: 4))
        return .Size(CGSize(width: Int(CFSwapInt16(size.width)), height: Int(CFSwapInt16(size.height))))
    default:
        return .Size(CGSizeZero)
    }

}

private static func parseJPEGData(data: NSData, offset: Int, segment: JPEGHeaderSegment) -> CGSize {
    var tuple: JPEGParseResult = .Tuple(JPEGParseTuple(data, offset: offset, segment: segment))
    while true {
        switch tuple {
        case .Size(let size):
            return size
        case .Tuple(let newTuple):
            tuple = parseJPEG(newTuple)
        }
    }
}

Swift3

it'd be cool to have a swift 3 version.

error to run demo on device(iPhone5S)

with error:
dyld: Library not loaded: @rpath/ImageScout.framework/ImageScout
Referenced from: /private/var/mobile/Containers/Bundle/Application/F9A9E333-019B-46B8-8DA9-CA5B4437D2C3/Demo.app/Demo
Reason: image not found

Build failure on Carthage

with error code:
The following build commands failed:
CompileSwift normal arm64 /Users/BourneWang/Desktop/ImageScout-master/Demo/Carthage/Checkouts/ImageScout/Source/ImageScout.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)

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.