Skip to content

Commit 0d2376f

Browse files
committed
Added project files from Working with RSS Feeds in Node.js, Working with DLLs in Node.js, Trying to recreate a program in a language I've never programmed in before, The Basics of YAML in Under 5 Minutes, How to Create PDFs in Node.js using PDF Kit, Extra-Bits Image Processing in Node.js with Jimp, How to using Google Forms data in a Node.js
1 parent 0b4210a commit 0d2376f

56 files changed

Lines changed: 1073 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
25.4 KB
Loading
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Import dependencies
2+
const Jimp = require("jimp");
3+
4+
(async function () {
5+
6+
// Read the image
7+
const image = await Jimp.read("images/shapes.png");
8+
9+
// Save the image
10+
image.writeAsync("images/edited-shapes.png");
11+
12+
})();
13+
14+
15+
// // Colour manipulation
16+
// image.color([
17+
// { apply: "hue", params: [100] }, // Change hue from -360 to 360
18+
// // { apply: 'lighten', params: [50] }, // Lighten the color a given amount, from 0 to 100
19+
// // { apply: 'xor', params: ['#06D'] }, // Treats the two colors as bitfields and applies an XOR operation to the red, green, and blue components
20+
21+
// ]);
22+
23+
// // Manual manipulation
24+
// image.scan(0, 0, image.bitmap.width, image.bitmap.height, function (x, y, idx) {
25+
26+
// // Get the colors
27+
// const red = this.bitmap.data[idx + 0];
28+
// const green = this.bitmap.data[idx + 1];
29+
// const blue = this.bitmap.data[idx + 2];
30+
// const alpha = this.bitmap.data[idx + 3];
31+
32+
// // If x is less than y
33+
// if (x < y)
34+
// // Set the red channel to 255
35+
// this.bitmap.data[idx + 0] = 255;
36+
37+
// });
38+
39+
// // Ghost effect - src, x, y, [{ mode, opacitySource, opacityDest }]
40+
// const image2 = image.clone();
41+
// image.composite(image2, 5, 0, {
42+
// mode: Jimp.BLEND_MULTIPLY,
43+
// opacitySource: 0.5,
44+
// opacityDest: 0.9
45+
// });
46+
47+
// // Emboss effect
48+
// image.convolute([[-2, -1, 0], [-1, 1, 1], [0, 1, 2]]);
49+
50+
// Jimp.rgbaToInt(r, g, b, a); // e.g. converts 255, 255, 255, 255 to 0xFFFFFFFF
51+
// Jimp.intToRGBA(hex); // e.g. converts 0xFFFFFFFF to {r: 255, g: 255, b: 255, a:255}
52+
// Jimp.cssColorToHex(cssColor); // e.g. converts #FF00FF to 0xFF00FFFF
53+
54+
// const image2 = new Jimp(256, 256, 0xff0000ff, (err, image) => {
55+
// // This image is 256 x 256, every pixel is set to 0xFF0000FF
56+
// });
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "javascript-image-manipulation",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "main.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "MIT",
12+
"dependencies": {
13+
"jimp": "^0.8.4"
14+
}
15+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Import dependencies
2+
const fs = require("fs");
3+
const PDFDocument = require("./pdfkit-tables");
4+
5+
// Load the patients
6+
const patients = require("./patients.json");
7+
8+
for (const patient of patients) {
9+
10+
// Create The PDF document
11+
const doc = new PDFDocument();
12+
13+
// Pipe the PDF into a patient file
14+
doc.pipe(fs.createWriteStream(`patients/${patient.name}.pdf`));
15+
16+
// Add the header - https://pspdfkit.com/blog/2019/generate-invoices-pdfkit-node/
17+
doc
18+
.image("logo.png", 50, 45, { width: 50 })
19+
.fillColor("#444444")
20+
.fontSize(20)
21+
.text("Patient Information.", 110, 57)
22+
.fontSize(10)
23+
.text("725 Fowler Avenue", 200, 65, { align: "right" })
24+
.text("Chamblee, GA 30341", 200, 80, { align: "right" })
25+
.moveDown();
26+
27+
// Create the table - https://www.andronio.me/2017/09/02/pdfkit-tables/
28+
const table = {
29+
headers: ["Name", "Address", "Phone", "Birthday", "Email Address", "Blood Type", "Height", "Weight"],
30+
rows: [
31+
[patient.name, patient.address, patient.phone, patient.birthday, patient.emailAddress, patient.bloodType, patient.height, patient.weight]
32+
]
33+
};
34+
35+
// Draw the table
36+
doc.moveDown().table(table, 10, 125, { width: 590 });
37+
38+
// Finalize the PDF and end the stream
39+
doc.end();
40+
41+
}
805 Bytes
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "pdf-kit-generator",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "app.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "MIT",
12+
"dependencies": {
13+
"pdfkit": "^0.11.0",
14+
"voilab-pdf-table": "^0.5.0"
15+
}
16+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[
2+
{
3+
"name": "Donovan Cottrell",
4+
"address": "2710 Joyce Street Fairhope, AL 36532",
5+
"phone": "251-928-0994",
6+
"birthday": "October 22, 1962",
7+
"emailAddress": "DonovanBCottrell@armyspy.com",
8+
"bloodType": "B+",
9+
"height": "178",
10+
"weight": "85.6"
11+
},
12+
{
13+
"name": "Herbert Denny",
14+
"address": "727 Fowler Avenue Chamblee, GA 30341",
15+
"phone": "770-220-4978",
16+
"birthday": "October 13, 1973",
17+
"emailAddress": "HerbertVDenny@dayrep.com",
18+
"bloodType": "O+",
19+
"height": "184",
20+
"weight": "78.5"
21+
},
22+
{
23+
"name": "Jasmine Lang",
24+
"address": "4650 Oakwood Avenue New York, NY 10007",
25+
"phone": "432-625-0002",
26+
"birthday": "October 15, 1980",
27+
"emailAddress": "JasmineSLang@teleworm.us",
28+
"bloodType": "A+",
29+
"height": "163",
30+
"weight": "60.9"
31+
},
32+
{
33+
"name": "Tyler Smith",
34+
"address": "4560 Hide A Way Road Orlando, FL 32811",
35+
"phone": "407-995-6876",
36+
"birthday": "March 21, 1940",
37+
"emailAddress": "TylerISmith@jourrapide.com",
38+
"bloodType": "O+",
39+
"height": "165",
40+
"weight": "99.4"
41+
},
42+
{
43+
"name": "Gordon White",
44+
"address": "4115 Pinnickinick Street Camas, WA 98607",
45+
"phone": "360-833-2114",
46+
"birthday": "March 11, 1954",
47+
"emailAddress": "GordonRWhite@dayrep.com",
48+
"bloodType": "O-",
49+
"height": "186",
50+
"weight": "84.1"
51+
},
52+
{
53+
"name": "Juanita Miller",
54+
"address": "1001 Sumner Street Riverside, CA 92507",
55+
"phone": "310-591-4624",
56+
"birthday": "January 15, 1967",
57+
"emailAddress": "JuanitaTMiller@jourrapide.com",
58+
"bloodType": "O+",
59+
"height": "172",
60+
"weight": "100.1"
61+
},
62+
{
63+
"name": "William Nelson",
64+
"address": "2599 South Street Midland, TX 79701",
65+
"phone": "432-625-0002",
66+
"birthday": "February 2, 1991",
67+
"emailAddress": "WilliamSNelson@armyspy.com",
68+
"bloodType": "O+",
69+
"height": "173",
70+
"weight": "97.8"
71+
}
72+
]
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)