Node.js로 워터마킹 기능을 구현하는 방법
Node.js로 워터마킹 기능을 구현하는 방법중 두가지를 설명드리겠습니다.
1. 이미지에 텍스트 워터마크 추가하기:
- `jimp` 라이브러리를 사용하여 이미지를 로드합니다.
- `jimp`의 `print` 메서드를 사용하여 이미지에 텍스트 워터마크를 추가합니다.
- 수정된 이미지를 저장하거나 출력합니다.
[code]
const Jimp = require('jimp');
// 이미지 로드
Jimp.read('original.jpg')
.then(image => {
// 텍스트 워터마크 추가
image.print(
Jimp.loadFont(Jimp.FONT_SANS_16_BLACK),
10, // x 좌표
10, // y 좌표
'Watermark Text' // 텍스트 내용
);
// 수정된 이미지 저장
image.write('watermarked.jpg');
})
.catch(error => {
console.error(error);
});
[/code]
2. 이미지에 로고 워터마크 추가하기:
- `sharp` 라이브러리를 사용하여 이미지를 로드합니다.
- `sharp`의 `composite` 메서드를 사용하여 이미지에 로고 워터마크를 추가합니다.
- 수정된 이미지를 저장하거나 출력합니다.
[code]
const sharp = require('sharp');
// 이미지 로드
sharp('original.jpg')
.composite([
{
input: 'logo.png', // 로고 이미지 경로
gravity: 'southeast', // 로고 위치
opacity: 0.8 // 로고 투명도
}
])
.toFile('watermarked.jpg')
.then(() => {
console.log('Watermark added successfully');
})
.catch(error => {
console.error(error);
});
[/code]
게시글 목록
| 번호 | 제목 |
|---|---|
| 16019 | |
| 16015 | |
| 16014 |
jQuery
jQuery.holdReady( hold )
|
| 16013 |
jQuery
jQuery.hasData( element )
1
|
| 16011 | |
| 16010 | |
| 16009 |
jQuery
jQuery.globalEval (code)
|
| 16008 | |
| 16004 | |
| 16003 |
jQuery
jQuery.getJSON()
|
| 16002 |
jQuery
jQuery.get()
|
| 16001 |
jQuery
jQuery.fx.off
|
| 15993 |
jQuery
jQuery.fx.interval
|
| 15992 |
jQuery
jQuery.fn.extend ()
2
|
| 15991 |
jQuery
jQuery.extend()
|
| 15988 |
jQuery
jQuery.escapeSelector ()
|
| 15987 |
jQuery
jQuery.error (message)
|
| 15986 |
jQuery
jQuery.each()
|
| 15985 |
jQuery
jquery 가상 선택자 확장하기.
|
| 15981 |
jQuery
jQuery.dequeue()
|
| 15980 |
jQuery
jQuery.Deferred()
|
| 15979 |
jQuery
jQuery.data()
|
| 15978 |
jQuery
jQuery.cssNumber
|
| 15977 |
jQuery
jQuery.cssHooks
|
| 15976 | |
| 15975 |
jQuery
jQuery.Callbacks ()
|
| 15974 |
jQuery
jQuery.ajaxTransport ()
|
| 15973 |
jQuery
jQuery.ajaxPrefilter()
1
|
| 15971 |
jQuery
jQuery.ajaxPrefilter()
|
| 15970 |
jQuery
jQuery.ajax()
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기