Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

서버에서 SVG DNA 이미지 만들기 #381

Merged
merged 14 commits into from Jul 11, 2023

Conversation

sumi-0011
Copy link
Member

@sumi-0011 sumi-0011 commented Jul 11, 2023

🤔 해결하려는 문제가 무엇인가요?

DNA 이미지 다운로드를 위해, 먼저 이미지를 만들어야해요

🎉 변경 사항

  • 로컬 image와 이름을 조합해 만들고 싶은 이미지의 DNA dom element를 만들었어요
  • �satori option에 font를 설정해주어햐 해서 NotoSans 폰트 받아왔어요.
  • satori 라이브러리를 이용해서 서버에서 이미지를 만들고, 클라이언트로 만든 svg string을 보내주었어요
  • 클라이언트에서는 서버에서 받아온 svg string을 dom에 강제 삽입해서 보여줄 수 있도록 하였습니다.

🙏 여기는 꼭 봐주세요!

  • NotoSans 폰트는 저희가 사용하는 Pretendard는 아니지만, 크게 중요한 사항은 아닌것 같아 추후 적용하려고 생각중입니다.
  • 이후 svg를 png로 바꾸는 Resvg라이브러리 등을 이용해 svg를 이미지로 만들고, 다운로드 할 수 있는 기능을 추가하려고 합니다.
  • DNA Banner를 띄우는 부분과 image 경로가 겹쳐, 재활용 하면 좋을 것 같아요. DNA Banner의 DNA 이미지 상수를 상수 폴더에 옮기면 어떨까요?
  • build에서 에러나는 이유는 ssr을 사용해서 입니다! 무시해주세요

사용 방법

export async function getServerSideProps() {
  const notoSansScFont = await fetchFont();
  if (!notoSansScFont) return { props: {} };

  const imageOptions: SatoriOptions = {
    width: 329,
    height: 389,
    fonts: [
      {
        name: 'Noto Sans KR',
        data: notoSansScFont,
        weight: 700,
        style: 'normal',
      },
    ],
  };
 
  const ogImage = await createOGImage(<DNAImageView group={'A'} name={'변수미'} />, imageOptions);

  return {
    props: {
      ogImage,
    },
  };
}

🌄 스크린샷

image

📚 참고

@cloudflare-pages
Copy link

cloudflare-pages bot commented Jul 11, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 26a9480
Status:🚫  Build failed.

View logs

Base automatically changed from feature/dna/result-render to feature/result/base July 11, 2023 12:10
@sumi-0011 sumi-0011 merged commit b440ce7 into feature/result/base Jul 11, 2023
1 of 2 checks passed
@sumi-0011 sumi-0011 deleted the feat/image-download branch July 11, 2023 12:22
@sumi-0011 sumi-0011 linked an issue Jul 11, 2023 that may be closed by this pull request
hyesungoh added a commit that referenced this pull request Jul 14, 2023
* feat: 성향 데이터

* feat: 결과 dna 페이지 알고리즘 사용

* feat: dna 페이지 배너 사용 및 결과 렌더링

* feat: 외부자 dna 페이지 대응

* chore: satori 설치

* feat: image server에서 만들기

* feat: 강제 html 집어넣기

* feat: 일단 귀여운 이미지 배치

* refactor: 안쓰는거 정리

* feat: text 배치

* fix: 안쓰는 모듈 제거

* refactor: prod base url 추가 (될지는 모르겠음)

* feat: create image 정리

* fix: build error fix

---------

