diff --git a/CLAUDE.md b/CLAUDE.md
index a3dac32..b8a902c 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -93,3 +93,4 @@ npm run build # build de prod
- **Textes de l'app (anti-slop, 1er déc. 2026)** : tutoiement partout (aussi en russe), pas de tiret long « — » pour relier deux idées (deux-points ou point), pas d'émoji comme icône (lucide-react), pas de promesse que l'app ne tient pas. Skills : `humanizer` (textes), `deslop` (code), `hallmark` sloplint (design), voir `.claude/skills/README.md`. Les flèches « → » d'accent après un libellé sont un choix de design voulu.
- **Installation iPhone (2 déc. 2026)** : guide « Installer Bobinoo » (`components/InstallGuide.tsx`) : carte masquable sur l'accueil (`azuucine:install-hint`) et section des Réglages, sur les appareils Apple seulement (`lib/install.ts`, `installPlatform()`) : iPhone/iPad (Partager → Sur l'écran d'accueil), Mac + Safari 17+ (Fichier → Ajouter au Dock), Mac + Chrome/Edge (icône d'installation de la barre d'adresse) ; rien sur Firefox, Windows, Android, ni si l'app est déjà installée. Pas de connexion Apple (elle exige un compte Apple Developer payant) : à ajouter seulement si l'app passe sur l'App Store.
- **Langue automatique (2 déc. 2026)** : `detectLang()` (`src/i18n/index.ts`) suit la langue du téléphone si Bobinoo la parle (parmi plusieurs, celle du pays du fuseau horaire), sinon l'anglais. Le pays ne s'impose plus (un anglophone à Paris lit en anglais). Le pays sert toujours aux plateformes de streaming et aux sorties (`detectRegion`). Un choix fait à la main dans Réglages → Langue reste prioritaire.
+- **Recadrage photo de profil / bannière (2 déc. 2026)** : `components/social/ImageCropper.tsx` (glisser, pincer, molette, curseur, flèches du clavier ; l'image couvre toujours le cadre), sortie JPEG sans métadonnées via `cropToJpeg` (`lib/image.ts`) : 400 × 400 pour la photo, 1500 × 500 pour la bannière. Ouvert par `EditProfile` après le choix d'une photo.
diff --git a/src/components/social/EditProfile.tsx b/src/components/social/EditProfile.tsx
index 423e74b..74be85d 100644
--- a/src/components/social/EditProfile.tsx
+++ b/src/components/social/EditProfile.tsx
@@ -2,9 +2,10 @@ import { Camera, ImagePlus, Loader2, Lock, Trash2 } from 'lucide-react'
import { useEffect, useRef, useState } from 'react'
import { t } from '../../i18n'
import { deleteProfileImage, updateProfile, uploadProfileImage, USERNAME_RE, type ProfilePatch } from '../../lib/cloud/social'
-import { cropImageToJpeg } from '../../lib/image'
+import { checkImageFile } from '../../lib/image'
import { cx } from '../../lib/utils'
import Avatar from './Avatar'
+import ImageCropper from './ImageCropper'
import Sheet from './Sheet'
import { useSocial } from './SocialProvider'
@@ -40,18 +41,26 @@ export default function EditProfile({ onClose }: { onClose: () => void }) {
const usernameOk = USERNAME_RE.test(cleanUsername)
const nameOk = displayName.trim().length >= 1 && displayName.trim().length <= 40
- const pick = async (kind: 'avatar' | 'banner', file?: File) => {
+ // Photo choisie : d'abord l'écran de recadrage, puis l'aperçu
+ const [cropping, setCropping] = useState<{ kind: 'avatar' | 'banner'; file: File }>()
+ const pick = (kind: 'avatar' | 'banner', input: HTMLInputElement) => {
+ const file = input.files?.[0]
+ input.value = '' // la même photo pourra être rechoisie (pour la recadrer autrement)
if (!file) return
setError(undefined)
try {
- const blob = kind === 'avatar' ? await cropImageToJpeg(file, 400, 400) : await cropImageToJpeg(file, 1500, 500, 0.84)
- const preview = URL.createObjectURL(blob)
- if (kind === 'avatar') setAvatar({ blob, preview })
- else setBanner({ blob, preview })
+ checkImageFile(file)
+ setCropping({ kind, file })
} catch (e) {
setError((e as Error).message)
}
}
+ const cropped = (blob: Blob) => {
+ const preview = URL.createObjectURL(blob)
+ if (cropping?.kind === 'avatar') setAvatar({ blob, preview })
+ else setBanner({ blob, preview })
+ setCropping(undefined)
+ }
const save = async () => {
if (!me || !usernameOk || !nameOk) return
@@ -114,7 +123,7 @@ export default function EditProfile({ onClose }: { onClose: () => void }) {
- pick('banner', e.target.files?.[0])} />
+ pick('banner', e.currentTarget)} />
@@ -124,7 +133,7 @@ export default function EditProfile({ onClose }: { onClose: () => void }) {
-
pick('avatar', e.target.files?.[0])} />
+
pick('avatar', e.currentTarget)} />
{avatar.preview && !avatar.removed && (
setAvatar({ removed: true })} className="flex items-center gap-1">
@@ -185,6 +194,7 @@ export default function EditProfile({ onClose }: { onClose: () => void }) {
{t('social.publicHint')}
+ {cropping &&
setCropping(undefined)} onDone={cropped} />}
)
}
diff --git a/src/components/social/ImageCropper.tsx b/src/components/social/ImageCropper.tsx
new file mode 100644
index 0000000..27e0642
--- /dev/null
+++ b/src/components/social/ImageCropper.tsx
@@ -0,0 +1,240 @@
+import { Loader2 } from 'lucide-react'
+import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent, type PointerEvent } from 'react'
+import { t } from '../../i18n'
+import { cropToJpeg, loadImage } from '../../lib/image'
+import { cx } from '../../lib/utils'
+import Sheet from './Sheet'
+
+/** Format de sortie : photo ronde (400 × 400) ou bannière 3:1 (1500 × 500), comme à l'affichage. */
+const FORMATS = {
+ avatar: { width: 400, height: 400, quality: 0.86, title: 'crop.avatarTitle' },
+ banner: { width: 1500, height: 500, quality: 0.84, title: 'crop.bannerTitle' },
+} as const
+
+const MAX_ZOOM = 5
+
+/** Cadrage : zoom (1 = l'image couvre juste le cadre) et point de l'image au centre du cadre (en pixels de l'image). */
+interface View {
+ z: number
+ cx: number
+ cy: number
+}
+
+/**
+ * Recadrer une photo de profil ou une bannière avant l'envoi : glisser pour déplacer, pincer, molette ou curseur
+ * pour zoomer, flèches du clavier pour ajuster. L'image couvre toujours tout le cadre (pas de bord vide).
+ */
+export default function ImageCropper({ file, kind, onCancel, onDone }: { file: File; kind: 'avatar' | 'banner'; onCancel: () => void; onDone: (blob: Blob) => void }) {
+ const format = FORMATS[kind]
+ const frameRef = useRef(null)
+ const [img, setImg] = useState()
+ const [error, setError] = useState()
+ const [frame, setFrame] = useState({ w: 0, h: 0 })
+ const [view, setView] = useState({ z: 1, cx: 0, cy: 0 })
+ const [busy, setBusy] = useState(false)
+ const pointers = useRef(new Map())
+ const pinch = useRef<{ dist: number; z: number } | null>(null)
+
+ // Adresse locale de la photo, libérée en fermant
+ const [src] = useState(() => URL.createObjectURL(file))
+ useEffect(() => () => URL.revokeObjectURL(src), [src])
+
+ useEffect(() => {
+ let alive = true
+ loadImage(src)
+ .then((i) => {
+ if (!alive) return
+ setImg(i)
+ setView({ z: 1, cx: i.naturalWidth / 2, cy: i.naturalHeight / 2 })
+ })
+ .catch((e: Error) => alive && setError(e.message))
+ return () => {
+ alive = false
+ }
+ }, [src])
+
+ // Taille du cadre à l'écran (suit la rotation du téléphone)
+ useLayoutEffect(() => {
+ const el = frameRef.current
+ if (!el) return
+ const measure = () => setFrame({ w: el.clientWidth, h: el.clientHeight })
+ measure()
+ const ro = new ResizeObserver(measure)
+ ro.observe(el)
+ return () => ro.disconnect()
+ }, [img])
+
+ const iw = img?.naturalWidth ?? 1
+ const ih = img?.naturalHeight ?? 1
+ // Pixels d'écran par pixel d'image, au zoom 1 : l'image couvre juste le cadre
+ const base = frame.w && frame.h ? Math.max(frame.w / iw, frame.h / ih) : 1
+
+ /** Garde l'image dans le cadre : jamais de bord vide, zoom entre 1 et MAX_ZOOM. */
+ const clamp = (v: View): View => {
+ const z = Math.min(MAX_ZOOM, Math.max(1, v.z))
+ const s = base * z
+ const hw = frame.w / (2 * s)
+ const hh = frame.h / (2 * s)
+ return { z, cx: Math.min(iw - hw, Math.max(hw, v.cx)), cy: Math.min(ih - hh, Math.max(hh, v.cy)) }
+ }
+
+ // Cadre redimensionné (rotation de l'écran) : l'image doit toujours le couvrir
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ useEffect(() => setView((v) => clamp(v)), [frame.w, frame.h])
+
+ const pan = (dx: number, dy: number) => setView((v) => clamp({ ...v, cx: v.cx - dx / (base * v.z), cy: v.cy - dy / (base * v.z) }))
+
+ /** Zoom autour d'un point du cadre (le doigt, le curseur) : ce point de l'image ne bouge pas. */
+ const zoomAt = (fx: number, fy: number, z: number) =>
+ setView((v) => {
+ const ox = fx - frame.w / 2
+ const oy = fy - frame.h / 2
+ const nx = v.cx + ox / (base * v.z)
+ const ny = v.cy + oy / (base * v.z)
+ const nz = Math.min(MAX_ZOOM, Math.max(1, z))
+ return clamp({ z: nz, cx: nx - ox / (base * nz), cy: ny - oy / (base * nz) })
+ })
+
+ // Molette (ordinateur) : écouteur non passif pour que la page ne défile pas en même temps
+ const zoomAtRef = useRef(zoomAt)
+ zoomAtRef.current = zoomAt
+ const zoomRef = useRef(view.z)
+ zoomRef.current = view.z
+ useEffect(() => {
+ const el = frameRef.current
+ if (!el || !img) return
+ const onWheel = (e: WheelEvent) => {
+ e.preventDefault()
+ const r = el.getBoundingClientRect()
+ zoomAtRef.current(e.clientX - r.left, e.clientY - r.top, zoomRef.current * Math.exp(-e.deltaY * 0.002))
+ }
+ el.addEventListener('wheel', onWheel, { passive: false })
+ return () => el.removeEventListener('wheel', onWheel)
+ }, [img])
+
+ const local = (e: PointerEvent) => {
+ const r = frameRef.current!.getBoundingClientRect()
+ return { x: e.clientX - r.left, y: e.clientY - r.top }
+ }
+
+ const onPointerDown = (e: PointerEvent) => {
+ e.currentTarget.setPointerCapture(e.pointerId)
+ pointers.current.set(e.pointerId, local(e))
+ if (pointers.current.size === 2) {
+ const [a, b] = [...pointers.current.values()]
+ pinch.current = { dist: Math.hypot(a.x - b.x, a.y - b.y) || 1, z: view.z }
+ }
+ }
+
+ const onPointerMove = (e: PointerEvent) => {
+ const prev = pointers.current.get(e.pointerId)
+ if (!prev) return
+ const p = local(e)
+ pointers.current.set(e.pointerId, p)
+ if (pointers.current.size === 1) pan(p.x - prev.x, p.y - prev.y)
+ else if (pointers.current.size === 2 && pinch.current) {
+ const [a, b] = [...pointers.current.values()]
+ zoomAt((a.x + b.x) / 2, (a.y + b.y) / 2, (pinch.current.z * Math.hypot(a.x - b.x, a.y - b.y)) / pinch.current.dist)
+ }
+ }
+
+ const onPointerUp = (e: PointerEvent) => {
+ pointers.current.delete(e.pointerId)
+ if (pointers.current.size < 2) pinch.current = null
+ }
+
+ const onKeyDown = (e: KeyboardEvent) => {
+ const step = e.shiftKey ? 40 : 10
+ const moves: Record = { ArrowLeft: [step, 0], ArrowRight: [-step, 0], ArrowUp: [0, step], ArrowDown: [0, -step] }
+ if (moves[e.key]) {
+ e.preventDefault()
+ pan(...moves[e.key])
+ }
+ }
+
+ const apply = async () => {
+ if (!img || busy) return
+ setBusy(true)
+ try {
+ const s = base * view.z
+ const w = frame.w / s
+ const h = frame.h / s
+ onDone(await cropToJpeg(img, { x: view.cx - w / 2, y: view.cy - h / 2, w, h }, format.width, format.height, format.quality))
+ } catch (e) {
+ setError((e as Error).message)
+ setBusy(false)
+ }
+ }
+
+ const s = base * view.z
+ return (
+
+ {busy ? : t('crop.apply')}
+
+ }
+ >
+
+ {error ? (
+
+ {error}
+
+ ) : !img ? (
+
+
+
+ ) : (
+ <>
+
+
+ {/* Photo de profil : ce qui sort du rond est assombri ; bannière : le cadre est la bannière */}
+ {kind === 'avatar' ? (
+
+ ) : (
+
+ )}
+
+
+ {t('crop.zoom')}
+ zoomAt(frame.w / 2, frame.h / 2, Number(e.target.value))}
+ className="flex-1 accent-accent"
+ />
+
+
{t('crop.hint')}
+ >
+ )}
+
+
+ )
+}
diff --git a/src/i18n/locales/ar.ts b/src/i18n/locales/ar.ts
index e353b1b..dbeb0f7 100644
--- a/src/i18n/locales/ar.ts
+++ b/src/i18n/locales/ar.ts
@@ -1193,6 +1193,11 @@ const dict: Translations = {
"install.macSafari3": "انقر «إضافة»: سيظهر Bobinoo في Dock.",
"install.macChrome1": "انقر على أيقونة التثبيت في شريط العنوان.",
"install.macChrome2": "انقر «تثبيت»: سيفتح Bobinoo في نافذة خاصة به ويُضاف إلى Dock.",
+ "crop.avatarTitle": "قص الصورة",
+ "crop.bannerTitle": "قص البانر",
+ "crop.hint": "اسحب لتحريك الصورة. استخدم إصبعين أو شريط التمرير للتكبير.",
+ "crop.zoom": "تكبير",
+ "crop.apply": "تم",
}
export default dict
diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts
index a7837d2..bf69ea8 100644
--- a/src/i18n/locales/de.ts
+++ b/src/i18n/locales/de.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "Klicke auf „Hinzufügen“: Bobinoo erscheint in deinem Dock.",
"install.macChrome1": "Klicke rechts in der Adressleiste auf das Installationssymbol.",
"install.macChrome2": "Klicke auf „Installieren“: Bobinoo öffnet sich in einem eigenen Fenster und landet in deinem Dock.",
+ "crop.avatarTitle": "Foto zuschneiden",
+ "crop.bannerTitle": "Banner zuschneiden",
+ "crop.hint": "Zieh das Bild, um es zu verschieben. Zum Zoomen die Finger spreizen oder den Regler nutzen.",
+ "crop.zoom": "Zoom",
+ "crop.apply": "Fertig",
}
export default dict
diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts
index 168366b..7cc0afb 100644
--- a/src/i18n/locales/en.ts
+++ b/src/i18n/locales/en.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "Click “Add”: Bobinoo appears in your Dock.",
"install.macChrome1": "Click the install icon on the right of the address bar.",
"install.macChrome2": "Click “Install”: Bobinoo opens in its own window and joins your Dock.",
+ "crop.avatarTitle": "Crop photo",
+ "crop.bannerTitle": "Crop banner",
+ "crop.hint": "Drag to move the image. Pinch or use the slider to zoom.",
+ "crop.zoom": "Zoom",
+ "crop.apply": "Done",
}
export default dict
diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts
index c1ed7a1..d158434 100644
--- a/src/i18n/locales/es.ts
+++ b/src/i18n/locales/es.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "Haz clic en «Añadir»: Bobinoo aparecerá en tu Dock.",
"install.macChrome1": "Haz clic en el icono de instalación, a la derecha de la barra de direcciones.",
"install.macChrome2": "Haz clic en «Instalar»: Bobinoo se abrirá en su propia ventana y se añadirá a tu Dock.",
+ "crop.avatarTitle": "Recortar foto",
+ "crop.bannerTitle": "Recortar banner",
+ "crop.hint": "Arrastra para mover la imagen. Pellizca o usa el control deslizante para hacer zoom.",
+ "crop.zoom": "Zoom",
+ "crop.apply": "Listo",
}
export default dict
diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts
index 4bcca7d..632282c 100644
--- a/src/i18n/locales/fr.ts
+++ b/src/i18n/locales/fr.ts
@@ -1046,6 +1046,11 @@ const dict = {
"install.macSafari3": "Clique sur « Ajouter » : Bobinoo apparaît dans ton Dock.",
"install.macChrome1": "Clique sur l'icône d'installation, à droite de la barre d'adresse.",
"install.macChrome2": "Clique sur « Installer » : Bobinoo s'ouvre dans sa propre fenêtre et rejoint ton Dock.",
+ "crop.avatarTitle": "Recadrer la photo",
+ "crop.bannerTitle": "Recadrer la bannière",
+ "crop.hint": "Fais glisser pour déplacer l'image. Pince ou utilise le curseur pour zoomer.",
+ "crop.zoom": "Zoom",
+ "crop.apply": "Valider",
}
export default dict
diff --git a/src/i18n/locales/hi.ts b/src/i18n/locales/hi.ts
index 00c6c2e..2d85361 100644
--- a/src/i18n/locales/hi.ts
+++ b/src/i18n/locales/hi.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "“जोड़ें” पर क्लिक करें: Bobinoo आपके Dock में दिखेगा।",
"install.macChrome1": "एड्रेस बार के दाईं ओर इंस्टॉल आइकन पर क्लिक करें।",
"install.macChrome2": "“इंस्टॉल करें” पर क्लिक करें: Bobinoo अपनी अलग विंडो में खुलेगा और Dock में जुड़ जाएगा।",
+ "crop.avatarTitle": "फ़ोटो क्रॉप करें",
+ "crop.bannerTitle": "बैनर क्रॉप करें",
+ "crop.hint": "इमेज खिसकाने के लिए खींचें। ज़ूम के लिए पिंच करें या स्लाइडर का इस्तेमाल करें।",
+ "crop.zoom": "ज़ूम",
+ "crop.apply": "हो गया",
}
export default dict
diff --git a/src/i18n/locales/id.ts b/src/i18n/locales/id.ts
index 0e8e20e..2cd9acf 100644
--- a/src/i18n/locales/id.ts
+++ b/src/i18n/locales/id.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "Klik “Tambah”: Bobinoo muncul di Dock.",
"install.macChrome1": "Klik ikon instal di sebelah kanan bilah alamat.",
"install.macChrome2": "Klik “Instal”: Bobinoo terbuka di jendelanya sendiri dan masuk ke Dock.",
+ "crop.avatarTitle": "Pangkas foto",
+ "crop.bannerTitle": "Pangkas banner",
+ "crop.hint": "Seret untuk menggeser gambar. Cubit atau gunakan penggeser untuk zoom.",
+ "crop.zoom": "Zoom",
+ "crop.apply": "Selesai",
}
export default dict
diff --git a/src/i18n/locales/it.ts b/src/i18n/locales/it.ts
index fafe55e..5e938a4 100644
--- a/src/i18n/locales/it.ts
+++ b/src/i18n/locales/it.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "Fai clic su «Aggiungi»: Bobinoo comparirà nel Dock.",
"install.macChrome1": "Fai clic sull’icona di installazione, a destra della barra degli indirizzi.",
"install.macChrome2": "Fai clic su «Installa»: Bobinoo si apre in una finestra tutta sua e compare nel Dock.",
+ "crop.avatarTitle": "Ritaglia foto",
+ "crop.bannerTitle": "Ritaglia banner",
+ "crop.hint": "Trascina per spostare l’immagine. Pizzica o usa il cursore per lo zoom.",
+ "crop.zoom": "Zoom",
+ "crop.apply": "Fatto",
}
export default dict
diff --git a/src/i18n/locales/ja.ts b/src/i18n/locales/ja.ts
index 554c5d0..3beb101 100644
--- a/src/i18n/locales/ja.ts
+++ b/src/i18n/locales/ja.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "「追加」をクリックすると、Bobinoo が Dock に表示されます。",
"install.macChrome1": "アドレスバーの右側にあるインストールのアイコンをクリックします。",
"install.macChrome2": "「インストール」をクリックすると、Bobinoo が専用のウインドウで開き、Dock に追加されます。",
+ "crop.avatarTitle": "写真を切り抜く",
+ "crop.bannerTitle": "バナーを切り抜く",
+ "crop.hint": "ドラッグで画像を移動、ピンチまたはスライダーで拡大・縮小できます。",
+ "crop.zoom": "ズーム",
+ "crop.apply": "完了",
}
export default dict
diff --git a/src/i18n/locales/ko.ts b/src/i18n/locales/ko.ts
index a3633b7..525116f 100644
--- a/src/i18n/locales/ko.ts
+++ b/src/i18n/locales/ko.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "'추가'를 클릭하면 Dock에 Bobinoo가 나타나요.",
"install.macChrome1": "주소창 오른쪽에 있는 설치 아이콘을 클릭하세요.",
"install.macChrome2": "'설치'를 클릭하면 Bobinoo가 별도의 창으로 열리고 Dock에 추가돼요.",
+ "crop.avatarTitle": "사진 자르기",
+ "crop.bannerTitle": "배너 자르기",
+ "crop.hint": "드래그해서 이미지를 옮기고, 핀치하거나 슬라이더로 확대해요.",
+ "crop.zoom": "확대",
+ "crop.apply": "완료",
}
export default dict
diff --git a/src/i18n/locales/nl.ts b/src/i18n/locales/nl.ts
index 2f7e738..2ebd5a0 100644
--- a/src/i18n/locales/nl.ts
+++ b/src/i18n/locales/nl.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "Klik op ‘Voeg toe’: Bobinoo verschijnt in je Dock.",
"install.macChrome1": "Klik op het installatiepictogram rechts in de adresbalk.",
"install.macChrome2": "Klik op ‘Installeren’: Bobinoo opent in een eigen venster en komt in je Dock.",
+ "crop.avatarTitle": "Foto bijsnijden",
+ "crop.bannerTitle": "Banner bijsnijden",
+ "crop.hint": "Sleep om de afbeelding te verplaatsen. Knijp of gebruik de schuifregelaar om te zoomen.",
+ "crop.zoom": "Zoom",
+ "crop.apply": "Klaar",
}
export default dict
diff --git a/src/i18n/locales/pl.ts b/src/i18n/locales/pl.ts
index 9ee0a59..89675da 100644
--- a/src/i18n/locales/pl.ts
+++ b/src/i18n/locales/pl.ts
@@ -1142,6 +1142,11 @@ const dict: Translations = {
"install.macSafari3": "Kliknij „Dodaj”: Bobinoo pojawi się w Docku.",
"install.macChrome1": "Kliknij ikonę instalacji po prawej stronie paska adresu.",
"install.macChrome2": "Kliknij „Zainstaluj”: Bobinoo otworzy się we własnym oknie i trafi do Docka.",
+ "crop.avatarTitle": "Przytnij zdjęcie",
+ "crop.bannerTitle": "Przytnij baner",
+ "crop.hint": "Przeciągnij, aby przesunąć obraz. Uszczypnij lub użyj suwaka, aby powiększyć.",
+ "crop.zoom": "Powiększenie",
+ "crop.apply": "Gotowe",
}
export default dict
diff --git a/src/i18n/locales/pt.ts b/src/i18n/locales/pt.ts
index f47d353..f482d75 100644
--- a/src/i18n/locales/pt.ts
+++ b/src/i18n/locales/pt.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "Clique em “Adicionar”: o Bobinoo aparece no seu Dock.",
"install.macChrome1": "Clique no ícone de instalação, à direita da barra de endereço.",
"install.macChrome2": "Clique em “Instalar”: o Bobinoo abre em uma janela própria e vai para o seu Dock.",
+ "crop.avatarTitle": "Recortar foto",
+ "crop.bannerTitle": "Recortar banner",
+ "crop.hint": "Arraste para mover a imagem. Use o gesto de pinça ou o controle deslizante para dar zoom.",
+ "crop.zoom": "Zoom",
+ "crop.apply": "Concluir",
}
export default dict
diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts
index f3753bd..42af1b8 100644
--- a/src/i18n/locales/ru.ts
+++ b/src/i18n/locales/ru.ts
@@ -1142,6 +1142,11 @@ const dict: Translations = {
"install.macSafari3": "Нажми «Добавить»: Bobinoo появится в Dock.",
"install.macChrome1": "Нажми на значок установки справа в адресной строке.",
"install.macChrome2": "Нажми «Установить»: Bobinoo откроется в отдельном окне и появится в Dock.",
+ "crop.avatarTitle": "Обрезать фото",
+ "crop.bannerTitle": "Обрезать баннер",
+ "crop.hint": "Перетаскивай, чтобы сдвинуть изображение. Сведи или разведи пальцы либо используй ползунок для масштаба.",
+ "crop.zoom": "Масштаб",
+ "crop.apply": "Готово",
}
export default dict
diff --git a/src/i18n/locales/th.ts b/src/i18n/locales/th.ts
index 709f839..d5cd3d1 100644
--- a/src/i18n/locales/th.ts
+++ b/src/i18n/locales/th.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "คลิก “เพิ่ม” แล้ว Bobinoo จะปรากฏใน Dock",
"install.macChrome1": "คลิกไอคอนติดตั้งทางขวาของแถบที่อยู่",
"install.macChrome2": "คลิก “ติดตั้ง” แล้ว Bobinoo จะเปิดในหน้าต่างของตัวเองและอยู่ใน Dock",
+ "crop.avatarTitle": "ครอปรูปภาพ",
+ "crop.bannerTitle": "ครอปแบนเนอร์",
+ "crop.hint": "ลากเพื่อเลื่อนภาพ ใช้สองนิ้วหรือแถบเลื่อนเพื่อซูม",
+ "crop.zoom": "ซูม",
+ "crop.apply": "เสร็จ",
}
export default dict
diff --git a/src/i18n/locales/tr.ts b/src/i18n/locales/tr.ts
index 9ec8f96..0600860 100644
--- a/src/i18n/locales/tr.ts
+++ b/src/i18n/locales/tr.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "“Ekle”ye tıkla: Bobinoo Dock’ta görünür.",
"install.macChrome1": "Adres çubuğunun sağındaki yükleme simgesine tıkla.",
"install.macChrome2": "“Yükle”ye tıkla: Bobinoo kendi penceresinde açılır ve Dock’a eklenir.",
+ "crop.avatarTitle": "Fotoğrafı kırp",
+ "crop.bannerTitle": "Banner’ı kırp",
+ "crop.hint": "Görseli taşımak için sürükle. Yakınlaştırmak için iki parmağını kullan ya da kaydırıcıyı sürükle.",
+ "crop.zoom": "Yakınlaştırma",
+ "crop.apply": "Tamam",
}
export default dict
diff --git a/src/i18n/locales/vi.ts b/src/i18n/locales/vi.ts
index faa52ed..8367377 100644
--- a/src/i18n/locales/vi.ts
+++ b/src/i18n/locales/vi.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "Bấm “Thêm”: Bobinoo xuất hiện trong Dock.",
"install.macChrome1": "Bấm vào biểu tượng cài đặt ở bên phải thanh địa chỉ.",
"install.macChrome2": "Bấm “Cài đặt”: Bobinoo mở trong cửa sổ riêng và có mặt trong Dock.",
+ "crop.avatarTitle": "Cắt ảnh",
+ "crop.bannerTitle": "Cắt ảnh bìa",
+ "crop.hint": "Kéo để di chuyển ảnh. Chụm hai ngón tay hoặc dùng thanh trượt để thu phóng.",
+ "crop.zoom": "Thu phóng",
+ "crop.apply": "Xong",
}
export default dict
diff --git a/src/i18n/locales/zh.ts b/src/i18n/locales/zh.ts
index e5cc08e..0fd26f6 100644
--- a/src/i18n/locales/zh.ts
+++ b/src/i18n/locales/zh.ts
@@ -1044,6 +1044,11 @@ const dict: Translations = {
"install.macSafari3": "点按“添加”:Bobinoo 会出现在你的程序坞中。",
"install.macChrome1": "点按地址栏右侧的安装图标。",
"install.macChrome2": "点按“安装”:Bobinoo 会在独立窗口中打开,并加入你的程序坞。",
+ "crop.avatarTitle": "裁剪照片",
+ "crop.bannerTitle": "裁剪横幅",
+ "crop.hint": "拖动以移动图片,双指或滑块可以缩放。",
+ "crop.zoom": "缩放",
+ "crop.apply": "完成",
}
export default dict
diff --git a/src/lib/image.ts b/src/lib/image.ts
index e2bcb7b..9cb273c 100644
--- a/src/lib/image.ts
+++ b/src/lib/image.ts
@@ -42,36 +42,35 @@ export function fileToPosterDataURL(file: File) {
return blobToPosterDataURL(file)
}
-/**
- * Photo de profil ou bannière : recadrée au centre aux dimensions voulues et ré-encodée en JPEG
- * (aucune métadonnée cachée n'est conservée).
- */
-export function cropImageToJpeg(file: File, width: number, height: number, quality = 0.86): Promise {
- if (!file.type.startsWith('image/') || file.type === 'image/svg+xml') return Promise.reject(new Error(t('image.notImage')))
- if (file.size > LIMITS.imageFileBytes) return Promise.reject(new Error(t('image.tooBig')))
+/** Photo choisie pour le profil : uniquement des images (pas de SVG), taille raisonnable. Lève une erreur sinon. */
+export function checkImageFile(file: File): void {
+ if (!file.type.startsWith('image/') || file.type === 'image/svg+xml') throw new Error(t('image.notImage'))
+ if (file.size > LIMITS.imageFileBytes) throw new Error(t('image.tooBig'))
+}
+
+/** Image décodée depuis une adresse locale (blob:), orientation de l'appareil photo déjà appliquée par le navigateur. */
+export function loadImage(src: string): Promise {
return new Promise((resolve, reject) => {
- const url = URL.createObjectURL(file)
const img = new Image()
- img.onload = () => {
- URL.revokeObjectURL(url)
- const scale = Math.max(width / img.width, height / img.height)
- const sw = width / scale
- const sh = height / scale
- const sx = (img.width - sw) / 2
- const sy = (img.height - sh) / 2
- const canvas = document.createElement('canvas')
- canvas.width = width
- canvas.height = height
- const ctx = canvas.getContext('2d')
- if (!ctx) return reject(new Error(t('image.canvas')))
- ctx.imageSmoothingQuality = 'high'
- ctx.drawImage(img, sx, sy, sw, sh, 0, 0, width, height)
- canvas.toBlob((b) => (b ? resolve(b) : reject(new Error(t('image.unreadable')))), 'image/jpeg', quality)
- }
- img.onerror = () => {
- URL.revokeObjectURL(url)
- reject(new Error(t('image.unreadable')))
- }
- img.src = url
+ img.onload = () => resolve(img)
+ img.onerror = () => reject(new Error(t('image.unreadable')))
+ img.src = src
+ })
+}
+
+/**
+ * Zone choisie d'une image (en pixels de l'image) ré-encodée en JPEG aux dimensions voulues :
+ * aucune métadonnée cachée (EXIF, GPS…) n'est conservée.
+ */
+export function cropToJpeg(img: HTMLImageElement, area: { x: number; y: number; w: number; h: number }, width: number, height: number, quality = 0.86): Promise {
+ return new Promise((resolve, reject) => {
+ const canvas = document.createElement('canvas')
+ canvas.width = width
+ canvas.height = height
+ const ctx = canvas.getContext('2d')
+ if (!ctx) return reject(new Error(t('image.canvas')))
+ ctx.imageSmoothingQuality = 'high'
+ ctx.drawImage(img, area.x, area.y, area.w, area.h, 0, 0, width, height)
+ canvas.toBlob((b) => (b ? resolve(b) : reject(new Error(t('image.unreadable')))), 'image/jpeg', quality)
})
}