https://github.com/lee-seokmin/PhotoFrame
๐ธ A website that frames the metadata of a photo.
https://github.com/lee-seokmin/PhotoFrame
fastapi nextjs photography photoshop-crack python react
Last synced: 9 months ago
JSON representation
๐ธ A website that frames the metadata of a photo.
- Host: GitHub
- URL: https://github.com/lee-seokmin/PhotoFrame
- Owner: seokmin12
- License: mit
- Created: 2024-03-18T09:49:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-20T00:06:27.000Z (over 1 year ago)
- Last Synced: 2024-12-20T01:18:46.469Z (over 1 year ago)
- Topics: fastapi, nextjs, photography, photoshop-crack, python, react
- Language: Python
- Homepage: https://photoframe.kro.kr
- Size: 248 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
์ด ์น์ฌ์ดํธ๋ [Next.js](https://nextjs.org/)๋ฅผ ์ฌ์ฉํด ๋ง๋ค์ด์ก์ต๋๋ค.
[](https://app.netlify.com/sites/photoframeo/deploys)
## ์ด ์ฌ์ดํธ๋ฅผ ๋ง๋ ๋ชฉ์
์ธ์คํ๊ทธ๋จ์ ์์ ์ด ์ฐ์ ์ฌ์ง์ ์ฌ๋ฆด ๋, ์๋ณธ ๊ทธ๋๋ก ์ฌ๋ฆฌ๋ ๊ฒ ๋ณด๋ค ๊ทธ ์ฌ์ง์ [EXIF](https://namu.wiki/w/EXIF)(์
ํฐ ์คํผ๋, ์กฐ๋ฆฌ๊ฐ ๊ฐ, ISO๋ฑ)๋ฅผ ์
๋ ฅํด ๋์์ผ๋ก์จ ์ฌ๋๋ค์ด ์ ๋ณด๋ฅผ ์ ์ ์๊ฒ ๋๋ ํ๋ ์์ ๋ง๋๋ ๊ฒ์ด ์ ํ์ด๋ค.
๊ทธ๋ฌ๋, ์ด ์์
์ ํฌํ ์ต์ผ๋ก ์ผ์ผ์ด ์
๋ ฅํด์ผ ํ๋ค๋ ๊ฒ์ด ๋จ์ ์ด์๋ค. ๊ทธ๋์ ์ด ์์
์ Python ์ฝ๋๋ก ์๋ํํ์ฌ ์ฌ์ฉ์์๊ฒ ์ ๊ณตํ๋ฉด ๋์ฑ ํธ๋ฆฌํ๊ฒ ๋ค๋ ์๊ฐ์ ํ์ฌ ๋ง๋ค์๋ค.
## Getting Started
๋จผ์ , ๋ก์ปฌ ์๋ฒ์์ ๋ค์์ ์ปค๋งจ๋๋ฅผ ์คํํ๋ค:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
๋ก์ปฌ ์ฃผ์ [http://localhost:3000](http://localhost:3000)์ ์ ์ํ์ฌ ๊ฒฐ๊ณผ๋ฌผ์ ํ์ธํ๋ค.
## ์ฃผ์ ์ฝ๋
```typescript
function setupCanvas(imgWidth: number, imgHeight: number, padding: number, metadataHeight: number): {
canvas: HTMLCanvasElement;
ctx: CanvasRenderingContext2D;
canvasWidth: number;
canvasHeight: number;
scaledImgWidth: number;
scaledImgHeight: number;
imgX: number;
imgY: number;
} {
// ๊ณ ์ ์บ๋ฒ์ค ํฌ๊ธฐ
const canvasWidth = 1080 * 2;
const canvasHeight = 1350 * 2;
const canvas = document.createElement('canvas');
canvas.width = canvasWidth;
canvas.height = canvasHeight;
const ctx = canvas.getContext('2d');
if (!ctx) throw new Error('Could not get canvas context');
// ๋ฐฐ๊ฒฝ ์ค์
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, canvasWidth, canvasHeight);
// ์ด๋ฏธ์ง ํฌ๊ธฐ ๊ณ์ฐ (์บ๋ฒ์ค์ ๋ง๊ฒ ์ค์ผ์ผ๋ง)
const imageArea = canvasHeight - (padding * 5) - metadataHeight;
const scale = Math.min(
(canvasWidth - padding * 2) / imgWidth,
imageArea / imgHeight
);
const scaledImgWidth = imgWidth * scale;
const scaledImgHeight = imgHeight * scale;
// ์ด๋ฏธ์ง ์์น ๊ณ์ฐ (๊ฐ๋ก ๋ฐ ์ธ๋ก ์ค์ ์ ๋ ฌ)
const imgX = (canvasWidth - scaledImgWidth) / 2;
// ๊ฐ๋ก ์ด๋ฏธ์ง(landscape)์ธ ๊ฒฝ์ฐ ์์ง ์ค์ ์ ๋ ฌ
let imgY = padding * 2;
if (imgWidth > imgHeight) {
// ๊ฐ๋ก ์ด๋ฏธ์ง๋ฉด ์์ง์ผ๋ก๋ ์ค์์ ๋ฐฐ์น
imgY = (canvasHeight - metadataHeight - scaledImgHeight) / 2;
}
return {
canvas,
ctx,
canvasWidth,
canvasHeight,
scaledImgWidth,
scaledImgHeight,
imgX,
imgY
};
}
```
## ๋ก์ง
```mermaid
flowchart LR
A(ํ๋ก ํธ์๋)
B[์ฌ์ง์ ๋ฉํ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ]
C[canvas๋ฅผ ์ด์ฉํ์ฌ
ํฐ ๋ฐฐ๊ฒฝ ๋ง๋ค๊ธฐ]
D[์๋ณธ ์ฌ์ง์ ์ผ์ ํ
๋น์จ์ ๋ง์ถฐ resizeํ๊ธฐ]
E[ํฐ ๋ฐฐ๊ฒฝ์ resize๋ ์ฌ์ง๊ณผ
๋ฉํ ๋ฐ์ดํฐ ์
๋ ฅํ๊ธฐ]
A ---> |์ฌ์ง ์ ์ก| B
subgraph ๋ฐฑ์๋
B --- C --- D --- E
end
E ---> |์์ฑ๋ ์ด๋ฏธ์ง๋ฅผ base64๋ก
์ธ์ฝ๋ฉํ์ฌ returnํ๊ธฐ| A
```