| 221 | Bborie: The JPEG format has several limitations: |
| 222 | |
| 223 | 1. JPEG only allows 1 (greyscale) or 3 (RGB) bands of data |
| 224 | |
| 225 | 2. JPEG only supports 8BUI pixeltype |
| 226 | |
| 227 | 3. JPEG cannot embed spatial reference information within the file but can have an associated world file |
| 228 | |
| 229 | To address the limitations: |
| 230 | |
| 231 | 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. |
| 232 | |
| 233 | 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. |
| 234 | |
| 235 | 3. Nothing can be done. |
| 236 | |
| 237 | A proposed set of variations of the ST_AsJPEG function: |
| 238 | |
| 239 | 1. ST_AsJPEG(rast raster, options text[]) |
| 240 | |
| 241 | rast: the raster with one or three bands in 8BUI pixel type to generate a JPEG image from |
| 242 | |
| 243 | options: array of creation options to pass to the GDAL JPEG driver |
| 244 | |
| 245 | {{{ |
| 246 | ST_AsJPEG(rast, ARRAY['QUALITY=90', 'PROGRESSIVE=ON']) |
| 247 | }}} |
| 248 | |
| 249 | 2. ST_AsJPEG(rast raster) |
| 250 | |
| 251 | Like !#1 above but use the driver's default creation options |
| 252 | |
| 253 | 3. ST_AsJPEG(rast raster, nbands int[], options text[]) |
| 254 | |
| 255 | nbands: an integer array specifying the band indices of the raster to include in the JPEG file |
| 256 | |
| 257 | {{{ |
| 258 | ST_AsJPEG(rast, ARRAY[1,3,6], ARRAY['QUALITY=50']) |
| 259 | }}} |
| 260 | |
| 261 | 4. ST_AsJPEG(rast raster, nbands int[]) |
| 262 | |
| 263 | Like !#3, but use the default creation options |
| 264 | |
| 265 | {{{ |
| 266 | ST_AsJPEG(rast, ARRAY[1,3,6]) |
| 267 | }}} |
| 268 | |
| 269 | 5. ST_AsJPEG(rast raster, nbands int[], quality int) |
| 270 | |
| 271 | quality: number between 10 and 100 indicating image quality |
| 272 | |
| 273 | {{{ |
| 274 | ST_AsJPEG(rast, ARRAY[1,2,3], 90) |
| 275 | }}} |
| 276 | |
| 277 | 6. ST_AsJPEG(rast raster, nband int, options text[]) |
| 278 | |
| 279 | nband: index of the band to include |
| 280 | |
| 281 | {{{ |
| 282 | ST_AsJPEG(rast, 2, ARRAY['QUALITY=25']) |
| 283 | }}} |
| 284 | |
| 285 | 7. ST_AsJPEG(rast raster, nband int, quality int) |
| 286 | |
| 287 | {{{ |
| 288 | ST_AsJPEG(rast, 5, 75) |
| 289 | }}} |
| 290 | |
| 291 | 8. ST_AsJPEG(rast raster, nband int) |
| 292 | |
| 293 | {{{ |
| 294 | ST_AsJPEG(rast, 4) |
| 295 | }}} |