Coder Social home page Coder Social logo

alamofireimage's Introduction

Alamofire: Elegant Networking in Swift

Swift Platforms CocoaPods Compatible Carthage Compatible Swift Package Manager Swift Forums

Alamofire is an HTTP networking library written in Swift.

Features

  • Chainable Request / Response Methods
  • Swift Concurrency Support Back to iOS 13, macOS 10.15, tvOS 13, and watchOS 6.
  • Combine Support
  • URL / JSON Parameter Encoding
  • Upload File / Data / Stream / MultipartFormData
  • Download File using Request or Resume Data
  • Authentication with URLCredential
  • HTTP Response Validation
  • Upload and Download Progress Closures with Progress
  • cURL Command Output
  • Dynamically Adapt and Retry Requests
  • TLS Certificate and Public Key Pinning
  • Network Reachability
  • Comprehensive Unit and Integration Test Coverage
  • Complete Documentation

Write Requests Fast!

Alamofire's compact syntax and extensive feature set allow requests with powerful features like automatic retry to be written in just a few lines of code.

// Automatic String to URL conversion, Swift concurrency support, and automatic retry.
let response = await AF.request("https://httpbin.org/get", interceptor: .retryPolicy)
                       // Automatic HTTP Basic Auth.
                       .authenticate(username: "user", password: "pass")
                       // Caching customization.
                       .cacheResponse(using: .cache)
                       // Redirect customization.
                       .redirect(using: .follow)
                       // Validate response code and Content-Type.
                       .validate()
                       // Produce a cURL command for the request.
                       .cURLDescription { description in
                         print(description)
                       }
                       // Automatic Decodable support with background parsing.
                       .serializingDecodable(DecodableType.self)
                       // Await the full response with metrics and a parsed body.
                       .response
// Detailed response description for easy debugging.
debugPrint(response)

Component Libraries

In order to keep Alamofire focused specifically on core networking implementations, additional component libraries have been created by the Alamofire Software Foundation to bring additional functionality to the Alamofire ecosystem.

  • AlamofireImage - An image library including image response serializers, UIImage and UIImageView extensions, custom image filters, an auto-purging in-memory cache, and a priority-based image downloading system.
  • AlamofireNetworkActivityIndicator - Controls the visibility of the network activity indicator on iOS using Alamofire. It contains configurable delay timers to help mitigate flicker and can support URLSession instances not managed by Alamofire.

Requirements

Platform Minimum Swift Version Installation Status
iOS 10.0+ / macOS 10.12+ / tvOS 10.0+ / watchOS 3.0+ 5.7.1 / Xcode 14.1 CocoaPods, Carthage, Swift Package Manager, Manual Fully Tested
Linux Latest Only Swift Package Manager Building But Unsupported
Windows Latest Only Swift Package Manager Building But Unsupported
Android Latest Only Swift Package Manager Building But Unsupported

Known Issues on Linux and Windows

Alamofire builds on Linux, Windows, and Android but there are missing features and many issues in the underlying swift-corelibs-foundation that prevent full functionality and may cause crashes. These include:

  • ServerTrustManager and associated certificate functionality is unavailable, so there is no certificate pinning and no client certificate support.
  • Various methods of HTTP authentication may crash, including HTTP Basic and HTTP Digest. Crashes may occur if responses contain server challenges.
  • Cache control through CachedResponseHandler and associated APIs is unavailable, as the underlying delegate methods aren't called.
  • URLSessionTaskMetrics are never gathered.
  • WebSocketRequest is not available.

Due to these issues, Alamofire is unsupported on Linux, Windows, and Android. Please report any crashes to the Swift bug reporter.

Migration Guides

Communication

Installation

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the dependencies value of your Package.swift or the Package list in Xcode.

dependencies: [
    .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.9.1"))
]

Normally you'll want to depend on the Alamofire target:

.product(name: "Alamofire", package: "Alamofire")

