From a3188a9b2507c3cb4ae92ee452518f4475feac84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Priv=C3=A9?= Date: Thu, 24 Oct 2024 09:07:45 +0200 Subject: [PATCH] update a bit --- .Rbuildignore | 3 +- .github/.gitignore | 1 + .github/workflows/R-CMD-check.yaml | 52 ++++++++++++++++++++++++++++++ .travis.yml | 42 ------------------------ DESCRIPTION | 11 +++---- R/downsize.R | 4 +-- R/kmeans.R | 4 +-- R/pixelart-package.r | 11 ++++--- README.md | 18 +++++++---- appveyor.yml | 45 -------------------------- inst/shiny/resize/app.R | 2 +- man/colors_kmeans.Rd | 2 +- man/crop.Rd | 2 +- man/downsize.Rd | 2 +- man/kmeans_colors.Rd | 2 +- man/pipeline.Rd | 16 +++++++-- man/pixelart-package.Rd | 26 +++++++++++++++ man/pixelart.Rd | 13 -------- man/reexports.Rd | 4 +-- man/run_pixelart.Rd | 26 ++++++++------- man/run_resize.Rd | 26 ++++++++------- package.txt | 8 ----- 22 files changed, 157 insertions(+), 163 deletions(-) create mode 100644 .github/.gitignore create mode 100644 .github/workflows/R-CMD-check.yaml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml create mode 100644 man/pixelart-package.Rd delete mode 100644 man/pixelart.Rd delete mode 100644 package.txt diff --git a/.Rbuildignore b/.Rbuildignore index f4c0d30..06bd211 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,5 +5,4 @@ ^update-webshot\.R$ ^tmp-tests$ ^kongs\.png$ -^\.travis\.yml$ -^appveyor\.yml$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..d46a617 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,52 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check.yaml + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 72dded9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -# Sample .travis.yml for R projects - -language: r - -matrix: - include: - - r: release - os: osx - brew_packages: imagemagick - - r: release - os: linux - after_success: travis_wait Rscript -e 'covr::codecov()' - - r: devel - os: linux - -addons: - apt: - update: true - sources: - - sourceline: 'ppa:opencpu/imagemagick' - - sourceline: 'ppa:ubuntugis/ppa' - packages: - - libmagick++-dev - - librsvg2-dev - - libwebp-dev - - libpoppler-cpp-dev - - libtesseract-dev - - libleptonica-dev - - tesseract-ocr-eng - - r-cran-rgdal - - libfftw3-dev - - cargo - -sudo: false -cache: packages -warnings_are_errors: true -r_check_args: "--no-manual --timings" - -notifications: - email: - on_success: change - on_failure: change diff --git a/DESCRIPTION b/DESCRIPTION index 1135bba..1a39b1a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,12 @@ Package: pixelart -Title: Make Pixel Art Models From Pictures -Version: 0.2.0 -Date: 2018-08-01 +Title: Resize Images and Make Pixel Art Models From Pictures +Version: 0.2.1 +Date: 2024-10-24 Authors@R: person("Florian", "Privé", email = "florian.prive.21@gmail.com", role = c("aut", "cre")) -Description: Make Pixel Art models from pictures. +Description: Resize and crop images, and make Pixel Art models from pictures (Shiny app). Depends: R (>= 3.3.0) Imports: flexclust, @@ -19,8 +19,7 @@ Imports: stringr License: GPL-3 Encoding: UTF-8 -LazyData: true URL: https://privefl.github.io/pixelart BugReports: https://github.com/privefl/pixelart/issues -RoxygenNote: 6.1.0 +RoxygenNote: 7.3.2 Roxygen: list(markdown = TRUE) diff --git a/R/downsize.R b/R/downsize.R index 6f1f8d6..394ebea 100644 --- a/R/downsize.R +++ b/R/downsize.R @@ -2,7 +2,7 @@ #' Downsize an image #' -#' @inheritParams pixelart +#' @inheritParams pixelart-package #' @param npixel_width Number of pixels for the width of the image. #' #' @return An image object of package **Magick** of reduced or equal size. @@ -22,7 +22,7 @@ downsize <- function(im, npixel_width = 200) { #' Crop image #' -#' @inheritParams pixelart +#' @inheritParams pixelart-package #' @param left Number of pixels to crop to the left #' @param top Number of pixels to crop to the top #' @param right Number of pixels to crop to the right diff --git a/R/kmeans.R b/R/kmeans.R index 6e150bd..58c523b 100644 --- a/R/kmeans.R +++ b/R/kmeans.R @@ -2,7 +2,7 @@ #' Perform K-means on RGB colors #' -#' @inheritParams pixelart +#' @inheritParams pixelart-package #' @param ncolors Number of colors (clusters). Default is 8. #' #' @return An object of class *kcca* of package **flexclust**. @@ -28,7 +28,7 @@ kmeans_colors <- function(im, ncolors = 8) { #' #' Get projection on kmeans for colors of image. #' -#' @inheritParams pixelart +#' @inheritParams pixelart-package #' @param kmeans An object of class *kcca* of package **flexclust**. #' #' @return A matrix of colors (in hex format, e.g. "#ffffff"). diff --git a/R/pixelart-package.r b/R/pixelart-package.r index 924072f..7504b9f 100644 --- a/R/pixelart-package.r +++ b/R/pixelart-package.r @@ -1,11 +1,12 @@ ################################################################################ -#' pixelart. +#' @param im An image object of package magick. #' -#' @param im An image object of package **Magick**. -#' -#' @name pixelart -#' @docType package +#' @keywords internal +"_PACKAGE" + +## usethis namespace: start +## usethis namespace: end NULL ################################################################################ diff --git a/README.md b/README.md index b59e112..8660686 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,18 @@ -[![Travis build status](https://travis-ci.org/privefl/pixelart.svg?branch=master)](https://travis-ci.org/privefl/pixelart) -[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/privefl/pixelart?branch=master&svg=true)](https://ci.appveyor.com/project/privefl/pixelart) -[![CRAN status](https://www.r-pkg.org/badges/version/pixelart)](https://cran.r-project.org/package=pixelart) + +[![R-CMD-check](https://github.com/privefl/pixelart/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/privefl/pixelart/actions/workflows/R-CMD-check.yaml) +[![CRAN status](https://www.r-pkg.org/badges/version/pixelart)](https://CRAN.R-project.org/package=pixelart) + # R package {pixelart} -R Package to make Pixel Art models. [[Blog post introducing the package]](https://privefl.github.io/blog/shiny-app-for-making-pixel-art-models/) +R Package to to resize and crop images, and make Pixel Art models from your own pictures. [[Blog post introducing the package]](https://privefl.github.io/blog/shiny-app-for-making-pixel-art-models/) ```r -# Installation -devtools::install_github("privefl/pixelart") +# Installation from CRAN +install.packages("pixelart") + +# Installation from GitHub +remotes::install_github("privefl/pixelart") # Run Shiny app for pixel art models pixelart::run_pixelart() @@ -29,6 +33,8 @@ I present you Kong. **A.** Picture of Kong. **B.** Kong as a pixel art model, cr ## News +- October 24, 2024: release on CRAN + - August 1, 2018: add Shiny app for resizing images. - March 10, 2018: run kmeans in the Lab space (instead of the RGB space) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index c6c1438..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,45 +0,0 @@ -# DO NOT CHANGE the "init" and "install" sections below - -# Download script file from GitHub -init: - ps: | - $ErrorActionPreference = "Stop" - Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" - Import-Module '..\appveyor-tool.ps1' - -install: - ps: Bootstrap - -cache: - - C:\RLibrary - -# Adapt as necessary starting from here - -build_script: - - travis-tool.sh install_deps - -test_script: - - travis-tool.sh run_tests - -on_failure: - - 7z a failure.zip *.Rcheck\* - - appveyor PushArtifact failure.zip - -artifacts: - - path: '*.Rcheck\**\*.log' - name: Logs - - - path: '*.Rcheck\**\*.out' - name: Logs - - - path: '*.Rcheck\**\*.fail' - name: Logs - - - path: '*.Rcheck\**\*.Rout' - name: Logs - - - path: '\*_*.tar.gz' - name: Bits - - - path: '\*_*.zip' - name: Bits diff --git a/inst/shiny/resize/app.R b/inst/shiny/resize/app.R index a0d7622..586438f 100644 --- a/inst/shiny/resize/app.R +++ b/inst/shiny/resize/app.R @@ -102,7 +102,7 @@ server <- function(input, output, session) { glue::glue("Current size: {infos$width} x {infos$height}") }) - output$img <- renderImage({ + output$img <- renderImage(deleteFile = TRUE, { image_write(image_with_border(), tmp_jpg, format = "jpg") diff --git a/man/colors_kmeans.Rd b/man/colors_kmeans.Rd index ec0257b..ffdf189 100644 --- a/man/colors_kmeans.Rd +++ b/man/colors_kmeans.Rd @@ -7,7 +7,7 @@ colors_kmeans(im, kmeans) } \arguments{ -\item{im}{An image object of package \strong{Magick}.} +\item{im}{An image object of package magick.} \item{kmeans}{An object of class \emph{kcca} of package \strong{flexclust}.} } diff --git a/man/crop.Rd b/man/crop.Rd index bb5626f..0fde8e2 100644 --- a/man/crop.Rd +++ b/man/crop.Rd @@ -7,7 +7,7 @@ crop(im, left = 0, top = 0, right = 0, bottom = 0) } \arguments{ -\item{im}{An image object of package \strong{Magick}.} +\item{im}{An image object of package magick.} \item{left}{Number of pixels to crop to the left} diff --git a/man/downsize.Rd b/man/downsize.Rd index 9070e79..b464a20 100644 --- a/man/downsize.Rd +++ b/man/downsize.Rd @@ -7,7 +7,7 @@ downsize(im, npixel_width = 200) } \arguments{ -\item{im}{An image object of package \strong{Magick}.} +\item{im}{An image object of package magick.} \item{npixel_width}{Number of pixels for the width of the image.} } diff --git a/man/kmeans_colors.Rd b/man/kmeans_colors.Rd index 5403706..4221ffa 100644 --- a/man/kmeans_colors.Rd +++ b/man/kmeans_colors.Rd @@ -7,7 +7,7 @@ kmeans_colors(im, ncolors = 8) } \arguments{ -\item{im}{An image object of package \strong{Magick}.} +\item{im}{An image object of package magick.} \item{ncolors}{Number of colors (clusters). Default is 8.} } diff --git a/man/pipeline.Rd b/man/pipeline.Rd index bb50c4b..3a8f85a 100644 --- a/man/pipeline.Rd +++ b/man/pipeline.Rd @@ -4,9 +4,19 @@ \alias{pipeline} \title{Pipeline to get pixel art} \usage{ -pipeline(url, resize1 = 100, ncolors = 7, resize2 = 20, - color_bg = "white", saturation = 100, degrees = 0, left = 0, - top = 0, right = 0, bottom = 0) +pipeline( + url, + resize1 = 100, + ncolors = 7, + resize2 = 20, + color_bg = "white", + saturation = 100, + degrees = 0, + left = 0, + top = 0, + right = 0, + bottom = 0 +) } \arguments{ \item{url}{URL of image.} diff --git a/man/pixelart-package.Rd b/man/pixelart-package.Rd new file mode 100644 index 0000000..9fe3b9b --- /dev/null +++ b/man/pixelart-package.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pixelart-package.R +\docType{package} +\name{pixelart-package} +\alias{pixelart} +\alias{pixelart-package} +\title{pixelart: Resize Images and Make Pixel Art Models From Pictures} +\arguments{ +\item{im}{An image object of package magick.} +} +\description{ +Resize and crop images, and make Pixel Art models from pictures (Shiny app). +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://privefl.github.io/pixelart} + \item Report bugs at \url{https://github.com/privefl/pixelart/issues} +} + +} +\author{ +\strong{Maintainer}: Florian Privé \email{florian.prive.21@gmail.com} + +} +\keyword{internal} diff --git a/man/pixelart.Rd b/man/pixelart.Rd deleted file mode 100644 index 64e6f3f..0000000 --- a/man/pixelart.Rd +++ /dev/null @@ -1,13 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pixelart-package.r -\docType{package} -\name{pixelart} -\alias{pixelart} -\alias{pixelart-package} -\title{pixelart.} -\arguments{ -\item{im}{An image object of package \strong{Magick}.} -} -\description{ -pixelart. -} diff --git a/man/reexports.Rd b/man/reexports.Rd index 37ee827..0ed7a92 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pixelart-package.r +% Please edit documentation in R/pixelart-package.R \docType{import} \name{reexports} \alias{reexports} @@ -11,6 +11,6 @@ These objects are imported from other packages. Follow the links below to see their documentation. \describe{ - \item{magrittr}{\code{\link[magrittr]{\%>\%}}} + \item{magrittr}{\code{\link[magrittr:pipe]{\%>\%}}} }} diff --git a/man/run_pixelart.Rd b/man/run_pixelart.Rd index 2b1e672..d3feebc 100644 --- a/man/run_pixelart.Rd +++ b/man/run_pixelart.Rd @@ -9,31 +9,35 @@ run_pixelart(launch.browser = TRUE, ...) \arguments{ \item{launch.browser}{If true, the system's default web browser will be launched automatically after the app is started. Defaults to true in -interactive sessions only. This value of this parameter can also be a +interactive sessions only. The value of this parameter can also be a function to call with the application's URL.} -\item{...}{Arguments passed on to \code{shiny::runApp} -\describe{ - \item{port}{The TCP port that the application should listen on. If the +\item{...}{ + Arguments passed on to \code{\link[shiny:runApp]{shiny::runApp}} + \describe{ + \item{\code{port}}{The TCP port that the application should listen on. If the \code{port} is not specified, and the \code{shiny.port} option is set (with \code{options(shiny.port = XX)}), then that port will be used. Otherwise, -use a random port.} - \item{host}{The IPv4 address that the application should listen on. Defaults +use a random port between 3000:8000, excluding ports that are blocked +by Google Chrome for being considered unsafe: 3659, 4045, 5060, +5061, 6000, 6566, 6665:6669 and 6697. Up to twenty random +ports will be tried.} + \item{\code{host}}{The IPv4 address that the application should listen on. Defaults to the \code{shiny.host} option, if set, or \code{"127.0.0.1"} if not. See Details.} - \item{workerId}{Can generally be ignored. Exists to help some editions of + \item{\code{workerId}}{Can generally be ignored. Exists to help some editions of Shiny Server Pro route requests to the correct process.} - \item{quiet}{Should Shiny status messages be shown? Defaults to FALSE.} - \item{display.mode}{The mode in which to display the application. If set to + \item{\code{quiet}}{Should Shiny status messages be shown? Defaults to FALSE.} + \item{\code{display.mode}}{The mode in which to display the application. If set to the value \code{"showcase"}, shows application code and metadata from a \code{DESCRIPTION} file in the application directory alongside the application. If set to \code{"normal"}, displays the application normally. Defaults to \code{"auto"}, which displays the application in the mode given in its \code{DESCRIPTION} file, if any.} - \item{test.mode}{Should the application be launched in test mode? This is + \item{\code{test.mode}}{Should the application be launched in test mode? This is only used for recording or running automated tests. Defaults to the \code{shiny.testmode} option, or FALSE if the option is not set.} -}} + }} } \value{ Nothing. diff --git a/man/run_resize.Rd b/man/run_resize.Rd index 8b7355f..b379da5 100644 --- a/man/run_resize.Rd +++ b/man/run_resize.Rd @@ -9,31 +9,35 @@ run_resize(launch.browser = TRUE, ...) \arguments{ \item{launch.browser}{If true, the system's default web browser will be launched automatically after the app is started. Defaults to true in -interactive sessions only. This value of this parameter can also be a +interactive sessions only. The value of this parameter can also be a function to call with the application's URL.} -\item{...}{Arguments passed on to \code{shiny::runApp} -\describe{ - \item{port}{The TCP port that the application should listen on. If the +\item{...}{ + Arguments passed on to \code{\link[shiny:runApp]{shiny::runApp}} + \describe{ + \item{\code{port}}{The TCP port that the application should listen on. If the \code{port} is not specified, and the \code{shiny.port} option is set (with \code{options(shiny.port = XX)}), then that port will be used. Otherwise, -use a random port.} - \item{host}{The IPv4 address that the application should listen on. Defaults +use a random port between 3000:8000, excluding ports that are blocked +by Google Chrome for being considered unsafe: 3659, 4045, 5060, +5061, 6000, 6566, 6665:6669 and 6697. Up to twenty random +ports will be tried.} + \item{\code{host}}{The IPv4 address that the application should listen on. Defaults to the \code{shiny.host} option, if set, or \code{"127.0.0.1"} if not. See Details.} - \item{workerId}{Can generally be ignored. Exists to help some editions of + \item{\code{workerId}}{Can generally be ignored. Exists to help some editions of Shiny Server Pro route requests to the correct process.} - \item{quiet}{Should Shiny status messages be shown? Defaults to FALSE.} - \item{display.mode}{The mode in which to display the application. If set to + \item{\code{quiet}}{Should Shiny status messages be shown? Defaults to FALSE.} + \item{\code{display.mode}}{The mode in which to display the application. If set to the value \code{"showcase"}, shows application code and metadata from a \code{DESCRIPTION} file in the application directory alongside the application. If set to \code{"normal"}, displays the application normally. Defaults to \code{"auto"}, which displays the application in the mode given in its \code{DESCRIPTION} file, if any.} - \item{test.mode}{Should the application be launched in test mode? This is + \item{\code{test.mode}}{Should the application be launched in test mode? This is only used for recording or running automated tests. Defaults to the \code{shiny.testmode} option, or FALSE if the option is not set.} -}} + }} } \value{ Nothing. diff --git a/package.txt b/package.txt deleted file mode 100644 index 3512096..0000000 --- a/package.txt +++ /dev/null @@ -1,8 +0,0 @@ -- create repo on GitHub (no LICENSE) -- make it an R project -- create R/ directory -- use `devtools::create_description()` -- use `devtools::use_package_doc()` -- restart the project -- More -> Confugure Build Tools -> Generate doc -> Build & reload -- Build & reload \ No newline at end of file