Does it have to be pure R? Imagemagick provides command-line tools to do
that, and can be called from within R using system().
Sarah
On Wednesday, January 21, 2015, Vera Thiemig <
vera.thiemig at ext.jrc.ec.europa.eu> wrote:
> Dear all,
>
>
>
> I would like to reduce the bit depth of a png file from originally 24 to 8
> (with the main intention to decrease the file size).
>
>
>
> With the ordinary png(.) command it seems to be not possible. So, I created
> first the png file and then re-wrote it with writePNG of the png package
> (http://cran.r-project.org/web/packages/png/png.pdf) as it is written
> that:
>
>
>
> "Currently writePNG only produces 8-bit, deflate-compressed,
non-quantized,
> non-interlaced images. Note in particular that readPNG can read 16-bit
> channels but storing them back using writePNG will strip the 8 LSB
> (irrelevant for display purposes but possibly relevant for use of PNG in
> signalprocessing if the input is truly 16-bit wide)."
>
>
>
> However, I end up with a 24-bit file again :(
>
>
>
> Anybody has an idea of how to proceed?
>
>
>
> Thank you,
>
>
>
> Vera
>
>
>
>
--
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org
[[alternative HTML version deleted]]