But if you want to force Alamofire to be dynamically linked (do not do this unless you're sure you need it), you can depend on the AlamofireDynamic target:

.product(name: "AlamofireDynamic", package: "Alamofire")

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Alamofire into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'Alamofire'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate Alamofire into your Xcode project using Carthage, specify it in your Cartfile:

github "Alamofire/Alamofire"

Manually

If you prefer not to use any of the aforementioned dependency managers, you can integrate Alamofire into your project manually.

Embedded Framework

  • Open up Terminal, cd into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:

    $ git init
  • Add Alamofire as a git submodule by running the following command:

    $ git submodule add https://github.com/Alamofire/Alamofire.git
  • Open the new Alamofire folder, and drag the Alamofire.xcodeproj into the Project Navigator of your application's Xcode project.

    It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.

  • Select the Alamofire.xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.

  • Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.

  • In the tab bar at the top of that window, open the "General" panel.

  • Click on the + button under the "Embedded Binaries" section.

  • You will see two different Alamofire.xcodeproj folders each with two different versions of the Alamofire.framework nested inside a Products folder.

    It does not matter which Products folder you choose from, but it does matter whether you choose the top or bottom Alamofire.framework.

  • Select the top Alamofire.framework for iOS and the bottom one for macOS.

    You can verify which one you selected by inspecting the build log for your project. The build target for Alamofire will be listed as Alamofire iOS, Alamofire macOS, Alamofire tvOS, or Alamofire watchOS.

  • And that's it!

    The Alamofire.framework is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.

Contributing

Before contributing to Alamofire, please read the instructions detailed in our contribution guide.

Open Radars

The following radars have some effect on the current implementation of Alamofire.

  • rdar://21349340 - Compiler throwing warning due to toll-free bridging issue in the test case
  • rdar://26870455 - Background URL Session Configurations do not work in the simulator
  • rdar://26849668 - Some URLProtocol APIs do not properly handle URLRequest

Resolved Radars

The following radars have been resolved over time after being filed against the Alamofire project.

  • rdar://26761490 - Swift string interpolation causing memory leak with common usage.
    • (Resolved): 9/1/17 in Xcode 9 beta 6.
  • rdar://36082113 - URLSessionTaskMetrics failing to link on watchOS 3.0+
    • (Resolved): Just add CFNetwork to your linked frameworks.
  • FB7624529 - urlSession(_:task:didFinishCollecting:) never called on watchOS
    • (Resolved): Metrics now collected on watchOS 7+.

FAQ

What's the origin of the name Alamofire?

Alamofire is named after the Alamo Fire flower, a hybrid variant of the Bluebonnet, the official state flower of Texas.

Credits

Alamofire is owned and maintained by the Alamofire Software Foundation. You can follow them on Twitter at @AlamofireSF for project updates and releases.

Security Disclosure

If you believe you have identified a security vulnerability with Alamofire, you should report it as soon as possible via email to [email protected]. Please do not post it to a public issue tracker.

Sponsorship

The ASF is looking to raise money to officially stay registered as a federal non-profit organization. Registering will allow Foundation members to gain some legal protections and also allow us to put donations to use, tax-free. Sponsoring the ASF will enable us to:

  • Pay our yearly legal fees to keep the non-profit in good status
  • Pay for our mail servers to help us stay on top of all questions and security issues
  • Potentially fund test servers to make it easier for us to test the edge cases
  • Potentially fund developers to work on one of our projects full-time

The community adoption of the ASF libraries has been amazing. We are greatly humbled by your enthusiasm around the projects and want to continue to do everything we can to move the needle forward. With your continued support, the ASF will be able to improve its reach and also provide better legal safety for the core members. If you use any of our libraries for work, see if your employers would be interested in donating. Any amount you can donate, whether once or monthly, to help us reach our goal would be greatly appreciated.

Sponsor Alamofire

Supporters

MacStadium provides Alamofire with a free, hosted Mac mini.

Powered by MacStadium

License

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

alamofireimage's People

Contributors

alexanderedge avatar arsonik avatar banannzza avatar baza207 avatar bradleybernard avatar brandenr avatar cnoon avatar cschep avatar djk12587 avatar erulezz avatar fsaint avatar graphiclife avatar hybridcattt avatar ishaq avatar jarrodrobins avatar jksy avatar jorjuela33 avatar jrgoodle avatar jshier avatar justinjiadev avatar kcharwood avatar kimdv avatar klaas avatar kylef avatar larsacus avatar lickel avatar mathiasnagler avatar natecook1000 avatar slaunchaman avatar xsdlr 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  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

alamofireimage's Issues

Bump to use Alamofire 3.0.0

@cnoon Now that Alamofire 3.0.0 has been released, would you please push a new version of this library that has a dependency on the stable release?

Thanks!

Store images on disk

Hey!

I have an idea for a feature.

Some apps store images in the disk and i could work following

1: The app check if the image is stored on the disk
2: If the image is stored on the disk, i should load it

  • If it's not stored i download the image.

It would be a sweet ass feature for AlamofireImage :o)

