Re: [Rd] vignettes: problems with PDF compaction
On 4/22/2013 5:51 PM, Uwe Ligges wrote: But this doesn't do anything, not even changing the timestamp on the file, because the file size doesn't change enough. Either you changed it or not, there is no not enough. I meant that the code in tools::compact compares the sizes of the old and new files and only replaces the old file if the change in size is sufficient: if (new/old 0.9 new old - 1) { file.copy(tf, p, overwrite = TRUE) } At any rate, with R_GSCMD now fixed (Thx: Henrik), tools::compactPDF, with gs_quality=ebook, still does not reduce the size of my HE-examples.pdf file. I tried the same on my Ubuntu system (R 2.15.2 also), and there I get tools::compactPDF(HE-examples.pdf, gs_quality=ebook) compacted 'HE-examples.pdf' from 739Kb to 366Kb So, I can now copy the compacted file back to my development tree on Windows; however, as I understand things, vignettes are re-built by R CMD build and --compact-vignettes=gs+qpdf has no effect. So my Ubuntu-compacted file will be overwritten. It's somewhat maddening to have to spend so much time to save ~373Kb in order to avoid a CRAN warning. -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] vignettes: problems with PDF compaction
On 4/21/2013 1:28 PM, Michael Friendly wrote: [Env: OS: Win Xp; R 2.15.2; IDE: eclipse/StatET] Each time I update my heplots package, I get warnings from R CMD check on R-Forge, * checking sizes of PDF files under ‘inst/doc’ ... WARNING ‘gs+qpdf’ made some significant size reductions: compacted ‘HE-examples.pdf’ from 739Kb to 366Kb To follow up my own post, I did some more checking of whether/how to compact PDFs on my own system. My conclusion is that that I am unable to comply with the request from CRAN maintainers, even though I would like to. Once again, I wonder why this cannot be handled on the CRAN side automatically. qpdf: running it from a cmd prompt (using the options from tools::compactPDF) doesn't do very much compression C:\R\testqpdf --stream-data=compress --object-streams=generate HE-examples.pdf HE-examples-comp.pdf C:\R\testdir HE-examples* 04/22/2013 10:55 AM 699,191 HE-examples-comp.pdf 04/22/2013 10:28 AM 756,624 HE-examples.pdf gs: I have gs installed at C:\Program Files\gs\gs9.07\bin\gswin32.exe, but the gs installer doesn't put itself on the path, so tools::compactPDF sees gs_cmd as empty: gs_cmd = Sys.getenv(R_GSCMD, ) [1] so it can't run gs+qpdf. OK, so I try to do it manually: Sys.setenv(R_GSCMD = C:/Program Files/gs/gs9.07/bin/gswin32.exe) setwd(test) tools::compactPDF(HE-examples.pdf) tools::compactPDF(HE-examples.pdf, gs_quality=ebook) But this doesn't do anything, not even changing the timestamp on the file, because the file size doesn't change enough. C:\R\testdir HE-examples.pdf 04/22/2013 10:28 AM 756,624 HE-examples.pdf -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] vignettes: problems with PDF compaction
On 22.04.2013 17:59, Michael Friendly wrote: On 4/21/2013 1:28 PM, Michael Friendly wrote: [Env: OS: Win Xp; R 2.15.2; IDE: eclipse/StatET] Each time I update my heplots package, I get warnings from R CMD check on R-Forge, * checking sizes of PDF files under ‘inst/doc’ ... WARNING ‘gs+qpdf’ made some significant size reductions: compacted ‘HE-examples.pdf’ from 739Kb to 366Kb To follow up my own post, I did some more checking of whether/how to compact PDFs on my own system. My conclusion is that that I am unable to comply with the request from CRAN maintainers, even though I would like to. Once again, I wonder why this cannot be handled on the CRAN side automatically. Because we cannot know if the result is acceptable. This is not a lossless compression. qpdf: running it from a cmd prompt (using the options from tools::compactPDF) doesn't do very much compression C:\R\testqpdf --stream-data=compress --object-streams=generate HE-examples.pdf HE-examples-comp.pdf C:\R\testdir HE-examples* 04/22/2013 10:55 AM 699,191 HE-examples-comp.pdf 04/22/2013 10:28 AM 756,624 HE-examples.pdf gs: I have gs installed at C:\Program Files\gs\gs9.07\bin\gswin32.exe, but the gs installer doesn't put itself on the path, so tools::compactPDF sees gs_cmd as empty: gs_cmd = Sys.getenv(R_GSCMD, ) [1] so it can't run gs+qpdf. OK, so I try to do it manually: Sys.setenv(R_GSCMD = C:/Program Files/gs/gs9.07/bin/gswin32.exe) setwd(test) tools::compactPDF(HE-examples.pdf) tools::compactPDF(HE-examples.pdf, gs_quality=ebook) But this doesn't do anything, not even changing the timestamp on the file, because the file size doesn't change enough. Either you changed it or not, there is no not enough. Best, Uwe C:\R\testdir HE-examples.pdf 04/22/2013 10:28 AM 756,624 HE-examples.pdf __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] vignettes: problems with PDF compaction
It's certainly not obvious, but you should use 'gswin32c.exe' instead of 'gswin32.exe'. From http://ghostscript.com/doc/current/Install.htm#Install_Windows GSWIN32C.EXE Ghostscript as a 32-bit Windows command line program. This is usually the preferred executable. GSWIN32.EXE 32-bit Ghostscript using its own window for commands Basically, 'gswin32c.exe' corresponds to 'gs' on Unix systems (the other one tries to open its own Windows which doesn't work). If you're installing the 64-bit version of Ghostscript, use 'gswin64c.exe'. You can verify that you have the proper setup by: Sys.setenv(R_GSCMD=C:/Program Files/gs/gs9.07/bin/gswin32c.exe) res - system2(Sys.getenv(R_GSCMD), args=--version) 9.07 res [1] 0 If you get 127 it indicates an error/command not found, e.g. Sys.setenv(R_GSCMD=C:/Program Files/gs/gs9.07/bin/gswin32c.exeHIDE) res - system2(Sys.getenv(R_GSCMD), args=--version) res [1] 127 So, after confirming that you get res == 0, then retry with: tools::compactPDF(HE-examples.pdf, gs_quality=ebook) FYI, you can set your R_GSCMD in C:/Users/foo/.Renviron, cf. help(.Renviron). Hope this helps Henrik On Mon, Apr 22, 2013 at 2:51 PM, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 22.04.2013 17:59, Michael Friendly wrote: On 4/21/2013 1:28 PM, Michael Friendly wrote: [Env: OS: Win Xp; R 2.15.2; IDE: eclipse/StatET] Each time I update my heplots package, I get warnings from R CMD check on R-Forge, * checking sizes of PDF files under ‘inst/doc’ ... WARNING ‘gs+qpdf’ made some significant size reductions: compacted ‘HE-examples.pdf’ from 739Kb to 366Kb To follow up my own post, I did some more checking of whether/how to compact PDFs on my own system. My conclusion is that that I am unable to comply with the request from CRAN maintainers, even though I would like to. Once again, I wonder why this cannot be handled on the CRAN side automatically. Because we cannot know if the result is acceptable. This is not a lossless compression. qpdf: running it from a cmd prompt (using the options from tools::compactPDF) doesn't do very much compression C:\R\testqpdf --stream-data=compress --object-streams=generate HE-examples.pdf HE-examples-comp.pdf C:\R\testdir HE-examples* 04/22/2013 10:55 AM 699,191 HE-examples-comp.pdf 04/22/2013 10:28 AM 756,624 HE-examples.pdf gs: I have gs installed at C:\Program Files\gs\gs9.07\bin\gswin32.exe, but the gs installer doesn't put itself on the path, so tools::compactPDF sees gs_cmd as empty: gs_cmd = Sys.getenv(R_GSCMD, ) [1] so it can't run gs+qpdf. OK, so I try to do it manually: Sys.setenv(R_GSCMD = C:/Program Files/gs/gs9.07/bin/gswin32.exe) setwd(test) tools::compactPDF(HE-examples.pdf) tools::compactPDF(HE-examples.pdf, gs_quality=ebook) But this doesn't do anything, not even changing the timestamp on the file, because the file size doesn't change enough. Either you changed it or not, there is no not enough. Best, Uwe C:\R\testdir HE-examples.pdf 04/22/2013 10:28 AM 756,624 HE-examples.pdf __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] vignettes: problems with PDF compaction
[Env: OS: Win Xp; R 2.15.2; IDE: eclipse/StatET] Each time I update my heplots package, I get warnings from R CMD check on R-Forge, * checking sizes of PDF files under ‘inst/doc’ ... WARNING ‘gs+qpdf’ made some significant size reductions: compacted ‘HE-examples.pdf’ from 739Kb to 366Kb and upon submission to CRAN, a message from maintainers: On CRAN now: but again there were warnings about significant size reductions in PDF compaction, which should really be fixed on your end. however, I am unable to find what to do to fix this on my end. In my package directory, I have the vignette sources all under vignettes/, with copies of the .pdf and .Rnw under inst/doc for historical reasons. [Q: can I now safely delete the copies under inst/doc ?] inst/doc/ HE-examples.pdf HE-examples.Rnw vignettes/ HE-examples.pdf HE-examples.Rnw HE-examples.bib fig/ ... I have qpdf installed: Sys.which(Sys.getenv(R_QPDF, qpdf)) qpdf c:\\Rtools\\bin\\qpdf.exe but, if I try to run it on the vignettes/HE-examples.pdf file, nothing happens: tools::compactPDF(C:/Documents/workspace/heplots/vignettes/HE-examples.pdf) Since vignettes are re-built from sources and then installed into inst/doc, I don't see why PDF compaction cannot be run as part of the build process. That is, if R CMD check --as-cran detects a problem, shouldn't there be some option for R CMD build that would run gs+qpdf to correct it? The idea of vignettes for R packages is a good thing, but, this problem (and others with vignettes) discourages me from using vignettes in packages, a bad thing. -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] vignettes: problems with PDF compaction
On 21.04.2013 19:28, Michael Friendly wrote: [Env: OS: Win Xp; R 2.15.2; IDE: eclipse/StatET] Each time I update my heplots package, I get warnings from R CMD check on R-Forge, * checking sizes of PDF files under ‘inst/doc’ ... WARNING ‘gs+qpdf’ made some significant size reductions: compacted ‘HE-examples.pdf’ from 739Kb to 366Kb and upon submission to CRAN, a message from maintainers: On CRAN now: but again there were warnings about significant size reductions in PDF compaction, which should really be fixed on your end. however, I am unable to find what to do to fix this on my end. In my package directory, I have the vignette sources all under vignettes/, with copies of the .pdf and .Rnw under inst/doc for historical reasons. [Q: can I now safely delete the copies under inst/doc ?] inst/doc/ HE-examples.pdf HE-examples.Rnw vignettes/ HE-examples.pdf HE-examples.Rnw HE-examples.bib fig/ ... I have qpdf installed: Sys.which(Sys.getenv(R_QPDF, qpdf)) qpdf c:\\Rtools\\bin\\qpdf.exe but, if I try to run it on the vignettes/HE-examples.pdf file, nothing happens: tools::compactPDF(C:/Documents/workspace/heplots/vignettes/HE-examples.pdf) Since vignettes are re-built from sources and then installed into inst/doc, I don't see why PDF compaction cannot be run as part of the build process. That is, if R CMD check --as-cran detects a problem, shouldn't there be some option for R CMD build that would run gs+qpdf to correct it? Yes, see R CMD build --help that tells you --compact-vignettes= try to compact PDF files under inst/doc: no (default), qpdf, gs, gs+qpdf, both Best, Uwe Ligges The idea of vignettes for R packages is a good thing, but, this problem (and others with vignettes) discourages me from using vignettes in packages, a bad thing. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] vignettes: problems with PDF compaction
On 4/21/2013 1:47 PM, Uwe Ligges wrote: Since vignettes are re-built from sources and then installed into inst/doc, I don't see why PDF compaction cannot be run as part of the build process. That is, if R CMD check --as-cran detects a problem, shouldn't there be some option for R CMD build that would run gs+qpdf to correct it? Yes, see R CMD build --help that tells you --compact-vignettes= try to compact PDF files under inst/doc: no (default), qpdf, gs, gs+qpdf, both I meant that perhaps R-Forge and CRAN could *automatically* do the compaction. I *do* run R CMD build on my machine with options --compact-vignettes=qpdf --keep-empty-dirs --resave-data giving the log info: * checking for file 'C:/Documents/workspace/heplots/DESCRIPTION' ... OK * preparing 'heplots': * checking DESCRIPTION meta-information ... OK * installing the package to re-build vignettes * creating vignettes ... OK * compacting vignettes and other PDF files * checking for LF line-endings in source and make files * checking for empty or unneeded directories * looking to see if a 'data/datalist' file should be added * re-saving image files * building 'heplots_1.0-9.tar.gz' However: (a) the heplots_1.0-9.tar.gz source package is built outside of the workspace source tree I sync with R-Forge (b) when I examine the heplots_1.0-9.tar.gz source package, the file heplots/inst/doc/HE-examples has not been modified in size. So, I still don't know how to correct this on my end. -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel