{"id":17049091,"url":"https://github.com/toddself/image-validator-stream","last_synced_at":"2025-07-17T02:43:11.518Z","repository":{"id":15910967,"uuid":"18652618","full_name":"toddself/image-validator-stream","owner":"toddself","description":null,"archived":false,"fork":false,"pushed_at":"2018-08-14T20:18:10.000Z","size":42,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T16:14:08.563Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toddself.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-10T21:33:12.000Z","updated_at":"2019-02-28T15:20:16.000Z","dependencies_parsed_at":"2022-09-26T20:41:26.899Z","dependency_job_id":null,"html_url":"https://github.com/toddself/image-validator-stream","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/toddself/image-validator-stream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddself%2Fimage-validator-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddself%2Fimage-validator-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddself%2Fimage-validator-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddself%2Fimage-validator-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toddself","download_url":"https://codeload.github.com/toddself/image-validator-stream/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddself%2Fimage-validator-stream/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265560993,"owners_count":23788290,"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-14T09:53:50.201Z","updated_at":"2025-07-17T02:43:11.502Z","avatar_url":"https://github.com/toddself.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# image-validator-stream\n\n[![build status](https://secure.travis-ci.org/toddself/image-validator-stream.png)](http://travis-ci.org/toddself/image-validator-stream)\n\nProvides a transform stream to inspect the incoming header of an image to detemine if it's a valid image format.\n\nCurrently supports:\n* jpg\n* png\n* gif (87a/89a)\n\n## Example\n\n```js\nconst fs = require('fs')\nconst path = require('path')\nconst ImageValidatorStream = require('image-validator-stream')\n\nfunction validateThenCopy (src, dst, cb) {\n  const ext = path.extname(src)\n  const ivs = new ImageValidatorStream({ext: ext})\n  ivs.on('error', function (err) {\n    err.file = dst\n    cb(err)\n  })\n\n  const out = fs.createWriteStream(dst).on('end', function () {\n    cb()\n  })\n\n  fs.createReadStream(src).pipe(ivs).pipe(out)\n}\n\nvalidateThenCopy(path.join(__dirname, 'junk.jpg'), 'awesome.jpg', function (err) {\n  if (err) {\n    fs.unlink(err.file, function (err) {\n      if (err) {\n        console.log(err)\n      }\n      console.log('oh noes!')\n    })\n  } else {\n    console.log('awyiss')\n  }\n})\n```\n\n[full example](example/abort-on-bad.js)\n\n## Installation\n\n`npm install image-validator-stream`\n\n## License\nCopyright © 2014 Todd Kennedy, Licensed under the [MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoddself%2Fimage-validator-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoddself%2Fimage-validator-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoddself%2Fimage-validator-stream/lists"}