Skip to content

Commit

Permalink
Merge pull request #133 from samvera/alpha-channel-docs
Browse files Browse the repository at this point in the history
Update source image docs to include alpha channel info
  • Loading branch information
mbklein authored Nov 30, 2023
2 parents 86e3405 + eddff53 commit b177f71
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions docs/pages/docs/source-images.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
import { Callout } from 'nextra/components'

# Source Images

The S3 key of any given file, minus the extension, is its IIIF ID. For example, if you want to access the image manifest for the file at `abcdef.tif`, you would get `https://.../iiif/2/abcdef/info.json`. If your key contains slashes, they must be URL-encoded: e.g., `ab/cd/ef/gh.tif` would be at `https://.../iiif/2/ab%2Fcd%2Fef%2Fgh/info.json`. (This limitation could easily be fixed by encoding only the necessary slashes in the incoming URL before handing it off to the IIIF processor, but that's beyond the scope of the demo.)

`iiif-processor` can use any image format _natively_ supported by [libvips](https://libvips.github.io/libvips/), including JPEG 2000 (`.jp2`), but best results will come from using tiled, multi-resolution TIFFs. The Lambda Function wrapper included in this application assumes a `.tif` extension unless you set ResolverTemplate in your .env file.

<Callout emoji="⚠️">
Some versions of `libvips` and `libjpeg` have an issue with JPEG-compressed pyramidal TIFF images that include more than 3 channels (e.g.,
alpha channels). If you find that `serverless-iiif` returns an error for an image request or isn't rendering as you'd expect, try removing any additional channels beyond red, green, and blue.
</Callout>

## Creating tiled TIFFs

### Using VIPS
### Using the VIPS command line

```bash
# For a 3-channel source image
vips tiffsave source_image.tif output_image.tif --tile --pyramid --compression jpeg --tile-width 256 --tile-height 256

# For a source image with an alpha channel
vips extract_band source_image.tif temp_image.v 0 --n 3 \
&& vips tiffsave temp_image.v output_image.tif --tile --pyramid --compression jpeg --tile-width 256 --tile-height 256 \
&& rm temp_image.v
```

### Using ImageMagick

```bash
convert source_image.tif -define tiff:tile-geometry=256x256 -compress jpeg 'ptif:output_image.tif'
convert source_image.tif -alpha off -define tiff:tile-geometry=256x256 -compress jpeg 'ptif:output_image.tif'
```

0 comments on commit b177f71

Please sign in to comment.