Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Jimp = require('jimp');
- const app = async () => {
- const img1 = await Jimp.read('./images/img1.png');
- const frame1 = await Jimp.read('./images/frame1.png');
- // ใส่กรอบ (merge) เข้าด้วยกัน
- img1
- .clone()
- .composite(frame1, Jimp.AUTO, Jimp.AUTO)
- .write('./images/jimp-composite.jpg');
- //ย่อขนาดรูปภาพ
- img1
- .clone()
- .resize(250, 250)
- .write('./images/jimp-resize.jpg');
- // เปลี่ยนสีภาพเป็นสีเทา
- img1
- .clone()
- .greyscale()
- .write('./images/jimp-greyscale.jpg');
- //หมุนรูป
- img1
- .clone()
- .rotate(45)
- .write('./images/jimp-rotate.jpg');
- // เบลอภาพ
- img1
- .clone()
- .blur(9)
- .write('./images/jimp-blur.jpg');
- // แทรกข้อความ
- const font = await Jimp.loadFont(Jimp.FONT_SANS_32_BLACK);
- img1
- .print(
- font,
- 190, // x
- 250, // y
- {
- text: 'Hello world!',
- alignmentX: Jimp.HORIZONTAL_ALIGN_CENTER,
- alignmentY: Jimp.VERTICAL_ALIGN_MIDDLE
- }, // message
- 250, //maxWidth
- 50 // maxHeight
- )
- .write('./images/jimp-print.jpg');
- };
- app();
Add Comment
Please, Sign In to add comment