Cheers
// Kim

On disk cache instead of in memory cache

I'm wondering if it would be at all possible to create an on disk cache rather than an in memory cache for handling images.

The use case I'm thinking of is small custom images (emoji) that don't change regularly but are often used throughout an app.

What would be the best approach of extending the current image caching to allow for an on disk cache?

WebP support

Are there any ideas/plans/thoughts around image/webp support? Would be awesome

on disk caching weird behavior

Hello, I just encountered an issue will using the pod. First of all, some images are fetched then written to disk at the correct path which is {app_identifier}/com.alamofire.imagedownloader/NsCachedData which is perfect as these images are not even downloaded again when the app is in offline mode. But the issue is that sometimes images are written to {app_identifier}/NsCachedData which I believe is the path for NSURLCache.sharedURLCache and not the path specified in the cache used by alamofireImage so these images are not seen by ImageDownloader and are re downloaded if they are not found in-memory. Also sometimes images are not even written to the disk which is weird.

All these Images where fetched using the same method with the same approach tried removing their filters and nothing happened still the same behavior. I used ImageDownloader.defaultInstance.downloadImage method to fetch these Images.

Any help will be appreciated, thanks In advance!

Image fails to load after device locked

When I lock my device (iPhone 6 iOS 9.0.2, AlamofireImage 2.0.0), I noticed that the first time I call af_setImageWithURL on a UIImageView the first image consistently does not load (if the image is not already cached). I believe this is due to Alamofire/Alamofire#872.

I was able to workaround the issue with the following code (which I'm not suggesting as a fix but I think shows it's the same underlying issue as Alamofire/Alamofire#872):

func applicationWillEnterForeground(application: UIApplication) {
    UIImageView.af_sharedImageDownloader = ImageDownloader()
}

Framework not safe for use in app extensions

I'm looking at using AlamofireImage in an app that I'm building though when I link against it in an application extension I get the warning "Linking against dylib not safe for use in application extensions".

Is that something which has been done on purpose?

Happy to provide a pull request if required.

Thanks,
Matt.

Add "image/jpg" to the list of acceptableContentTypes

I'm not sure why it isn't already in the list but please add "image/jpg" here:

`private class func validateResponse(response: NSHTTPURLResponse?) -> Bool {

    let acceptableContentTypes: Set<String> = [
        "image/tiff",
        "image/jpeg",
        "image/gif",
        "image/png",
        "image/ico",
        "image/x-icon",
        "image/bmp",
        "image/x-bmp",
        "image/x-xbitmap",
        "image/x-win-bitmap"
    ]`

It's in Request+AlamofireImage.swift.

"image/jpg" is a valid content type and behaves identically to "image/jpeg".

Thanks.

Request: Optional URL/URL Request parameters

Could we make the URL/URL Request parameters optional on the setImageWith... methods?

I know this seems like it doesn't make sense at first, but I have a use case.

I'm using this library with a UImageView contained inside a UITableViewCell. My image url property on my model object is an optional, and if I don't have an image url to display, I'd like to display the placeholder image. In this case, if I have to do the following currently:

func setImageFromModel(modelObject: MyModel) { 
    guard let imageURL = modelObject.primaryImageURL else {
      imageView.image = modelObject.placeholderImage
      return
    }

    imageView.af_setImageWithURL(imageURL,
      placeholderImage: post.primaryImagePlaceholderImage,
      filter: nil,
      imageTransition: .CrossDissolve(0.2),
      completion: nil)
}

If the URL parameter was optional, this could be done just the one method call.

I'd be happy to make a PR, but I wanted to get input from @cnoon on this before I started.

how to queue image using Alamofire.request

Hello i ' am new in swift.My problem is.i already set an array for a image request around 5 url. Then the result of responseImage is not in order as in earlier array. Please help me to figure out the solution to produce result in order.
Thank You

af_setImageWithURL doesn't use acceptableImageContentTypes and fails to load binary/octet-stream

This fixes the issue by replacing "Images/*" as the only acceptable to using the list of acceptable content types

// MARK: - Private - URL Request Helper Methods

private func URLRequestWithURL(URL: NSURL) -> NSURLRequest {
    let mutableURLRequest = NSMutableURLRequest(URL: URL)
    for mimeType in Request.acceptableImageContentTypes {
        mutableURLRequest.addValue(mimeType, forHTTPHeaderField: "Accept")
    }

    return mutableURLRequest
}

AspectScaledToFillSizeFilter

Hi,

im getting a little problem with AspectScaledToFillSizeFilter.

when i use this

cell.eventImageView!.image = image!.af_imageAspectScaledToFillSize(cell.eventImageView!.bounds.size)

i get a result that next what i want.

but when i use

let imgFilter = AspectScaledToFillSizeFilter(size: cell.eventImageView!.bounds.size)
cell.eventImageView!.af_setImageWithURL(NSURL(string: url!)!, placeholderImage: nil, filter: imgFilter, imageTransition: UIImageView.ImageTransition.CrossDissolve(0.5))

i get a different thing. Looks like that my filter is not being applied to my UIImageView.

Does anyone know about it?

Image Inflate code between AFNetworking & AlamofireImage

The AFNetworking version is AFInflatedImageFromResponseWithDataAtScale which has nearly 90 lines code.

But AlamofireImage's is just
CGDataProviderCopyData(CGImageGetDataProvider(CGImage))

I wonder

  1. why the difference?
  2. a copy without CGDataProviderRelease is fine?

Crash at method imageAspectScaledToFillSize

Hi Alamofire team, I've tested my app on a iPhone 4S, 5, 5S and works fine. But when I test on a 6 or 6S, this happens:

unexpectedly found nil while unwrapping an Optional value

captura de tela 2015-11-25 as 14 36 24

I'm using the filter to create the rounded borders at the image, I`m using the version 2.1.1 and Swift 2.0.

var filter : ImageFilter? = nil

    ...

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! Cell
    let object = (self.objects?.objectAtIndex(indexPath.row))! as! Object

    cell.title.text = object.title

    if self.filter == nil {
      self.filter = AspectScaledToFillSizeWithRoundedCornersFilter(
      size: cell.image.frame.size, radius: 5.0)
    }
   ImageHelper.loadImage(cell.image, object: object, filter: filter, .None)
   return cell
}

