JonasKruckenberg / imagetools

Load and transform images using a toolbox :toolbox: of custom import directives!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add documentation showing how to save jpegs as progressive

KMarshland opened this issue · comments

Currently, there's nothing in the documentation (at least that I can find) about saving jpegs as progressive, despite it being supported. This should be updated.

For reference, the following default directives code makes all jpgs use progressive interlacing.

defaultDirectives: (url) => {
    if (!url.searchParams.get('format') && (url.pathname.endsWith('.jpg') || url.pathname.endsWith('.jpeg'))) {
        url.searchParams.set('format', 'jpeg');
    }

    if (url.searchParams.get('format') === 'jpeg') {
        url.searchParams.set('progressive', 'true');
    }

    return url.searchParams;
}