diff --git a/docs/api.md b/docs/api.md index 28e4c6f4..e745c6c6 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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: -* `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 * `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) diff --git a/docs/changelog.md b/docs/changelog.md index 690e7f56..539418a8 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -12,6 +12,10 @@ [#340](https://github.com/lovell/sharp/issues/340) [@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. * Add support for gamma correction of images with an alpha channel. diff --git a/docs/index.md b/docs/index.md index a2f7a19c..ae4287ee 100644 --- a/docs/index.md +++ b/docs/index.md @@ -24,7 +24,7 @@ to install the libvips dependency. ### Formats 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. diff --git a/src/common.cc b/src/common.cc index 5b7d2a58..2e25934a 100644 --- a/src/common.cc +++ b/src/common.cc @@ -94,6 +94,10 @@ namespace sharp { imageType = ImageType::OPENSLIDE; } else if (EndsWith(loader, "TiffFile")) { 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")) { imageType = ImageType::MAGICK; } diff --git a/src/common.h b/src/common.h index e3801a7d..276567ac 100644 --- a/src/common.h +++ b/src/common.h @@ -15,7 +15,9 @@ namespace sharp { WEBP, TIFF, MAGICK, - OPENSLIDE + OPENSLIDE, + PPM, + FITS }; // How many tasks are in the queue? diff --git a/src/metadata.cc b/src/metadata.cc index bcd933e2..a19877ae 100644 --- a/src/metadata.cc +++ b/src/metadata.cc @@ -120,6 +120,8 @@ class MetadataWorker : public AsyncWorker { case ImageType::TIFF: baton->format = "tiff"; break; case ImageType::MAGICK: baton->format = "magick"; 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; } // VipsImage attributes