Co-authored-by: hyesungoh <haesungoh414@gmail.com>
sumi-0011 added a commit that referenced this pull request Jul 20, 2023
* result DNA 페이지 작업 중 (#357)

Co-authored-by: 권오연 <ohyeon.kwon@flask.global>

* feat: 나와 잘맞는 DNA 배너 (#366)

* feat: 나와 잘맞는 DNA 배너

* Update src/components/banner/DnaBanner.tsx

Co-authored-by: hyesung oh <haesungoh414@gmail.com>

---------

Co-authored-by: oyeon-kwon <ohyeon.kwon@flask.global>
Co-authored-by: hyesung oh <haesungoh414@gmail.com>

* 결과 로직 알고리즘 짜기  (#371)

* feat: useIsMounted 작성 (#71)

* feat: 결과 로직 짜기 - 많이 선택된 성향 찾기

* feat: 결과 로직 카운트 수정

* feat: 결과 그룹 도출

* feat: 결과 그룹 도출 로직 연결

---------

Co-authored-by: Sangjo LEE <cent7425@gmail.com>

* DNA 페이지 API 관련 로직 (#365)

* feat: use get user info by survey id

* feat: use get tendency와 로딩 핸들링

* feat: dna 페이지 접근 유저 확인

* 결과 페이지 상단 DNA 배너 (#370)

* feat: 결과 페이지 dna 배너 피드백 없을 때

* feat: 결과 페이지 상단 배너

* feat: 북마크 아이콘 피드백 컴포넌트에 추가 (#369)

* feat: useIsMounted 작성 (#71)

* feat: 북마크 아이콘 피드백 컴포넌트에 추가

* fix: isView Props 삭제

---------

Co-authored-by: Sangjo LEE <cent7425@gmail.com>
Co-authored-by: oyeon-kwon <ohyeon.kwon@flask.global>

* dna 페이지 퍼블리싱 및 로직 추가 (#372)

* feat: 성향 데이터

* feat: 결과 dna 페이지 알고리즘 사용

* feat: dna 페이지 배너 사용 및 결과 렌더링

* feat: 외부자 dna 페이지 대응

* DNA 결과 로직 테스트 코드 작성 (#373)

* feat: 성향 데이터

* feat: 결과 dna 페이지 알고리즘 사용

* feat: dna 페이지 배너 사용 및 결과 렌더링

* feat: 외부자 dna 페이지 대응

* fix: 타입 선언 충돌 수정

* test: 결과 로직 테스트 코드 작성

* fix: console 제거

* fix: build error type fix

* refactor: 주석 제거

---------

Co-authored-by: hyesungoh <haesungoh414@gmail.com>

* 서버에서 SVG DNA 이미지 만들기 (#381)

* feat: 성향 데이터

* feat: 결과 dna 페이지 알고리즘 사용

* feat: dna 페이지 배너 사용 및 결과 렌더링

* feat: 외부자 dna 페이지 대응

* chore: satori 설치

* feat: image server에서 만들기

* feat: 강제 html 집어넣기

* feat: 일단 귀여운 이미지 배치

* refactor: 안쓰는거 정리

* feat: text 배치

* fix: 안쓰는 모듈 제거

* refactor: prod base url 추가 (될지는 모르겠음)

* feat: create image 정리

* fix: build error fix

---------

Co-authored-by: hyesungoh <haesungoh414@gmail.com>

* satori로 만든 svg를 png로 변환 (#382)

* feat: 성향 데이터

* feat: 결과 dna 페이지 알고리즘 사용

* feat: dna 페이지 배너 사용 및 결과 렌더링

* feat: 외부자 dna 페이지 대응

* chore: satori 설치

* feat: image server에서 만들기

* feat: 강제 html 집어넣기

* feat: 일단 귀여운 이미지 배치

* refactor: 안쓰는거 정리

* feat: text 배치

* fix: 안쓰는 모듈 제거

* refactor: prod base url 추가 (될지는 모르겠음)

* feat: create image 정리

* fix: build error fix

* chore: resvg 라이브러리 설치

* feat: resvg로 png base encoding

---------

Co-authored-by: hyesungoh <haesungoh414@gmail.com>

* refactor: 페이지 경로 변경

* feat: 이미지 다운로드 기능 추가

* feat: 모바일 감지해서 토스트 메시지 띄우기

* feat: mock data 추가

* feat: 폰트 적용

* feat: 화질 깨지는 문제 수정

* feat: 포지션  집어넣기

* feat: 배너 완성

* fix: minor style fix

* feat: 이미지 변경

* feat: 포지션 추가

* refactor: 이미지 로직 분리

* feat: pc 다운

* feat: 다운로드 추가

* fix: 충돌 에러 수정

* feat: image 경로 변경

* refactor: 사용하지 않는 파일 삭제

---------

Co-authored-by: 권오연 <61301574+oyeon-kwon@users.noreply.github.com>
Co-authored-by: 권오연 <ohyeon.kwon@flask.global>
Co-authored-by: hyesung oh <haesungoh414@gmail.com>
Co-authored-by: Sangjo LEE <cent7425@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

서버에서 svg 이미지 만들기
3 participants