---
title: "#51: PINRemoteImage 📌🎮🌄"
url: https://littlebitesofcocoa.com/51-pinremoteimage
author: Jake Marsh
date: 2015-08-03
published: 2015-08-03
topics: ["Libraries","Images"]
description: "PINRemoteImage is a new and promising solution for asynchronously downloading images. It was created by the team at Pinterest and has been battle tested in..."
---

# #51: PINRemoteImage 📌🎮🌄

By Jake Marsh, August 3, 2015. HTML: https://littlebitesofcocoa.com/51-pinremoteimage

**[PINRemoteImage](http://git.io/pri)** is a new and promising solution for asynchronously downloading images. It was created by the team at **Pinterest** and has been battle tested in their [extremely popular iOS app](https://itunes.apple.com/us/app/pinterest/id429047995?mt=8). Let's `import PINRemoteImage`, take a look at how to use it, and see what it can do:

``` swift
let imageURL = NSURL(string: "http://apple.com/iCar.png")
imageView.setImageFromURL(imageURL)
```

Images are downloaded and decoded _off_ the main thread. They're then cached using a fast, non-deadlocking parallel object cache. (Courtesy of another **Pinterest** library, **PINCache**). Upon subsequent requests the in-memory, then disk caches will be checked before re-downloading.

## Processing

You can process the image before caching occurs. Here we'll use **[Toucan](http://git.io/toucan)** (covered in [Bite #40](/40)) to convert the image into a circular avatar.

``` swift
imageView.setImageFromURL(
  imageURL, 
  placeholderImage: placeholder, 
  processorKey: "circleAvatar"
) { (result, cost) -> UIImage! in
  return Toucan.Mask.maskImageWithEllipse(result.image)
}
```

## Progressive JPEGs

Optionally, you can enable a mode supporting progressive JPEG images. They're treated with a nice blur effect, so they look great even at low resolutions.

``` swift
imageView.updateWithProgress = true
```

## Animated GIF Support

**PINRemoteImage** also comes with built-in support for Flipboard's blazing fast animated GIF library, FLAnimatedImage. All you have to do to use it is create an FLAnimatedImageView instead of a UIImageView:

``` swift
let animatedImageView = FLAnimatedImageView(frame: GIFRect)

let GIFURL = NSURL(string: "http://apple.com/eddy-dance.gif")
animatedImageView.setImageFromURL(GIFURL)

// #GIFnotJIF
```

More info about **PINRemoteImage** can be found at [git.io/pri](http://git.io/pri)
