canvasjavascript12139
Fake e-KTP Canvas Generator Engine
Generator kartu e-KTP Indonesia 1:1 presisi tinggi dengan kustomisasi NIK, nama lengkap, pasfoto proporsional, biodata lengkap, tanda tangan otomatis, dan auto-download aset resmi dari Vamx CDN.
Vamz Spectre19 Okt 2026367 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/fakektp" -o fakektp.js
# 2. Jalankan script
node fakektp.js
Dependencies npm yang Dibutuhkan:
npm install skia-canvasPanduan Penggunaan:
// Persyaratan: Node.js v18+ dan package skia-canvas
// npm install skia-canvas
// 1. Eksekusi langsung via CLI:
// Format ringkas (URL Foto + Nama + NIK):
node fakektp.js "https://picsum.photos/400/600" "BUDI SANTOSO" "3171010101900001"
// Format pipe-delimited lengkap (semua parameter biodata):
node fakektp.js "https://picsum.photos/400/600" "BUDI SANTOSO|DKI JAKARTA|JAKARTA PUSAT|3171010101900001|JAKARTA, 01-01-2000|LAKI-LAKI|O|JL. MERDEKA NO. 45|001/002|GAMBIR|GAMBIR|ISLAM|BELUM KAWIN|PELAJAR/MAHASISWA|WNI|SEUMUR HIDUP|01-01-2024"
// 2. Integrasi Modular di Node.js:
const { generateFakeKtp } = require('./fakektp');
const fs = require('fs');
const ktpBuffer = await generateFakeKtp(
{
nama: "BUDI SANTOSO",
prov: "DKI JAKARTA",
kota: "JAKARTA PUSAT",
nik: "3171010101900001",
ttl: "JAKARTA, 01-01-2000",
jk: "LAKI-LAKI",
goldar: "O",
alamat: "JL. MERDEKA NO. 45",
rtrw: "001/002",
keldesa: "GAMBIR",
kec: "GAMBIR",
agama: "ISLAM",
status: "BELUM KAWIN",
kerja: "PELAJAR/MAHASISWA",
wn: "WNI",
masa: "SEUMUR HIDUP",
terbuat: "01-01-2024"
},
"https://picsum.photos/400/600"
);
fs.writeFileSync('output_ktp.png', ktpBuffer);
// 3. Integrasi Bot WhatsApp (Baileys / VamxBotz):
case 'ktp':
case 'fakektp': {
const q = (text || '').trim();
const media = await m.download(); // atau URL foto
if (!media) return m.reply('❌ Kirim/reply pasfoto dengan caption: .fakektp BUDI SANTOSO');
await m.reply('⏳ Sedang memproses cetak kartu e-KTP...');
try {
const buffer = await generateFakeKtp({ nama: q || 'BUDI SANTOSO' }, media);
await conn.sendMessage(m.chat, { image: buffer, caption: '✅ Sukses generate e-KTP!\n\n⚡ *Powered by vamxapi.my.id*' }, { quoted: m });
} catch (err) {
await m.reply('❌ Gagal: ' + err.message);
}
break;
}fakektp.js(367 lines)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
/**
* Fake e-KTP Canvas Generator Engine
* Author: Vamz Spectre (VamxAPI)
* License: MIT
*
* Fitur:
* - 1:1 Pixel-accurate generator kartu e-KTP Indonesia (720 x 463).
* - Customization lengkap: NIK, Nama, Provinsi, Kota, TTL, Jenis Kelamin, Gol Darah,
* Alamat, RT/RW, Kelurahan/Desa, Kecamatan, Agama, Status Perkawinan, Pekerjaan,
* Kewarganegaraan, Masa Berlaku, dan Tanggal Diterbitkan.
* - Auto-download template KTP dan font resmi (ArrialKTP, OcrKTP, SignKTP) langsung dari Vamx CDN.
* - Pasfoto otomatis di-crop dan diposisikan proporsional pada bingkai foto KTP.
* - Tanda tangan digital otomatis disesuaikan dengan nama pemilik KTP.
*
* Cara Penggunaan CLI:
* 1. Download kode snippet:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/fakektp" -o fakektp.js
*
* 2. Jalankan langsung via terminal:
* node fakektp.js "https://picsum.photos/400/600" "BUDI SANTOSO" "3171010101900001"
* node fakektp.js "https://picsum.photos/400/600" "nama|provinsi|kota|nik|ttl|jk|goldar|alamat|rt/rw|kelurahan|kecamatan|agama|status|pekerjaan|wn|masa|terbuat"
*/
const fs = require("fs");
const path = require("path");
const https = require("https");
const { Canvas, loadImage, FontLibrary } = require("skia-canvas");
// Direktori cache aset (template & fonts)
const CACHE_DIR = path.join(process.cwd(), ".cache_ktp");
// CDN URL Aset
const ASSETS_CDN = {
template: "https://cdn.vamxapi.my.id/m/m_f1f482ad2035.png",
arrial: "https://cdn.vamxapi.my.id/m/m_887d795cbeb8.ttf",
ocr: "https://cdn.vamxapi.my.id/m/m_f5704a3d097f.ttf",
sign: "https://cdn.vamxapi.my.id/m/m_b4b0b5f87c73.ttf",
};
/**
* Helper untuk mengunduh buffer atau file dari URL
*/
function downloadFile(url, destPath) {
return new Promise((resolve, reject) => {
if (fs.existsSync(destPath) && fs.statSync(destPath).size > 0) {
return resolve(destPath);
}
const dir = path.dirname(destPath);
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
const file = fs.createWriteStream(destPath);
const get = (targetUrl) => {
https
.get(targetUrl, (res) => {
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
return get(res.headers.location);
}
if (res.statusCode !== 200) {
file.close();
fs.unlinkSync(destPath);
return reject(new Error(`Failed to download asset from ${targetUrl}: HTTP ${res.statusCode}`));
}
res.pipe(file);
file.on("finish", () => {
file.close(() => resolve(destPath));
});
})
.on("error", (err) => {
file.close();
if (fs.existsSync(destPath)) fs.unlinkSync(destPath);
reject(err);
});
};
get(url);
});
}
function fetchBuffer(url) {
return new Promise((resolve, reject) => {
const get = (targetUrl) => {
https
.get(targetUrl, (res) => {
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
return get(res.headers.location);
}
if (res.statusCode !== 200) {
return reject(new Error(`HTTP error ${res.statusCode} fetching ${targetUrl}`));
}
const chunks = [];
res.on("data", (c) => chunks.push(c));
res.on("end", () => resolve(Buffer.concat(chunks)));
})
.on("error", reject);
};
get(url);
});
}
let fontsLoaded = false;
async function ensureKtpAssets() {
if (!fs.existsSync(CACHE_DIR)) {
fs.mkdirSync(CACHE_DIR, { recursive: true });
}
const localAssetDir = path.join(process.cwd(), "assets/ktp");
const getPath = (filename, cdnUrl) => {
const local = path.join(localAssetDir, filename);
if (fs.existsSync(local) && fs.statSync(local).size > 0) return local;
return path.join(CACHE_DIR, filename);
};
const templatePath = getPath("template.png", ASSETS_CDN.template);
const arrialPath = getPath("arrial.ttf", ASSETS_CDN.arrial);
const ocrPath = getPath("ocr.ttf", ASSETS_CDN.ocr);
const signPath = getPath("sign.ttf", ASSETS_CDN.sign);
await Promise.all([
fs.existsSync(templatePath) ? Promise.resolve() : downloadFile(ASSETS_CDN.template, templatePath),
fs.existsSync(arrialPath) ? Promise.resolve() : downloadFile(ASSETS_CDN.arrial, arrialPath),
fs.existsSync(ocrPath) ? Promise.resolve() : downloadFile(ASSETS_CDN.ocr, ocrPath),
fs.existsSync(signPath) ? Promise.resolve() : downloadFile(ASSETS_CDN.sign, signPath),
]);
if (!fontsLoaded) {
try {
FontLibrary.use("ArrialKTP", arrialPath);
FontLibrary.use("OcrKTP", ocrPath);
FontLibrary.use("SignKTP", signPath);
fontsLoaded = true;
} catch {}
}
return { templatePath };
}
/**
* Parser string dengan separator "|"
*/
function parsePipeParams(text) {
const v = text.split("|").map((s) => s.trim());
return {
nama: v[0] || undefined,
prov: v[1] || undefined,
kota: v[2] || undefined,
nik: v[3] || undefined,
ttl: v[4] || undefined,
jk: v[5] || undefined,
goldar: v[6] || undefined,
alamat: v[7] || undefined,
rtrw: v[8] || undefined,
keldesa: v[9] || undefined,
kec: v[10] || undefined,
agama: v[11] || undefined,
status: v[12] || undefined,
kerja: v[13] || undefined,
wn: v[14] || undefined,
masa: v[15] || undefined,
terbuat: v[16] || undefined,
};
}
/**
* Main Fake e-KTP Generator
* @param {Object} options Data KTP
* @param {string|Buffer} photoInput URL gambar, Buffer, atau path file gambar
* @returns {Promise<Buffer>} PNG Buffer
*/
async function generateFakeKtp(options = {}, photoInput) {
const { templatePath } = await ensureKtpAssets();
// Load photo
let photoImg = null;
if (Buffer.isBuffer(photoInput)) {
photoImg = await loadImage(photoInput);
} else if (typeof photoInput === "string" && photoInput.startsWith("http")) {
const pBuf = await fetchBuffer(photoInput);
photoImg = await loadImage(pBuf);
} else if (typeof photoInput === "string" && fs.existsSync(photoInput)) {
photoImg = await loadImage(photoInput);
} else {
// Default dummy photo
const dummySvg = `<svg width="200" height="280" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="#3b82f6"/>
<circle cx="100" cy="90" r="50" fill="#e2e8f0"/>
<path d="M 30 240 Q 100 150 170 240 Z" fill="#e2e8f0"/>
</svg>`;
photoImg = await loadImage(Buffer.from(dummySvg));
}
const templateImg = await loadImage(templatePath);
const canvas = new Canvas(720, 463);
const ctx = canvas.getContext("2d");
// Gambar template background e-KTP
ctx.drawImage(templateImg, 0, 0, 720, 463);
// Penempatan & crop pasfoto
const PHOTO_X = 520,
PHOTO_Y = 80,
PHOTO_W = 200,
PHOTO_H = 280;
const frameRatio = PHOTO_W / PHOTO_H;
const imgRatio = photoImg.width / photoImg.height;
let sx, sy, sw, sh;
if (imgRatio > frameRatio) {
sh = photoImg.height;
sw = sh * frameRatio;
sx = (photoImg.width - sw) / 2;
sy = 0;
} else {
sw = photoImg.width;
sh = sw / frameRatio;
sx = 0;
sy = (photoImg.height - sh) / 2;
}
const scale = Math.min(PHOTO_W / sw, PHOTO_H / sh) * 0.78;
const dw = sw * scale;
const dh = sh * scale;
const dx = PHOTO_X + (PHOTO_W - dw) / 2 - 15;
const dy = PHOTO_Y + (PHOTO_H - dh) / 2;
ctx.drawImage(photoImg, sx, sy, sw, sh, dx, dy, dw, dh);
// Helper render teks
const L = (x, y, text, font, size) => {
ctx.font = `${size}px ${font}`;
ctx.textAlign = "left";
ctx.textBaseline = "top";
ctx.fillStyle = "#000000";
ctx.fillText(text || "", x, y);
};
const C = (x, y, text, font, size) => {
ctx.font = `${size}px ${font}`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = "#000000";
ctx.fillText(text || "", x, y);
};
const up = (s) => (s || "").toUpperCase();
const prov = options.prov || "DKI JAKARTA";
const kota = options.kota || "JAKARTA PUSAT";
const nik = options.nik || "3171010101900001";
const nama = options.nama || "BUDI SANTOSO";
const ttl = options.ttl || "JAKARTA, 01-01-2000";
const jk = options.jk || "LAKI-LAKI";
const goldar = options.goldar || "O";
const alamat = options.alamat || "JL. MERDEKA NO. 45";
const rtrw = options.rtrw || "001/002";
const keldesa = options.keldesa || "GAMBIR";
const kec = options.kec || "GAMBIR";
const agama = options.agama || "ISLAM";
const status = options.status || "BELUM KAWIN";
const kerja = options.kerja || "PELAJAR/MAHASISWA";
const wn = options.wn || "WNI";
const masa = options.masa || "SEUMUR HIDUP";
const terbuat = options.terbuat || "01-01-2024";
// Header Provinsi & Kota
C(380, 45, "PROVINSI " + up(prov), "ArrialKTP", 25);
C(380, 70, "KOTA " + up(kota), "ArrialKTP", 25);
// NIK dengan font OCR
ctx.font = "32px OcrKTP";
ctx.textAlign = "left";
ctx.textBaseline = "top";
ctx.fillStyle = "#000000";
ctx.fillText(nik, 170, 105);
// Data Biodata Pribadi
L(190, 145, up(nama), "ArrialKTP", 16);
L(190, 168, up(ttl), "ArrialKTP", 16);
L(190, 191, up(jk), "ArrialKTP", 16);
L(463, 190, up(goldar), "ArrialKTP", 16);
L(190, 212, up(alamat), "ArrialKTP", 16);
L(190, 234, up(rtrw), "ArrialKTP", 16);
L(190, 257, up(keldesa), "ArrialKTP", 16);
L(190, 279, up(kec), "ArrialKTP", 16);
L(190, 300, up(agama), "ArrialKTP", 16);
L(190, 323, up(status), "ArrialKTP", 16);
L(190, 346, up(kerja), "ArrialKTP", 16);
L(190, 369, up(wn), "ArrialKTP", 16);
L(190, 390, up(masa), "ArrialKTP", 16);
// Penerbitan Kota & Tanggal
L(553, 345, "KOTA " + up(kota), "ArrialKTP", 12);
L(570, 365, terbuat, "ArrialKTP", 12);
// Tanda Tangan
ctx.font = "40px SignKTP";
const firstName = nama.split(" ")[0] || nama;
ctx.fillText(firstName, 540, 395);
return await canvas.toBuffer("image/png");
}
module.exports = {
generateFakeKtp,
parsePipeParams,
};
// ==========================================
// CLI RUNNER (WAJIB KONSISTEN SESUAI RULE)
// ==========================================
if (require.main === module) {
const arg1 = process.argv[2] || "";
const arg2 = process.argv[3] || "";
const arg3 = process.argv[4] || "";
let photo = "https://picsum.photos/400/600";
let ktpData = {};
if (arg1.startsWith("http") || fs.existsSync(arg1)) {
photo = arg1;
if (arg2.includes("|")) {
ktpData = parsePipeParams(arg2);
} else if (arg2) {
ktpData.nama = arg2;
if (arg3) ktpData.nik = arg3;
}
} else if (arg1.includes("|")) {
ktpData = parsePipeParams(arg1);
if (arg2.startsWith("http") || fs.existsSync(arg2)) {
photo = arg2;
}
} else if (arg1) {
ktpData.nama = arg1;
if (arg2 && !arg2.startsWith("http")) ktpData.nik = arg2;
if (arg3 && (arg3.startsWith("http") || fs.existsSync(arg3))) photo = arg3;
}
const outputPath = path.join(process.cwd(), "fake_ktp.png");
generateFakeKtp(ktpData, photo)
.then((buf) => {
fs.writeFileSync(outputPath, buf);
const res = {
status: true,
creator: "Vamz Spectre",
result: {
file: outputPath,
nama: ktpData.nama || "BUDI SANTOSO",
nik: ktpData.nik || "3171010101900001",
size: `${(buf.length / 1024).toFixed(2)} KB`,
width: 720,
height: 463,
},
};
console.log(JSON.stringify(res, null, 2));
})
.catch((err) => {
const errRes = {
status: false,
creator: "Vamz Spectre",
message: err.message || "Gagal membuat gambar e-KTP.",
};
console.error(JSON.stringify(errRes, null, 2));
process.exit(1);
});
}