The method to load the image is:

class func loadImage(imageView: UIImageView, object : Object, filter: ImageFilter?, imageTransition: UIImageView.ImageTransition) {

    let stringUrl = createURLImage(object)

    if let url = NSURL(string: stringUrl) {
      imageView.af_setImageWithURL(
        url,
        placeholderImage: UIImage(named: "app_logo"),
        filter: filter,
        imageTransition: imageTransition)
    }
}

Is it a bug? If I comment the code, it works fine.

Scale filter makes the image as red with the "color blended layers" option

Hi !

First, thank you for this great library, I really appreciate its design.

I noticed that when I'm using a scaling method of AlamofireImage (e.g. af_imageAspectScaledToFillSize), I see its container (basic UIImageView) as red in the "color blended layers". But if I'm using my "own", then the color is green.

I'm putting below the code I used to create the image/imageView (nothing special):

// instanciate image view
let imageView = UIImageView()
imageView.frame = CGRectMake(10.0, 10.0, 50.0, 50.0)
self.view.addSubview(imageView)

// add image
if let image = UIImage(named: "image-test")?.af_imageAspectScaledToFillSize(CGSizeMake(50.0, 50.0)) {
    image.af_inflate()
    imageView.image = image
}

I'm not sure if it's a big performance issue or not.
The resizing code I'm using is from this blog, which I converted to Swift.

1/ Do you want an Xcode project to reproduce the issue?
2/ Do you think it would be worth updating the scaling method? I could manage a pull-request if you want.

Notes: Xcode 7.2, iOS 9.2

Cheers,
Vincent

Composite filters

Hi,

First of all, thank you so much for such a good framework! I've been waiting for something like this for a very long time :-))))

That being said, I really like the filters, but I think we could make "compound" filters based on an (sorted) array of other filters.
For instance:

let filters = [AspectScaledToFillSizeFilter(size: someSize), BlurFilter(blurRadius: 20)]
let compoundFilter = CompoundFilter(filters: filters) // Or using variadic args ?

