Given an S3 key and bucket/URL, perform given image operations on an image and return the URL.

def generate_url(self, bucket=None, asset_key=None, asset_url=None, operations=['identity'], secure=True):
        """
        Given an S3 key and bucket/URL, perform given image operations on an image and return the URL.
        """
        if len(operations) < 1:
            raise OperationError('You didn\'t provide any operations to perform on the image')

        protocol = 'https://' if secure else 'http://'
        base_url = '%s%s' % (protocol, self.cloudfront_hostname)

        if asset_key is not None:
            if bucket is None:
                if self.default_bucket is None:
                    raise OperationError('No S3 bucket has been provided.')
                else:
                    bucket = self.default_bucket

            path = '/%s/%s/%s/%s' % (
                bucket,
                asset_key,
                '/'.join(operations),
                self.account_id,
            )

            request_hash = self._generate_hash(path)

            adept_url = ('%s%s/%s' % (
                base_url,
                path,
                request_hash)
            )

        elif asset_url is not None:

            path = '/loader/%s/%s' % (
                '/'.join(operations),
                self.account_id
            )
            loader_uri = '%s?url=%s' % (path, asset_url)
            request_hash = self._generate_hash(loader_uri)

            adept_url = '%s%s/%s?url=%s' % (
                base_url,
                path,
                request_hash,
                urlquote(asset_url)
            )
        else:
            raise OperationError("Asset key or URL must be provided")

        return adept_url