def import_image(self, image_id):
        '''
        Imports and returns tuple with image and context dict

        Input: foreign image ID

        Output: (Image: imported image, Dict: info about import)

        Side effects: If Importer object has a record_keeper, it
        will update the record of foreign to local images.

        Attempts to avoid duplicates by matching image dimensions
        and hashes. If a match is found it refers to local instance
        instead. If it is not, the image is fetched, created and
        referenced.
        '''
        image_detail_url = "{}{}/".format(self.image_url, image_id)

        try:
            img_response = requests.get(image_detail_url)
            img_info = json.loads(img_response.content)
        except Exception as e:
            error_context = {
                "image detail url": image_detail_url,
                "exception": e,
            }
            raise ImageInfoFetchFailed(error_context)

        if img_info["image_hash"] is None:
            raise ValueError('image hash should not be none')

        # check if a replica exists
        local_image = self.get_replica_image(
            img_info["image_hash"])

        file_url = img_info['image_url']

        # handle when image_url is relative
        # assumes that image import means local storage
        if img_info['image_url'][0] == '/':
            file_url = "{}{}".format(
                self.base_url, img_info['image_url'])

        if local_image:
            context = {
                "local_version_existed": True,
                "file_url": file_url,
                "image_detail_url": image_detail_url,
                "foreign_title": img_info["title"],
            }
            # update record keeper
            if self.record_keeper:
                self.record_keeper.record_image_relation(
                    image_id,
                    local_image.id)
            return (local_image, context)
        else:
            new_image, context = self.fetch_and_create_image(
                file_url,
                img_info["title"])
            # update record keeper
            if self.record_keeper:
                self.record_keeper.record_image_relation(
                    image_id,
                    new_image.id)
            context.update({
                "local_version_existed": False,
            })
            return (new_image, context)
Imports and returns tuple with image and context dict

        Input: foreign image ID

        Output: (Image: imported image, Dict: info about import)

        Side effects: If Importer object has a record_keeper, it
        will update the record of foreign to local images.

        Attempts to avoid duplicates by matching image dimensions
        and hashes. If a match is found it refers to local instance
        instead. If it is not, the image is fetched, created and
        referenced.