concept st_asjpeg in category postgis

appears as: ST_AsJPEG
PostGIS in Action, Third Edition

This is an excerpt from Manning's book PostGIS in Action, Third Edition.

PostGIS has a number of output functions for raster data such as ST_AsPNG, ST_AsJPEG, and ST_AsTiff. ST_AsGDALRaster is an all-purpose function that outputs to all formats supported by GDAL. A newer input companion function called ST_FromGDALRaster will accept any raster supported by GDAL, provided that the entire raster fits into a single row of a table in a bytea data type column. With the combination of these two, you can easily perform powerful image processing using PostGIS. Take your old black and white photos, digitized them into JPEGs, copy them into a PostgreSQL table, storing the JPEG in a bytea column, apply colorization, and then dump them out back as JPEGs.

This would convert all your pictures (as long as they’re in a format supported by your PostGIS GDAL driver) to PostGIS raster format and insert them into the bag_o_rasters table. If you wanted to keep your images in a more common format, such as PNG or JPEG, then you’d convert back using one of the PostGIS raster companion output functions (ST_AsGDALRaster, ST_AsPNG, or ST_AsJPEG) which we’ll cover in the next section.