Add support for libvips' PPM and FITS loaders #347

This commit is contained in:
Lovell Fuller 2016-01-31 19:39:21 +00:00
parent 2656c69d99
commit 56508e8d79
6 changed files with 15 additions and 3 deletions

View File

@ -38,7 +38,7 @@ Fast access to image metadata without decoding any compressed image data.
`callback`, if present, gets the arguments `(err, metadata)` where `metadata` has the attributes: `callback`, if present, gets the arguments `(err, metadata)` where `metadata` has the attributes:
* `format`: Name of decoder to be used to decompress image data e.g. `jpeg`, `png`, `webp` (for file-based input additionally `tiff`, `magick` and `openslide`) * `format`: Name of decoder to be used to decompress image data e.g. `jpeg`, `png`, `webp` (for file-based input additionally `tiff`, `magick`, `openslide`, `ppm`, `fits`)
* `width`: Number of pixels wide * `width`: Number of pixels wide
* `height`: Number of pixels high * `height`: Number of pixels high
* `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `scrgb`, `cmyk`, `lab`, `xyz`, `b-w` [...](https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L522) * `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `scrgb`, `cmyk`, `lab`, `xyz`, `b-w` [...](https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L522)

View File

@ -12,6 +12,10 @@
[#340](https://github.com/lovell/sharp/issues/340) [#340](https://github.com/lovell/sharp/issues/340)
[@janaz](https://github.com/janaz) [@janaz](https://github.com/janaz)
* Add support for libvips' PBM, PGM, PPM and FITS image format loaders.
[#347](https://github.com/lovell/sharp/issues/347)
[@oaleynik](https://github.com/oaleynik)
* Small optimisation when reducing by an integral factor to favour shrink over affine. * Small optimisation when reducing by an integral factor to favour shrink over affine.
* Add support for gamma correction of images with an alpha channel. * Add support for gamma correction of images with an alpha channel.

View File

@ -24,7 +24,7 @@ to install the libvips dependency.
### Formats ### Formats
This module supports reading JPEG, PNG, WebP, TIFF, OpenSlide, This module supports reading JPEG, PNG, WebP, TIFF, OpenSlide,
GIF and other libmagick-supported formats. GIF and most other libmagick-supported formats.
Output images can be in JPEG, PNG and WebP formats as well as uncompressed raw pixel data. Output images can be in JPEG, PNG and WebP formats as well as uncompressed raw pixel data.

View File

@ -94,6 +94,10 @@ namespace sharp {
imageType = ImageType::OPENSLIDE; imageType = ImageType::OPENSLIDE;
} else if (EndsWith(loader, "TiffFile")) { } else if (EndsWith(loader, "TiffFile")) {
imageType = ImageType::TIFF; imageType = ImageType::TIFF;
} else if (EndsWith(loader, "Ppm")) {
imageType = ImageType::PPM;
} else if (EndsWith(loader, "Fits")) {
imageType = ImageType::FITS;
} else if (EndsWith(loader, "Magick") || EndsWith(loader, "MagickFile")) { } else if (EndsWith(loader, "Magick") || EndsWith(loader, "MagickFile")) {
imageType = ImageType::MAGICK; imageType = ImageType::MAGICK;
} }

View File

@ -15,7 +15,9 @@ namespace sharp {
WEBP, WEBP,
TIFF, TIFF,
MAGICK, MAGICK,
OPENSLIDE OPENSLIDE,
PPM,
FITS
}; };
// How many tasks are in the queue? // How many tasks are in the queue?

View File

@ -120,6 +120,8 @@ class MetadataWorker : public AsyncWorker {
case ImageType::TIFF: baton->format = "tiff"; break; case ImageType::TIFF: baton->format = "tiff"; break;
case ImageType::MAGICK: baton->format = "magick"; break; case ImageType::MAGICK: baton->format = "magick"; break;
case ImageType::OPENSLIDE: baton->format = "openslide"; break; case ImageType::OPENSLIDE: baton->format = "openslide"; break;
case ImageType::PPM: baton->format = "ppm"; break;
case ImageType::FITS: baton->format = "fits"; break;
case ImageType::UNKNOWN: break; case ImageType::UNKNOWN: break;
} }
// VipsImage attributes // VipsImage attributes