{"id":16048943,"url":"https://github.com/devongovett/pics","last_synced_at":"2025-03-17T16:31:38.144Z","repository":{"id":23515582,"uuid":"26881684","full_name":"devongovett/pics","owner":"devongovett","description":"Ties together streaming image encoders and decoders with a nice API","archived":false,"fork":false,"pushed_at":"2015-04-09T17:45:53.000Z","size":171,"stargazers_count":34,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T01:48:30.478Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devongovett.png","metadata":{"files":{"readme":"README.md","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":"2014-11-19T21:08:10.000Z","updated_at":"2024-01-06T12:04:17.000Z","dependencies_parsed_at":"2022-08-03T00:56:06.832Z","dependency_job_id":null,"html_url":"https://github.com/devongovett/pics","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fpics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fpics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fpics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fpics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devongovett","download_url":"https://codeload.github.com/devongovett/pics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243871860,"owners_count":20361378,"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":[],"created_at":"2024-10-09T00:11:31.902Z","updated_at":"2025-03-17T16:31:37.660Z","avatar_url":"https://github.com/devongovett.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pics\n\nTies together streaming image encoders and decoders with a nice API. It handles the following concerns:\n\n1. Probing images for their file format on the first chunk and proxying to the correct decoder.\n2. Finding and initializing image encoders based on mime type.\n3. Performing the necessary color conversions to encode an image, depending on the supported color spaces\n    of the image format. This includes quantization in the case of indexed image formats such as GIF.\n\n## Installation\n\n    npm install pics\n\n## Example\n\nThe following example registers some image codec plugins, resizes a PNG file, and converts it to a JPEG.\n\n```javascript\nvar pics = require('pics');\nvar resize = require('resizer-stream');\n\n// register some image codecs\npics.use(require('gif-stream'));\npics.use(require('jpg-stream'));\npics.use(require('png-stream'));\n\n// convert a PNG to a JPEG\nfs.createReadStream('in.png')\n  .pipe(pics.decode())\n  .pipe(resize({ width: 300, height: 300, fit: true }))\n  .pipe(pics.encode('image/jpeg'))\n  .pipe(fs.createWriteStream('out.jpg'));\n```\n\nNotice that nowhere is a PNG decoder explicitly created: it is created for us automatically\nby probing the first few bytes of a file. You could just as easily pipe a GIF to `pics.decode()`\nand convert it to a JPEG with no code modifications.\n\n## API\n\n### `pics.use(codec)`\n\nRegisters a image codec plugin. Should be an object with the following properties:\n\n* `Decoder` - the image decoder class. Should be a transform stream.\n* `Encoder` - the image encoder class. Should be a [pixel-stream](https://github.com/devongovett/pixel-stream).\n* `mime` - the mime type for this image format.\n\nYou can register only a decoder by including only a `Decoder` property. To register only an encoder,\ninclude the `Encoder` and `mime` properties.\n\nThe `Decoder` class should have a static `probe` method that accepts a buffer and returns a boolean\nto determine whether the image format can be handled by that decoder.\n\nThe `Encoder` class should have a `supportedColorSpaces` property, which is an array listing the \ncolor spaces supported by this image format. Color space conversion using the \n[color-transform](https://github.com/devongovett/color-transform) and [neuquant](https://github.com/devongovett/neuquant)\nmodules may be performed prior to data being passed to the encoder if the input color space\nis not one of the supported color spaces of this encoder.\n\nFor examples of image codecs, check out the following modules:\n\n* [png-stream](https://github.com/devongovett/png-stream)\n* [jpg-stream](https://github.com/devongovett/jpg-stream)\n* [gif-stream](https://github.com/devongovett/gif-stream)\n\n### `pics.decode(options)`\n\nReturns a decoder stream that probes the image to find an available decoder for the file.\nThe options are passed to the underlying decoder class.\n\n### `pics.encode(mime, options)`\n\nReturns an encoder stream for the given mime type. The options are passed to the underlying\nencoder class. Depending on the input to this stream, color space conversion or quantization\nmay be necessary, and will be performed before the data is sent to the underlying image encoder.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Fpics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevongovett%2Fpics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Fpics/lists"}