{"id":15011279,"url":"https://github.com/dchan3/yubigen","last_synced_at":"2025-04-09T19:04:51.665Z","repository":{"id":57404693,"uuid":"125961169","full_name":"dchan3/yubigen","owner":"dchan3","description":"Node Thumbnail generation without limits","archived":false,"fork":false,"pushed_at":"2018-06-09T14:39:27.000Z","size":588,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T21:01:40.599Z","etag":null,"topics":["graphicsmagick","image-manipulation","image-processing","imagemagick","node","node-js","npm","thumbnail","thumbnail-generator","thumbnail-images"],"latest_commit_sha":null,"homepage":"https://dchan3.github.io/yubigen","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/dchan3.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","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":"2018-03-20T04:34:23.000Z","updated_at":"2021-10-08T13:05:34.000Z","dependencies_parsed_at":"2022-09-26T17:01:25.321Z","dependency_job_id":null,"html_url":"https://github.com/dchan3/yubigen","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dchan3%2Fyubigen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dchan3%2Fyubigen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dchan3%2Fyubigen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dchan3%2Fyubigen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dchan3","download_url":"https://codeload.github.com/dchan3/yubigen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094985,"owners_count":21046770,"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":["graphicsmagick","image-manipulation","image-processing","imagemagick","node","node-js","npm","thumbnail","thumbnail-generator","thumbnail-images"],"created_at":"2024-09-24T19:40:12.513Z","updated_at":"2025-04-09T19:04:51.640Z","avatar_url":"https://github.com/dchan3.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YUBIGEN\nNode Thumbnail generation without limits\n\n[![NPM version](https://img.shields.io/npm/v/yubigen.svg?style=flat)](https://www.npmjs.com/package/yubigen)\n![npm](https://img.shields.io/npm/dt/yubigen.svg)\n[![Build Status](https://travis-ci.org/dchan3/yubigen.svg?branch=master)](https://travis-ci.org/dchan3/yubigen)\n\n## Prerequisites\nPlease refer to the operating system-specific instructions on installing the following before using YUBIGEN.\n- both `graphicsmagick` and `imagemagick`\n- `npm` and `node`\n- `gm` package for `npm`. If `npm` has been installed, simply run `npm install gm`.\n- `aws-sdk` package for `npm`, installed at the application level, but only if putting objects to AWS S3\n\n## Description of Implementation\nYUBIGEN makes use of the [`resize`](http://aheckmann.github.io/gm/docs.html#resize) and [`crop`](http://aheckmann.github.io/gm/docs.html#crop) functions found in `gm` to resize and crop images according to specified parameters, respectively passed into the `resizeParams` and `cropParams` fields in the second parameter object in arrays. The third parameter is passed a callback which handles the resulting buffer in the specified manner.\n\nYUBIGEN also has a way to predict the format of the input, as well as a function\nto output to a specified file and to upload to an AWS S3 Bucket.\nFormat-specific functions have been made available as well.\n\n## Methods\n### `yubigen.fromUrl(url, paramObj, callback)`\nManipulates image given URL\n### `yubigen.fromFile(path, paramObj, callback)`\nManipulates image from file given path\n### `yubigen.fromBuffer(buffer, paramObj, callback)`\nManipulates image from a buffer given path\n### `yubigen.predict(input, paramObj, callback)`\nPredicts format (string or buffer) of the given input\n### `yubigen.outToFile(outFile, input, paramObj, callback)`\nOutputs to file as specified from input format prediction\n### `yubigen.s3Put(config, bucket, path, input, paramObj, callback)`\nWith specified credentials (default if `config` is `null`), outputs to specified S3 Bucket as specified from\ninput format prediction (requires external install of `aws-sdk` package)\n\n## Parameter Object Keys\n- `resizeParams`: resize parameters as specified by [`resize`](http://aheckmann.github.io/gm/docs.html#resize) in a one-dimensional array\n- `cropParams`: crop parameters as specified by [`crop`](http://aheckmann.github.io/gm/docs.html#crop) in a one-dimensional array\n- `textParams`: an array of text parameter objects. Text parameter object schema is as follows.\n  - `fontName`: name of font to use, passed into [`font`](http://aheckmann.github.io/gm/docs.html#font)\n  - `fontSize`: text font size, passed into [`fontSize`](http://aheckmann.github.io/gm/docs.html#fontSize)\n  - `color`: text fill color, passed into [`fill`](http://aheckmann.github.io/gm/docs.html#fill)\n  - `drawParams`: text draw parameters as specified by [`drawText`](http://aheckmann.github.io/gm/docs.html#drawText) in a one-dimensional array\n- `format`: file format\n- `imageMagick`: ImageMagick enabled if true\n\n## Callback\n- `result`: resulting buffer\n- `err`: error if any\n\n## Usage\n```js\nconst yubigen = require('yubigen'), fs = require('fs'),\n  AWS = require('aws-sdk'); // for demonstration purposes\nvar params = {\n  resizeParams: [100], // resize parameters as specified by gm resize\n  cropParams: [50,50,20,0], // crop parameters as specified by gm crop\n  format: \"JPEG\", // file format\n  imageMagick: false, // ImageMagick not enabled\n  textParams: [ // Text parameter object #1:\n    {\n      color: \"#5940de\",\n      fontSize: \"24pt\",\n      drawParams: [0, 0, \"CENSORED\", \"Center\"] // text draw parameters as specified by gm drawText\n    },\n    {\n      color: \"#000000\",\n      fontSize: \"12pt\",\n      drawParams: [0, 0, \"VOID\", \"Center\"]\n    }\n  ]\n}, writeFile = (result, err) =\u003e { // write to file callback\n  fs.writeFile(\"bruh.png\", result, (error) =\u003e {\n    if (error) console.log(error);\n  });\n}, s3_upload = (result, err) =\u003e {\n  // callback to upload to S3 Bucket, for demonstration purposes\n  var args = {\n    Bucket: BUCKET_NAME\n    Key: KEY_NAME,\n    Body: result\n  }, var s3 = new AWS.S3();\n  s3.putObject(args, function(error) {\n    if (error) console.log(error);\n  });\n};\n\n// From URL\nyubigen.fromUrl(\"https://ktuh.org/img/ktuh-fm-logo.png\", params, writeFile);\n\n// From file\nyubigen.fromFile(\"bruh.png\", params, s3_upload);\n\n// From buffer\nfs.readFile('alpha.jpg', function(error, data) {\n  yubigen.fromBuffer(data, params, (result, err) =\u003e {\n    fs.writeFile(\"gamma.png\", result, (error) =\u003e {\n      if (error) console.log(error);\n    });\n  });\n});\n\n// Export from URL to file\nyubigen.outToFile('logo.png', \"https://ktuh.org/img/ktuh-fm-logo.png\", params,\n(result, err) =\u003e {\n  if (error) console.log(error);\n  else console.log(result);\n});\n\n// Put Object to S3 bucket `my-bucket` with default AWS credentials\nfs.readFile('test/images/alpha.jpg', function(error, data) {\n  yubigen.s3Put(null, \"my-bucket\", \"alpha.png\", data, params,\n  (result, err) =\u003e {\n    if (error) console.log(error);\n    else if (result) console.log(\"Upload success!\");\n  });\n});\n```\n\n## Author\n- Derek Chan\n\n## Contributors\n- Pull requests and issues are welcome! Feature requests will be considered on\n  a case-by-case basis.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdchan3%2Fyubigen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdchan3%2Fyubigen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdchan3%2Fyubigen/lists"}