{"id":22823132,"url":"https://github.com/jonclayden/loder","last_synced_at":"2025-04-23T03:48:44.446Z","repository":{"id":56937231,"uuid":"88974602","full_name":"jonclayden/loder","owner":"jonclayden","description":"Dependency-Free Access to PNG Image Files","archived":false,"fork":false,"pushed_at":"2022-12-16T18:41:38.000Z","size":202,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-23T03:48:39.446Z","etag":null,"topics":["image","image-processing","png","r"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonclayden.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-21T10:54:00.000Z","updated_at":"2025-03-22T11:16:56.000Z","dependencies_parsed_at":"2023-01-29T15:45:34.900Z","dependency_job_id":null,"html_url":"https://github.com/jonclayden/loder","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonclayden%2Floder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonclayden%2Floder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonclayden%2Floder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonclayden%2Floder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonclayden","download_url":"https://codeload.github.com/jonclayden/loder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250366682,"owners_count":21418768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image","image-processing","png","r"],"created_at":"2024-12-12T16:14:20.280Z","updated_at":"2025-04-23T03:48:44.401Z","avatar_url":"https://github.com/jonclayden.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"```{r, echo=FALSE}\noptions(mmand.display.newDevice=FALSE)\nknitr::opts_chunk$set(collapse=TRUE, fig.path=\"tools/figures/\", fig.dim=c(1,1), dpi=128)\n```\n\n[![CRAN version](http://www.r-pkg.org/badges/version/loder)](https://cran.r-project.org/package=loder) [![CI](https://github.com/jonclayden/loder/actions/workflows/ci.yaml/badge.svg)](https://github.com/jonclayden/loder/actions/workflows/ci.yaml) [![codecov](https://codecov.io/gh/jonclayden/loder/branch/master/graph/badge.svg)](https://app.codecov.io/gh/jonclayden/loder) [![status](https://tinyverse.netlify.com/badge/loder)](https://cran.r-project.org/package=loder)\n\n# Simple, dependency-free access to PNG images\n\nThe `loder` package provides functions for easily reading from PNG image files and writing to them. It functions in a very similar way to Simon Urbanek's venerable [`png` package](https://github.com/s-u/png), but unlike that package it does not require external `libpng` and `zlib` libraries to be installed. Instead, `loder` includes Lode Vandevenne's compact LodePNG library, which provides self-contained PNG read and write functionality.\n\n## Installation\n\nThe package may be installed from [CRAN](https://cran.r-project.org/package=loder) using the standard command\n\n```{r, eval=FALSE}\ninstall.packages(\"loder\")\n```\n\nAlternatively, the latest development version can be installed directly from GitHub using the `remotes` package, viz.\n\n```{r, eval=FALSE}\n## install.packages(\"remotes\")\nremotes::install_github(\"jonclayden/loder\")\n```\n\n## Reading and writing files\n\nThe `readPng` function is used to read PNG images. It returns an array of class `loder` with three dimensions representing rows, columns and channels. Greyscale images have one channel, grey/alpha images have two, red/green/blue (RGB) images have three, and red/green/blue/alpha images have four.\n\n```{r}\nlibrary(loder)\npath \u003c- system.file(\"extdata\", \"pngsuite\", \"basn6a08.png\", package=\"loder\")\nimage \u003c- readPng(path)\ndim(image)\n```\n\nMetadata including background colour, aspect ratio and pixel size or image resolution are available through attributes, if they are stored in the file.\n\n```{r}\npath \u003c- system.file(\"extdata\", \"pngsuite\", \"cdfn2c08.png\", package=\"loder\")\nattributes(readPng(path))\n```\n\nThe `display` function from the [`mmand` package](https://github.com/jonclayden/mmand) respects these attributes, and can be used to view the image on an R graphics device.\n\n```{r}\n## install.packages(\"mmand\")\nmmand::display(image)\n```\n\nMetadata alone may be read using the `inspectPng` function, which also gives information about the compression level achieved:\n\n```{r}\ninspectPng(path)\n```\n\nImage data can be written back to a file using the `writePng` function. The theoretical numerical range of the pixel intensities (i.e., the black and white points) can be set using the `range` attribute or an argument of the same name.\n\n```{r}\nwritePng(image, tempfile(), range=c(0,200))\n```\n\nThis will rescale the image intensities, and clip any values outside the specified range to the appropriate extreme.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonclayden%2Floder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonclayden%2Floder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonclayden%2Floder/lists"}