Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

Commit a225328

Browse files
committed
Merge branch 'develop'
2 parents 1ebfbc7 + 67f4f19 commit a225328

File tree

14 files changed

+2760
-1437
lines changed

14 files changed

+2760
-1437
lines changed

CHANGELOG.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
## [3.1.0] - 2019-04-26
11+
12+
### Added
13+
14+
- SVG Tracing with *potrace*
15+
- Better modularization of the pipeline for easier extensibility with newer features
16+
17+
### Fixed
18+
19+
- Image converting (`convert` option would do nothing)
20+
- Small formatting errors, typos
21+
22+
## [3.0.1] - 2019-04-02
23+
24+
### Fixed
25+
26+
- CLI ('bin' folder was not whitelisted for deployment)
27+
1028
## [3.0.0] - 2019.04-02
1129

1230
The third major update that involved a rewrite of the worker thread. The image export system is now
@@ -189,7 +207,9 @@ not fork the project and submit a Pull Request?
189207

190208
First release
191209

192-
[unreleased]: https://github.com/marcuscemes/responsive-image-builder/compare/v3.0.0...HEAD
210+
[unreleased]: https://github.com/marcuscemes/responsive-image-builder/compare/v3.1.0...HEAD
211+
[3.1.0]: https://github.com/marcuscemes/responsive-image-builder/compare/v3.0.1...v3.1.0
212+
[3.0.1]: https://github.com/marcuscemes/responsive-image-builder/compare/v3.0.0...v3.0.1
193213
[3.0.0]: https://github.com/marcuscemes/responsive-image-builder/compare/v2.1.2...v3.0.0
194214
[2.1.2]: https://github.com/marcuscemes/responsive-image-builder/compare/v2.1.1...v2.1.2
195215
[2.1.1]: https://github.com/marcuscemes/responsive-image-builder/compare/v2.1.0...v2.1.1

README.md

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424

2525
## Features
2626