would create a filter that would first scale to fill, then apply a blur to the scaled image.

Classes such as AspectScaledToFillSizeWithRoundedCornersFilter could then themselves also be compound filters.

What do you think about it?

Cheers.

Support for AlamoFire 3.0

I was trying to update to AlamoFire 3.0 today, but I rely on this library as well. Thanks for the great work! Is there a plan to update the library?

Default closure based ImageFilter struct

I think many people will like to create filters on the fly with something like that:

let filter = ImageFilter("MyFilter") { image in
    // Do something the image
   return image.someTransformation()
}

It would be really convenient in some cases to avoid creating many files for isolated cases. In this example, the filter would have "MyFilter" as its identifier. (I don't think we can automatically generate a same unique identifier for this on-the-fly filter every time it is created / copied)

This would require to rename the protocol ImageFilter into ImageFilterType.


The same could be applied to (to be announced) CompositeImageFilter type. It could be created with a variadic array of ImageFilterType or a variadic array of Image -> Image closures / functions.

let composite = CompositeImageFilter(filters: SizeToFillFilter(size: size), CircleFilter(), BlackAndWhiteFilter())

CompositeImageFilter protocol would be renamed CompositeImageFilterType.

UICollectionView multiple cells and images

I am downloading multiple images in UICollectionView. There are about 30 cells on the screen.
When I scroll to down and scroll to top back all images look like downloading again. They are slowly loading one by one.

Also I am getting this warning.

[/BuildRoot/Library/Caches/com.apple.xbs/Sources/CoreUI/CoreUI-371.4/Bom/Storage/BOMStorage.c:522] <memory> is not a BOMStorage file.

My Code:
In UICollectionViewCell

func loadImage(urlString: String) {
    CircleImageView.af_setImageWithURL(NSURL(string: urlString)!, 
     placeholderImage: UIImage(named: "holderImage"), 
     filter: CircleFilter())
}

What am I missing?

Note: I am using different Image/Cache library and it's working without any of these things.

Thanks

Downloading doesn't work via ImageDownloader

let downloader = ImageDownloader()
let URLRequest = NSURLRequest(URL: NSURL(string: "https://httpbin.org/image/jpeg")!)

downloader.downloadImage(URLRequest: URLRequest) { response in
    if let image = response.result.value {
        print(image)
    }
}

The completion block isn't even called. Using Alamofire image response serializer works fine.

How to set image and cache it?

I don't understand why the function imageView.af_setImageWithURL(URL) is not caching the results automatically or why there are no such option?

How to implement this? I tried to get cache and via fetch method to load image, but this don't work.

Cannot load images from file URL

Hi there,

Firstly, fantastic work so far, I'm really looking forward to working with AlamofireImage and contributing where I can.

I've noticed that loading from an image file to a UIImageView from the application bundle (and, presumably, a location on disk) doesn't work. I haven't yet had time to look into why, but I thought I should bring it to your attention.

An example file URL:

file:///Users/alexanderedge/Library/Developer/CoreSimulator/Devices/B0CBC833-1F6C-4099-9B19-258DFE22AC89/data/Containers/Bundle/Application/388B99E5-E443-4C87-A22B-EB41BC192044/MyApp.app/image_06.1.png

An example call:

imageView.af_setImageWithURL(NSBundle.mainBundle().URLForResource(name: "image_06.1", withExtension: "png"))

Image does not load after being cancelled and instantly reloaded

imageView.af_setImageWithURL(url)
imageView.af_cancelImageRequest()
imageView.af_setImageWithURL(url)

The real world case we were having was:

  1. in a collectionview, a cell calls af_setImageWithURL.
  2. The collectionview is reloaded, then in the prepareForReuse() the request is cancelled.
  3. If the same cell makes the same image url request the image does not load

Testing on iOS 8 & iOS 9 this fails on simulator and device

Bug with AlamoFireImage

myProg(63494,0xb029b000) malloc: *** error for object 0x79b5ce80: double free
*** set a breakpoint in malloc_error_break to debug

screen shot 2016-01-22 at 4 25 25 am

UIImageView extensions do not work sometimes for URL's that redirect

Xcode: 7.0
AlamofireImage: 1.1.0

Current around line 324 of UIImageView+AlamofireImage.swift there is this block of code:

                guard let
                    currentRequest = strongSelf.af_activeRequest?.task.currentRequest
                    where currentRequest.URLString == request?.URLString else
                {
                    return
                }

Trying to figure out why facebook profile photos don't load such as https://graph.facebook.com/v2.4/529271840955/picture?type=large turns out this check returns because of a 3XX that then results in a different URL.

Would it be worth generated a UUID rather than using the image url or some way of keeping track of the redirects?

How to make perfect code for image caching from url[For Beginner Code Help]

I know its sounds like crazy.But,for a beginner like me,the documentation seems a little confuse.
So,If I can let me request a help from you because I want to use your library instead of KingFisher.
First of all,I have realm database which i used to store notification information.Every time the notifications comes in,it include data and 2 image url,

What i did in my program was,I insert every notifications that comes in at realm database and get all the data and then show at table cell.When each table cell is tapped,the detail goes on.

So,there will be one image at table view which will be max 50 records [1 image for each row] and,two images will be showed at the detail view when user tapped one of table view cell.

For,the table view which have 50 records max(let assume 10 notifications comes in)
How to download the 10 images asynchronously and cache and show the user?Even the user remove the app from app switcher and open again,the image should be still remain without needing to re-download again

This is the code that I applied at my table view (cellForRowAtIndexPath) for one notification only.

        let URL = NSURL(string: notification.image1)! // notification is realm object,there was image 1 & 2
       // image1 for list view and,both for detail view when user tapped on each record.
        let placeholderImage = UIImage(named: "Notification_PlaceHolder")!

        cell.notificationImageView.af_setImageWithURL(
            URL,
            placeholderImage: placeholderImage,
            imageTransition: .CrossDissolve(0.5)
        )

Any help please?

Image is never set when af_setImageWithURL is called 2 times in a row

I've noticed that images are never set if I call af_setImageWithURL several times.
The following (test) code will always result in only the placeholder image being set.

imageView.af_setImageWithURL(imageURL, placeholderImage: placeholder, filter: AspectScaledToFillSizeFilter(size: imageView.bounds.size))
imageView.af_setImageWithURL(imageURL, placeholderImage: placeholder, filter: AspectScaledToFillSizeFilter(size: imageView.bounds.size))

The first request seems to be successfully cancelled (I get a cancelled error if I set the completion block).

Cheers.

2 phase image download

Hi, I have an idea for feature.

Some content driven apps use two phase image download. It download super small image preview first and then it request large full res image.

So the flow is:

  1. show placeholder image
  2. show blurred low res preview (is purged from memory as soon as full res is available)
  3. show cached full res image

Low res previews have slightly higher priority for download queue.

It would be super nice to have such feature build right in ImageDownloader.

Cheers and best wishes, Vlad

Feature request: force image transition if image is cached

In the readme for this project, there's the line -

If the remote image is cached locally, the image transition is ignored.

This makes perfect sense in most cases. However, I have a use case where I would like to force the transition to be invoked - for cross dissolving a background image that may already have been downloaded elsewhere in the app.

Can I suggest some sort of override that we can use to ensure that the animation is not ignored if the image is in a cache?

I'm happy to create a pull request myself but I'd like others to agree on the implementation first.

The easiest solution would be to just add an extra optional parameter to af_setImageWithURLRequest.

Thoughts?

Issue with Umlaut within the URL

Hi guys

I ran into a strange issue.

If I have a URL with a Umlaut in it e.g.

http://upload.wikimedia.org/wikipedia/commons/a/a9/Rösti_mit_Bratwurst.jpg

I'll get following error message

fatal error: unexpectedly found nil while unwrapping an Optional value

If a try it with a URL without an Umlaut everything works as expected.

Strange right? :)

