Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace formatQuality with formatOptions for additional configurability #1327

Merged
merged 3 commits into from
Aug 10, 2024

Conversation

nathreed
Copy link
Contributor

Per the (brief) discussion #1281, this PR replaces the formatQuality option in the config file with formatOptions.

The documentation is also updated with examples for the previous JPEG and WebP quality settings as well as the new PNG options.

Comment on lines 506 to 516
const formatQuality = (options.formatQuality || {})[format];
const formatOptions = (options.formatOptions || {})[format] || {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like options.formatQuality should still be supported (IOW, when people would update to a new version, they suddenly wouldn't get lower or higher qualities than what they expect), maybe log a deprecation warning though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, this is done. formatQuality is still supported but will produce a deprecation warning if it's found. formatOptions is preferred over formatQuality.

@nathreed nathreed requested a review from akx July 31, 2024 17:18
@acalcutt acalcutt force-pushed the expanded_format_options branch 2 times, most recently from b5e3fe7 to 304743b Compare August 9, 2024 19:19
Copy link
Collaborator

@acalcutt acalcutt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good and offers a good path for people using the old option.

One thing to note is when testing the 4 colors noted in the documentation I did see some text that had different colors, i think it was text that crosses the tile border.
image

not sure this is fixable since the colors are being determined per tile

formatQuality is more flexible and allows configuration of more than just quality for all formats.
JPEG and WebP still have only their quality configurable.
PNG has all the configuration options from the sharp library exposed.

Signed-off-by: Nathan Reed <[email protected]>
@acalcutt acalcutt merged commit 1f5a580 into maptiler:master Aug 10, 2024
6 checks passed
@nathreed
Copy link
Contributor Author

One thing to note is when testing the 4 colors noted in the documentation I did see some text that had different colors, i think it was text that crosses the tile border.

yeah, I noticed this in testing too. Unfortunately sharp doesn’t seem to let you specify which four colors you want. Maybe we should pick a different example for the documentation, one that people would be more likely to use? I think it’s fine as-is (people would probably find this pretty quick) but happy to change it if you think we should.

@acalcutt
Copy link
Collaborator

I wouldn't mind a PR to change the docs to better defaults that are less likely to cause issues.

@ampledata
Copy link

Should this configuration parameter work with mbtiles with png tiles? For example, if I use mapTiler to build a mbtiles file, and select PNG as the output format, can I assume that formatOptions will apply to those PNGs? I ask because I've tried this but haven't noticed any options being applied. I'm testing on the v5.0.0 Docker image.

@acalcutt
Copy link
Collaborator

acalcutt commented Oct 6, 2024

It would not apply to your data files, so it would not change the png images inside your mbtiles.

tiles that are rendered like the style raster endpoints or static image endpoints would be changed by this.

@ampledata
Copy link

ampledata commented Oct 6, 2024

I understand this will not change the files within the mbtiles, and to clarify I meant the rendered tiles that the tileserver serves from within the mbtiles - that is, will this change apply to the tiles rendered on the fly FROM the mbtiles file, served by tileserver? I guess I don't totally understand how these options are apply, or where, or to what.

@acalcutt
Copy link
Collaborator

acalcutt commented Oct 6, 2024

It will not change the pngs served from you data files either. It serves those as is

Like i said, it only affects rendered images, so that would be the rendered 'raster' endpoint under styles or the image endpoints under styles.
https://tileserver.readthedocs.io/en/latest/endpoints.html#rendered-tiles
https://tileserver.readthedocs.io/en/latest/endpoints.html#static-images
( the rendered-tiles endpoint is also used in the TileJSON, WMTS, and XYZ endpoints)

If you wanted to render your data files with different format options, you could make a style that uses that data source and include it as a layer. then the resulting images from your style would be rendered with the formatOptions you set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants