If your data is sourced from a single zoom level, e.g. aerial imagery
GDAL does this easily:
gdal_translate -co TILE_FORMAT=JPEG \
-of MBTILES png.mbtiles jpg.mbtiles
For generating the zoom levels, one needs to use gdaladdo afterwards:
gdaladdo -r average jpg.mbtiles
For more information on the tools, see https://www.gdal.org/gdal_translate.html and https://www.gdal.org/gdaladdo.html
For more information on the format and the options GDAL offers when writing it (for example QUALITY
), see https://www.gdal.org/frmt_mbtiles.html
If you have different styles per zoom level
Using the GDAL approach above would drop all your zoom levels except the highest one and recalculate the others. This will be bad if you had per-zoomlevel styles. In that case you can use mbutil and any tool you like for mass-converting images from PNG to JPEG:
First extract all the tiles:
mb-util png.mbtiles tiles
Then convert all the PNG files to JPEG, I used this on Linux:
find tiles -name "*.png" | xargs convert -verbose -format jpg -quality 85
Then collect the tiles into a mbtiles file again:
mb-util --image_format=jpg tiles jpg2.mbtiles