Failed image load in cell reuse other cell's image

I was testing my comments' tableview listing with a user that has a broken image in the cell (Failed to load resource: the server responded with a status of 403), and when I was scrolling, the user with the broken image was assigned with another user's image in the listing. This does not happen when there's no 403 error on any image. I was previously using HanekeSwift and this was not happening, and none of my code has change.

I'm using vanilla UIImageView extension:

cell.pictureImageView.af_setImageWithURL(NSURL(string: urlString)!, imageTransition: .CrossDissolve(0.2))

This is nothing major, but wondering if it's fixable, either on my side or on AlamofireImage's side.

Thanks!

UInt64 cannot be negative

In ImageCache.swift

                let bytesToPurge = self.currentMemoryUsage - self.preferredMemoryUsageAfterPurge

This sentence may EXC_BREAKPOINT, because self.currentMemoryUsage may less then self.preferredMemoryUsageAfterPurge.

and bytesToPruge is UInt64 type inference by Swift.

ImageView on TableViewCell changes size on tap or reload of cell

I'm trying to set the image view on a UITableViewCell subclass using the helper with a placeholder.

It works fine, and when the image is loaded the placeholder is replaced with the correct image. However, upon tapping on the cell (or forcing the cell to reload by scrolling it out of view and then bringing it back in) the image view snaps to a smaller version of the image.

