Package: coif
CoifCoif (Coverimagefinder) is a Python 3 module for contacting multiple services to look for a book jacket image given an identifier such as an ISBN.Table of contentsIntroductionInstallationUsageKnown issues and limitationsGetting helpContributingLicenseAuthors and historyAcknowledgmentsIntroductionIn a variety of situations involving library software systems, it's useful to show a small image of a book's cover or jacket. Coif (Coverimagefinder) is a simple Python 3 library that looks for cover images using multiple network services. When it finds one, Coif returns the image inJPEGformat.Coif is most similar tobookcovers, a JavaScript library that performs federated search for book cover images. A Python package similar to Coif isbooker, but that one is limited to searching Google Books.InstallationThe instructions below assume you have a Python interpreter installed on your computer; if that's not the case, please firstinstall Python version 3and familiarize yourself with running Python programs on your system.OnLinux,macOS, andWindowsoperating systems, you should be able to installcoifwithpip.  To installcoiffrom thePython package repository (PyPI), run the following command:python3 -m pip install coifAs an alternative to getting it fromPyPI, you can usepipto installcoifdirectly from GitHub, like this:python3-mpipinstallgit+https://github.com/caltechlibrary/coif.gitUsageCoif currently offers only an application programming interface (API); it does not offer a command-line interface. The main interface point is the functioncover_image(...). Here is a simple demonstration of using it:fromcoifimportcover_image(url,image)=cover_image('9781479837243')ifimage:withopen('image.jpg','wb')asimage_file:image_file.write(image)else:print('Unable to find image')As illustrated above,cover_imagereturnstwovalues: a URL, and a JPEG image in binary form (if a cover image is found).Arguments tocover_imageThe function takes one required argument, an identifier (preferably anISBN, but possibly other kinds of identifiers), and additional optional arguments. In more detail, the possible arguments are:identifier(required): an ISBN, OCLC id, LCCN id, OLID and or Open LibraryCover ID. Note that only Open Library accepts anything other than ISBN, so your best bet for finding a cover image is to use an ISBN. Conversely, if you provide anything other than an ISBN,cover_imagewill only contact Open Library.kind(optional): the kind of identifier given as the first argument. Recognized values areisbn,lccn,olid,oclc, andcoverid. The default isisbn.size(optional): one of the lettersS,M, orL, to indicate a preference for small, medium, or large images, respectively. Some cover images may exist in one size and not another, and there is no way to know in advance which size may be available from a service without actually downloading the image. If asizeis provided,cover_imagewill ask for that sizeand smaller; for example, if you call it withsize = 'M', it will try to findMfirst and if none exists, it will tryS. By default, it wilonlytryS. If you want to get the largest image you can find, call it withsize = 'L'.cc_login(optional): one of the best services for finding cover images isContent Cafè 2from Baker & Talor, but it requires an account. If you have a user id and password with their service, provide the credentials as a tuple of values("user", "password")to the optional argumentcc_login.Whycover_imagealways returns an imageA frustrating aspect of many of the services is that they provide no way to simply ask whether an image exists. If the services do not have an image for a given identifier, most return a small placeholder image (often containing rendered text to the effect of "no cover found") instead of returning a failure code of some kind. Consequently,cover_imagemust always download images and test them against some size thresholds to determine if it got a placeholder or an actual cover image. This is the reason why the return values fromcover_imageare both a URL and an image: it has already downloaded the image, so it may as well return it, to save the caller the trouble of downloading the image a second time.Known issues and limitationsAlthough theOpen Library Covers APIaccepts multiple types of identifiers such as an ISBN, OCLC, LCCN, and more, other services only accept ISBNs. Thus, while you can pass any of these types of identifiers to Coif, if what you use isnotan ISBN, then Coif will only contact the Open Library's service.Getting helpIf you find an issue, please submit it inthe GitHub issue trackerfor this repository.ContributingWe would be happy to receive your help and participation with enhancing Coif!  Please visit theguidelines for contributingfor some tips on getting started.LicenseSoftware produced by the Caltech Library is Copyright © 2021 California Institute of Technology.  This software is freely distributed under a BSD/MIT type license.  Please see theLICENSEfile for more information.Authors and historyIn this section, list the authors and contributors to your software project.  Adding additional notes here about the history of the project can make it more interesting and compelling.  This is also a place where you can acknowledge other contributions to the work and the use of other people's software or tools.AcknowledgmentsThis work was funded by the California Institute of Technology Library.Thevector artworkof a man's coiffure, used as the icon for this project, was created bysarahfrom the Noun Project.  It is licensed under the Creative CommonsCC-BY 3.0license. I edited the logo inBoxy SVG, a native SVG editor for macOS to change the icon color to the orange used by Caltech in their logo.