Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apostrophecms/heic-to-jpeg-middleware
Middleware to convert HEIC/HEIF files from iOS 11 devices like the iPhone to JPEG format, with no other modifications to your code that expects JPEG
https://github.com/apostrophecms/heic-to-jpeg-middleware
Last synced: about 2 months ago
JSON representation
Middleware to convert HEIC/HEIF files from iOS 11 devices like the iPhone to JPEG format, with no other modifications to your code that expects JPEG
- Host: GitHub
- URL: https://github.com/apostrophecms/heic-to-jpeg-middleware
- Owner: apostrophecms
- License: mit
- Created: 2018-07-10T22:59:23.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2020-07-14T17:42:18.000Z (over 4 years ago)
- Last Synced: 2024-11-02T03:04:08.653Z (2 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
```javascript
const multipart = require('connect-multiparty')();
const heicToJpeg = require('heic-to-jpeg-middleware')();
const app = require('express')();
app.post('/upload', multipart, heicToJpeg, function(req, res) {
// Access req.files as you normally would here.
//
// You will see `.jpg` where you would otherwise
// see `.heic`.
});
```This is middleware to convert the iOS HEIC/HEIF image format to JPEG,
so that your Express route sees the JPEG as if it were the
original file.This middleware expects that the file upload has already been
accepted via `connect-multiparty` or any other middleware that
provides a `req.files` object in which each sub-object has
`path`, `name` and `type` properties. The sub-objects of
`req.files` may also be arrays of such objects.## Alternatives
The very latest versions of ImageMagick support HEIF too.
## Warnings
To prevent a denial of service, middleware that does CPU- and RAM-intensive
stuff like this should always be added only to the specific routes that
require it. It's also a good idea to use other middleware to check the user's
permissions first, rather than later in the route code itself.## Changelog
2.0.0: Use [heic-convert](https://github.com/catdad-experiments/heic-convert) in replacement of [tifig](https://github.com/monostream/tifig). Since `heic-convert` is pure JavaScript there is no more need to install a hand-compiled dependency that is not well-supported. Thanks to Gabriel L. Maljkovich for this contribution. Also fixed an error in the documentation; thanks to Vũ Quang Thịnh for pointing this out.
1.0.2: supports more types of file upload middleware. In particular, the sub-objects of `req.files` may be arrays, and if `path` does not have any extension to change then a `.jpg` extension is added.
1.0.1: more docs, repo push.
1.0.0: initial release.