self.imageView?.af_setImageWithURL(categoryImageUrl, placeholderImage: UIImage(named: "DefaultCategory"))

For example, here is how the cell appears after the initial load:

image

Then, once the cell has been tapped/reloaded it appears as this:

image

How can I have the image set at the right size initially, or prevent a resize from occurring upon reload?

Feature request: Image download progress information

As stated in this Stack Overflow question, I'd like to show some kind of progress indicator when downloading images in lists (tableviews…) or in —big— image viewers. I know I can achieve this by using regular Alamofire.request + responseImage but I'd like to keep things simple and make use of the UIImageView Extension and the extra features it provides (cache, filters…).

I'm currently working on an app that shows a news feed view controller which shows one highlighted news with a big photo followed by a list of "smaller" views with their own smaller photos. Each news detail view controller shows a gallery of related photos (1 to 50 or even more) and when the user taps one of them we load the big version of the photo in a custom photo viewer.

It'd nice to show some kind of progress indicator to the user. Or perhaps I'm mistaken and its better to use the image-placeholder-only approach followed by the current implementation of AlamofireImage.

Either way, thank you for your hard work ;-)

identify if a placeholder image is used

We are using af_setImageWithURLRequest to display a profile picture. Sometimes users don't have a profile picture so we use a placeholderimage instead. Is there a way to identify if the placeholderimage is used or not. Basically I want to set a UI action on profile pictures only but not placeholder images.

Need API to set inflateResponseImage to false

Hi. I noticed the line 'CGDataProviderCopyData(CGImageGetDataProvider(CGImage))' of function af_inflate uses a lot of memory especially when I load a large image on a cell (like 3000x3000 and file size is 2MB) and then scroll the pages quickly. This blows up the memory usage and crashes my app

Disabling the inflation works for me

Effect applying callback

I'm getting remotely displaying pretty large images on the screen (tvOS) - about 1920x1080.
The downloading process is pretty seamless (around 1 sec), but when I'm trying to apply a filter on top of it (BlurFilter in my case), the time to actually display image on the screen multiplies by a factor of 6! And thats just on my mac. On actual Apple TV this will probably be longer. Well, I could just block the screen at this point and display a spinner, but is there a way to know when the filter is actually applied and the image is presented on the screen?

Installing and building from Carthage fails on the watchOS scheme

I am setting up my Cartfile as explained in the readme file and I get this console output when running "carthage update".


*** Fetching AlamofireImage
*** Fetching SDWebImage
*** Fetching Alamofire
*** Checking out Alamofire at "3.1.4"
*** Checking out AlamofireImage at "2.2.0"
*** Checking out SDWebImage at "3.7.3"
*** xcodebuild output can be found in /var/folders/pr/vgdvxhm93yjbq8_9w4p2q_z80000gn/T/carthage-xcodebuild.bnxNOt.log
*** Building scheme "Alamofire OSX" in Alamofire.xcworkspace
*** Building scheme "Alamofire watchOS" in Alamofire.xcworkspace
** BUILD FAILED **

The following build commands failed:
Check dependencies
(1 failure)
A shell task failed with exit code 65:
** BUILD FAILED **

The following build commands failed:
Check dependencies
(1 failure)

Xcode complains that watchOS framework was built for iOS when installed through Carthage

I get this error when I try to add the 2 frameworks(Alamofire & AlamofireImage) to my WatchKit Extension target.

It actually does not matter from which platform Build folder I will add the frameworks. It always shows the same error.

d: building for watchOS simulator, but linking against dylib built for iOS, file '/Some-Project-Filder/Carthage/Build/iOS/AlamofireImage.framework/AlamofireImage' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

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.