In preparation for a QGIS QgsRasterLite2Provider, I am building a small Database with 4 RasterCoverages of the same 2000x2000 Meter area.
<ul>
1656 : 1-BIT MONOCHROME, FAX4<br>
1811 : UINT8 RGB, JPEG<br>
1910 : UINT8 RGB, JPEG<br>
2010 : 1-BIT MONOCHROME, FAX4
</ul>
<hr>
From existing RL2 Databases the attempt was mad to extract this are from the 4 with RL2_WriteGeoTiff.<br>
For the UINT8 RGB, JPEG: no problem.<br>
For the 1-BIT MONOCHROME, FAX4: the images are blank.<br>
<hr>
All 4 are exported from 1 script<br>
- here the portion from the last image:
<pre>
-- -- ---------------------------------- --
SELECT DateTime('now','localtime'),'ATTACH DATABASE ''../2010.berlin_k5.400_dpi.db'' AS db_import';
ATTACH DATABASE '../2010.berlin_k5.400_dpi.db' AS db_import;
-- -- ---------------------------------- --
SELECT DateTime('now'),'2010.alt_berlin_coelln_friedrichsweder: pixel_size_x['||round((26000.0-24000.0)/0.3175065154982885)||'] pixel_size_y['||round((22250.0-20250.0)/0.3174918146641513)||']';
-- -- ---------------------------------- --
-- gdal_translate 2010.Berlin.5000.3068.FAX4_MINISWHITE.400.tif -projwin 24000.0 22250.000 26000.0 20250.000 2010.Alt_Berlin_Coelln_Friedrichsweder.5000.3068.tif
-- gdalinfo 2010.Alt_Berlin_Coelln_Friedrichsweder.5000.3068.tif > 2010.Alt_Berlin_Coelln_Friedrichsweder.5000.3068.tif.info.txt
-- -- ---------------------------------- --
SELECT RL2_WriteGeoTiff
(
 -- The dbPrefix argument is intended to specify the ATTACHED-DB where the Coverage is expected to be found
 'db_import',
 -- chosen name of raster_coverage
 lower('2010.berlin_k5'),
  -- directory where the files to be loaded are stored
 '2010.alt_berlin_coelln_friedrichsweder.5000.3068.tif',
 -- image-size width,height (calculate)
 -- 2143.730401266
 CAST(round((26000.0-24000.0)/0.3175065154982885) AS INTEGER),
 -- 2144.134100369
 CAST(round((22250.0-20250.0)/0.3174918146641513)AS INTEGER),
 -- area to extract,
 BuildMbr
 (
  24000.0,22250.000, 26000.0,20250.000,
  3068
 ),
 -- resolution horz/x
 0.3175065154982885,
-- resolution vert/y
 0.3174918146641513,
 -- world-file 0=no ; 1=yes
 1,
 -- compression
 'FAX4',
-- tile-size  (of tif)
 512
);
-- -- ---------------------------------- --
SELECT DateTime('now','localtime'),'DETACH DATABASE ''../2010.berlin_k5.400_dpi.db'' AS db_import';
DETACH DATABASE db_import;
-- -- ---------------------------------- --
</pre>
The shown gdal command for the same task (from the original tiff) returns correct results.
<hr>
Note on the side:<br>
When the extent is given and either
<ul>
image size <b>or</b>
resolution
</ul>
are given - the missing value should be calculated.<br>
In most cases, people will give the <b>extent</b> and <b>size</b><br>
<ul>they should not have to bother about the resolution</ul>
If no resolution or size is given (i.e. values are 0):<br>
<ul>The original resolution should be taken to calculate the size<br>
as I have done with this script</ul>
This was a part of my patch which was never looked into.