[postgis-devel] [PostGIS] #340: [raster] Implement ST_AsJPEG function for raster

PostGIS trac at osgeo.org
Tue Apr 19 07:13:54 PDT 2011


#340: [raster] Implement ST_AsJPEG function for raster
----------------------------+-----------------------------------------------
 Reporter:  mloskot         |       Owner:  mloskot              
     Type:  task            |      Status:  new                  
 Priority:  medium          |   Milestone:  PostGIS Raster Future
Component:  postgis raster  |     Version:  trunk                
 Keywords:                  |  
----------------------------+-----------------------------------------------

Comment(by dustymugs):

 The JPEG format has several limitations:

 1. JPEG only allows 1 (greyscale) or 3 (RGB) bands of data

 2. JPEG only supports 8BUI pixeltype

 3. JPEG cannot embed spatial reference information within the file

 To address the limitations:

 1. 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.

 2. 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.

 3. Nothing can be done.

 A proposed set of variations of the ST_AsJPEG function:

 1. 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'])
 }}}

 2. ST_AsJPEG(rast raster)

   Like !#1 above but use the driver's default creation options

 3. 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'])
 }}}

 4. ST_AsJPEG(rast raster, nbands int[])

   Like !#3, but use the default creation options

 {{{
 ST_AsJPEG(rast, ARRAY[1,3,6])
 }}}

 5. ST_AsJPEG(rast raster, compression int)

   compression: number between 10 and 100 indicating image quality

 {{{
 ST_AsJPEG(rast, 90)
 }}}

 6. ST_AsJPEG(rast raster, nbands int[] compression int)

 {{{
 ST_AsJPEG(rast, ARRAY[1,2,3], 90)
 }}}

 7. ST_AsJPEG(rast raster, nband int, options text[])

   nband: index of the band to include

 {{{
 ST_AsJPEG(rast, 2, ARRAY['QUALITY=25'])
 }}}

 8. ST_AsJPEG(rast raster, nband int, compression int)

 {{{
 ST_AsJPEG(rast, 5, 75)
 }}}

 9. 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.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/340#comment:8>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list