#340 closed task (fixed)
[raster] ST_AsJPEG
Reported by: | mloskot | Owned by: | Bborie Park |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.0.0 |
Component: | raster | Version: | master |
Keywords: | history | Cc: |
Description (last modified by )
This tasks belongs to the Objective 0.1.6f specified in the WKT Raster roadmap
As stated at the end of the comment 5 of the "Specification Comments following the Code Sprint" section of the working specifications, this function should be a PL/pgSQL wrapper around a more general ST_AsImage(format, params) function using GDAL to convert any raster to an image.
The function should return a bytea.
This function is particularly sensible to the number of band present in the raster as it normally needs 3 band (r,g,b).
It is also very sensible to the pixel type of the raster since JPEG supports only values in the 0-255 range.
See the working specifications for more details/questions.
Priority should be given to these variants:
ST_AsJPEG(raster, integer)
ST_AsJPEG(raster, integer, integer, integer, integer)
ST_AsJPEG(raster, integer, "GRAYSCALE", integer, min, max, text)
Attachments (3)
Change History (19)
comment:1 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 15 years ago
Version: | → trunk |
---|
comment:3 by , 15 years ago
Description: | modified (diff) |
---|
comment:4 by , 15 years ago
Description: | modified (diff) |
---|
comment:5 by , 14 years ago
Milestone: | WKTRaster 0.1.6 → WKTRaster Future |
---|
comment:6 by , 14 years ago
Summary: | [wktraster] Implement ST_AsJPEG function for raster → [raster] Implement ST_AsJPEG function for raster |
---|
comment:7 by , 14 years ago
Status: | assigned → new |
---|
comment:8 by , 14 years ago
The JPEG format has several limitations:
- JPEG only allows 1 (greyscale) or 3 (RGB) bands of data
- JPEG only supports 8BUI pixeltype
- JPEG cannot embed spatial reference information within the file
To address the limitations:
- Use ST_Band to specify which band(s) should be passed to the ST_AsJPEG function. Variations of ST_AsJPEG are made available that allows specifying a band index. If a raster whose number of specified bands does not equal 1 or 3 is provided, a warning is raised and the first or the first three bands are used.
- Throw an exception if any of the specified bands is not 8BUI. The user should use ST_Reclass to convert any non-8BUI bands to 8BUI.
- Nothing can be done.
A proposed set of variations of the ST_AsJPEG function:
- ST_AsJPEG(rast raster, options text[])
rast: the raster with one or three bands in 8BUI pixel type to generate a JPEG image from
options: array of creation options to pass to the GDAL JPEG driver
ST_AsJPEG(rast, ARRAY['QUALITY=90', 'PROGRESSIVE=ON'])
- ST_AsJPEG(rast raster)
Like #1 above but use the driver's default creation options
- ST_AsJPEG(rast raster, nbands int[], options text[])
nbands: an integer array specifying the band indices of the raster to include in the JPEG file
ST_AsJPEG(rast, ARRAY[1,3,6], ARRAY['QUALITY=50'])
- ST_AsJPEG(rast raster, nbands int[])
Like #3, but use the default creation options
ST_AsJPEG(rast, ARRAY[1,3,6])
- ST_AsJPEG(rast raster, compression int)
compression: number between 10 and 100 indicating image quality
ST_AsJPEG(rast, 90)
- ST_AsJPEG(rast raster, nbands int[] compression int)
ST_AsJPEG(rast, ARRAY[1,2,3], 90)
- ST_AsJPEG(rast raster, nband int, options text[])
nband: index of the band to include
ST_AsJPEG(rast, 2, ARRAY['QUALITY=25'])
- ST_AsJPEG(rast raster, nband int, compression int)
ST_AsJPEG(rast, 5, 75)
- ST_AsJPEG(rast raster, nband int)
ST_AsJPEG(rast, 4)
In looking over the working spec's ST_AsJPEG, I don't believe the GREYSCALE variations are usable as the JPEG driver automatically creates a greyscale image if the raster passed to it has one band.
comment:10 by , 14 years ago
Just for the record, JPEG cannot embed spatial reference information within the file but an application can get a sister wordfile with this query: SELECT ST_Georeference(rast) FROM mytable.
comment:11 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:12 by , 14 years ago
Attached incremental patch for adding ST_AsJPEG. Patch can be applied with the following in the base postgis source directory.
patch -p1 < st_asjpeg.patch
Patches for ST_Band, ST_MinMax, ST_Reclass and ST_AsGDALRaster must be applied first in the order listed.
comment:13 by , 14 years ago
Summary: | [raster] Implement ST_AsJPEG function for raster → [raster] ST_AsJPEG |
---|
by , 14 years ago
Attachment: | st_asjpeg.2.patch added |
---|
No changes made. Update diff due to incremental changes in ST_MinMax.
comment:14 by , 13 years ago
Add ST_AsJPEG. Merges cleanly against r7145.
The following patches must be merged first for this patch to merge cleanly:
- ST_Band
- ST_SummaryStats
- ST_Mean
- ST_StdDev
- ST_MinMax
- ST_Histogram
- ST_Quantile
- ST_Reclass
- ST_AsGDALRaster
- ST_AsTIFF
comment:15 by , 13 years ago
Keywords: | history added |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Added in r7157
comment:16 by , 13 years ago
Milestone: | PostGIS Raster Future → PostGIS 2.0.0 |
---|
A more general ST_AsImage invoking GDAL should be implemented first. ST_AsJPEG should be a wrapper around this more generic function.