이미지 파일을 base64로 인코딩하는 방법은, 간단하게는 이미지 파일을 변환해주는 사이트를 이용하면 됩니다.
아래 몇가지 사이트들을 소개합니다.
https://base64.guru/converter/encode/image
Image to Base64 | Base64 Encode | Base64 Converter | Base64
Image to Base64 Convert image to Base64 online and use the result string as data URI, img src, CSS background-url, and others. Sometimes you have to send or output an image within a text document (for example, HTML, CSS, JSON, XML), but you cannot do this
base64.guru
https://api.products.aspose.app/ocr/ko/img-to-base64
Image to Base64 Encoder - Convert Image to Base64 Online
Free online Base64 Encoder that allows converting Image to Base64
products.aspose.app
aspose 에서 이미지 변환을 해보겠습니다.
변환 끝!
svg 파일을 변환한 경우 svg 태그내에서 다음과 같이 불러옵니다.
<svg width="950" height="360" xmlns="http://www.w3.org/2000/svg">
<image href="data:image/svg+xml;base64,[encoding 결과값]" />
</svg>
png 파일의 경우 svg 태그내에서 다음과 같이 불러옵니다.
<svg width="950" height="360" xmlns="http://www.w3.org/2000/svg">
<image href="data:image/png;base64,[encoding 결과값]" />
</svg>
다음 글에서는 python을 이용해서 이미지를 encoding하는 예제코드를 올리겠습니다.
2022.11.29 - [Python] - python image base64 encoding # python으로 이미지를 base64 인코딩하기
python image base64 encoding # python으로 이미지를 base64 인코딩하기
import base64 with open("django.svg", "rb") as f: encoded_string = base64.b64encode(f.read()) with 문을 통해서 svg 파일을 읽어서 base64로 인코딩한 예제입니다. 아래와 같이 해서 image태그에서 바로 불러올수 있도록 text
taltal-dev-note.tistory.com
'Image(svg, base64...)' 카테고리의 다른 글
svg: text-anchor (0) | 2022.12.13 |
---|---|
svg 에서 image 가져오기 (0) | 2022.11.29 |