27-
-**Fast** - Uses the lightning-quick [libvips image processing library](https://github.com/jcupitt/libvips/wiki/Speed-and-memory-use)
27+
-**Fast** - Uses the lightning-quick [libvips image processing library][link-libvips-speed]
2828
- 🔥 **Multithreaded** - Scales to all available CPU cores
2929
- 📦 **Zero configuration** - Change nothing, change everything. You choose.
3030
- 🌍 **Universal** - a flexible image build process that doesn't enforce any principles
3131
- ✂️ **Cross-platform** - Tested on Windows, macOS and Linux
3232
- 😊 **Friendly experience** - telling you what's going on, from start to finish
33+
-**SVG Tracing** - for [really fancy placeholders][link-traced-svg]
3334

3435
<div align="center">
3536

@@ -46,7 +47,10 @@
4647

4748
## Why
4849

49-
Webpack... Angular... React... PHP... Cloudflare... So many solutions for serving images, some terrible, some paid. What if you just want to serve modern [WebP][link-webp-speed] images with [srcset][link-srcset] optimization, [lazy-loading][link-lazy-sizes] (with low-quality placeholder), fingerprint cache-busting, aggressive compression, while also exporting the original codec for [browsers that are late to the party][link-caniuse] (ahem Safari, Firefox, Edge, ...)?
50+
A lighter web is now more important than ever, with cloud computing taking off and their [ridiculous bandwidth costs][link-bandwidth-costs]! Next to video, images are the largest payload for videos to provide, incurring significant costs if not done correctly, not to mention extra charges and wait times for the user.
51+
52+
Webpack... Angular... React... PHP... Cloudflare... So many solutions for serving images, some terrible, some paid. What if you just want to serve modern [WebP][link-webp-speed] images with [srcset][link-srcset] optimization, [lazy-loading][link-lazy-sizes] (with low-quality placeholder OR amazing traced-SVGs), fingerprint cache-busting, aggressive compression, while also exporting the original codec for [browsers that are late to the party][link-caniuse] (ahem Safari, Firefox, Edge, ...)?
53+
5054

5155
<p align="center">
5256
Is that really too much to ask?
@@ -58,6 +62,8 @@ That's just all that you <i>can</i> do, RIB can help you with any combination of
5862

5963
### What this does
6064

65+
*Chuck any high-quality originals in a folder, and RIB will non-destructively create a set of web-optimized responsive images for each original image in another folder. No more manual resizing, compressing, "where did I put the original?".*
66+
6167
In it's most basic form. with no additional configuration, RIB will scan a given directory for image files, and export them to a folder of your choosing. The export process consists of creating four different sized images from the source, converting a WebP copy of each size, optimizing them for web use before saving them using unique and predictable files names.
6268

6369
Finally, a [manifest](#manifest) file in [JSON][link-json] format is saved along with the images, containing information about every image's exported sizes, format, accompanying WebP file, final URL, etc...
@@ -68,9 +74,9 @@ The resulting manifest file is a few KB of data that lets you easily resolve an
6874

6975
It follows the [KISS principle][link-kiss]. We tend to over-complicate everything when it comes to website development when usually most things can be done really simply...
7076

71-
Of course, more elaborate websites require complicated design principles to scale better, but they should have a custom build pipeline anyway, such as a script that suits their needs perfectly (which, incidentally, is how this project came to be).
77+
Of course, more elaborate websites require complicated design principles to scale better, but they should have a custom build pipeline that suits their needs perfectly (which, incidentally, is how this project came to be).
7278

73-
RIB makes it easy to take a set of high-quality source images and just make them work on the web. Optimized, with several different responsive breakpoints, the assurance of no duplicate files meaning no wasted space or bandwidth. See the [example](example/) to see what it does.
79+
RIB makes it easy to take a set of high-quality source images and just make them work on the web. Optimized, with several different responsive breakpoints, the assurance of no duplicate sizes or files meaning no wasted space or bandwidth. See the [example](example/) to see what it does.
7480

7581
<p align="center">
7682
<a href="https://i.ibb.co/GP0NW93/Responsive-Image-Builder.png">
@@ -517,6 +523,31 @@ This will enable fingerprinting, adding a new property to the `original` group o
517523
"fingerprint": "5ae7554b" # When using --short-hash
518524
```
519525

526+
## SVG Placeholders
527+
528+
RIB supports [potrace][link-potrace] to create a beautiful SVG placeholder. It can be used like [this][link-traced-svg] as a tiny (2-6KB) placeholder until you have downloaded the full high quality image. In some ways it provides a more pleasing experience than a blurred 8x8 thumbnail.
529+
530+
SVGs are vector graphics that scale to any resolution, it only contains primitive shapes that represents strong edges/contrasts in the source image.
531+
532+
By default, RIB will create a traced image for every non-SVG export. You can customize the name of this traced image using the `traceTemplate` config option.
533+
534+
The `traceOptions` configuration property will pass down all options to [potrace][link-potrace], this lets you change the colour and complexity of the image.
535+
536+
**Example**
537+
538+
```javascript
539+
rib({
540+
traceOptions: {
541+
color: 'lightgray',
542+
optTolerance: 0.4,
543+
turdSize: 100,
544+
turnPolicy: potrace.Potrace.TURNPOLICY_MAJORITY
545+
}
546+
})
547+
```
548+
549+
<p align="center"><sub>You may need to import the potrace library, or used hard-coded constant values</sub></p>
550+
520551
## Typescript
521552

522553
Since v2.0.0, the entire project has been rewritten in Typescript. This not only provides more robust compilation with less chance of stupid errors but also provides strong typings for practically all function parameters and returns.
@@ -566,7 +597,9 @@ And of course, at the end of the pipeline are beautifully compressed images.
566597

567598
## Converting
568599

569-
Converting is used to change the format of the fallback image, and can be done using the `convert` option. This can be used, for example, to convert high-quality TIFF image files into JPEG and WebP images optimized for the web. It allows for slightly more compatibility and automation during the build process.
600+
Converting is used to change the format of the image before entering the pipeline. This is done using the `convert` option.
601+
602+
Converting allows you to, for example, convert high-quality TIFF image files into JPEG (and the accompanying WebP image), which is far more compatible, without the need to convert the original yourself.
570603

571604
## Troubleshooting
572605

@@ -578,7 +611,7 @@ If you have a bug, issue or a feature request, open a [new issue][link-issues] u
578611

579612
If you would like to contribute directly, see [contributing][link-contributing] to learn how to make changes and submit a Pull Request.
580613

581-
Responsive Image Builder uses [Travis CI](link-travis) and [semantic-release][link-semantic-release] to test the master and develop branches and publish any significant changes immediately to npm and GitHub.
614+
Responsive Image Builder uses [Travis CI][link-travis] and [semantic-release][link-semantic-release] to test the master and develop branches and publish any significant changes immediately to npm and GitHub.
582615

583616
<div align="center">
584617

@@ -620,6 +653,7 @@ Stretch goals for the next feature release. Completed goals are removed after th
620653
- [x] Add codec conversion support (e.g. TIFF -> JPEG) (`convert` option)
621654
- [x] Add checksum to manifest for better image searching (`fingerprint` option)
622655
- [x] Add example with new WebP optimizer and better optimizer settings
656+
- [x] Add support for pre-load traced SVGs
623657

624658
### Quirks
625659

@@ -655,10 +689,13 @@ Stretch goals for the next feature release. Completed goals are removed after th
655689
[link-marcuscemes]:https://github.com/MarcusCemes
656690
[link-wiki]:https://github.com/MarcusCemes/responsive-image-builder/wiki/
657691

692+
[link-libvips-speed]:https://github.com/jcupitt/libvips/wiki/Speed-and-memory-use
693+
[link-traced-svg]:https://using-gatsby-image.gatsbyjs.org/traced-svg/
658694
[link-webp-speed]:https://developers.google.com/speed/webp/
659695
[link-srcset]:https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images
660696
[link-lazy-sizes]:https://github.com/aFarkas/lazysizes
661697
[link-caniuse]:https://caniuse.com/#feat=webp
698+
[link-bandwidth-costs]:https://news.ycombinator.com/item?id=11301085
662699
[link-json]:https://en.wikipedia.org/wiki/JSON
663700
[link-kiss]:https://en.wikipedia.org/wiki/KISS_principle
664701
[link-win-nvm]:https://github.com/coreybutler/nvm-windows
@@ -671,4 +708,5 @@ Stretch goals for the next feature release. Completed goals are removed after th
671708
[link-mozjpeg]:https://www.npmjs.com/package/imagemin-mozjpeg
672709
[link-svgo]:https://www.npmjs.com/package/imagemin-svgo
673710
[link-gifsicle]:https://www.npmjs.com/package/imagemin-gifsicle
674-
[link-semantic-release]:https://github.com/semantic-release/semantic-release
711+
[link-semantic-release]:https://github.com/semantic-release/semantic-release
712+
[link-potrace]:https://github.com/tooolbox/node-potrace

bin/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ program
4747
.option("-f, --fingerprint", "Enable original file fingerprinting (manifest entry)")
4848
.option("-a, --hash-algorithm [algorithm]", "The fingerprint algorithm to use, such as 'md5'")
4949
.option("-s, --short-hash", "Trim hashes in the manifest file to only a few characters")
50+
.option("--no-trace", "Disable placeholder SVG tracing")
5051
.option("--no-fallback", "Disable fallback format exports")
5152
.option("--no-webp", "Disable WebP format exports")
5253
.option("--no-resize", "Disable image resizing (based on export presets)")
5354
.option("--no-optimize", "Disable image optimization")
5455
.option("-c, --convert [format]", "Convert the fallback format to the specified format")
5556
.option("--single-template [template]", "The template to use for file-naming single exports")
56-
.option("--multiple-template [template]", "The template to sue fo file-naming multiple export")
57+
.option("--multiple-template [template]", "The template to sue for file-naming multiple export")
58+
.option("--trace-template [template]", "The template to sue for SVG traces")
5759

5860
.parse(process.argv);
5961

@@ -72,6 +74,7 @@ explorer.search()
7274
config = config || {}; // read config
7375
const CLIConfig = {}; // config from flags
7476

77+
/** Map the CLI option names to config keys */
7578
const configMappings = {
7679
in: null,
7780
out: null,
@@ -91,7 +94,9 @@ explorer.search()
9194
convert: null,
9295
singleTemplate: "singleExportTemplate",
9396
multipleTemplate: "multipleExportTemplate",
94-
fingerprint: null
97+
fingerprint: null,
98+
trace: null,
99+
traceTemplate: null
95100
}
96101

97102
for (const prop of Object.keys(configMappings)) {
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)