diff --git a/src/pixelflow/api/static/index.html b/src/pixelflow/api/static/index.html index 1fd23ac..bd457cf 100644 --- a/src/pixelflow/api/static/index.html +++ b/src/pixelflow/api/static/index.html @@ -944,6 +944,26 @@ color: var(--pf-danger); } + .btn-filter-pill { + background: #111520; + border: 1px solid rgba(255, 255, 255, 0.08); + color: #94a3b8; + font-size: 10px; + font-weight: 600; + padding: 3px 8px; + border-radius: 12px; + cursor: pointer; + white-space: nowrap; + transition: all 0.12s ease; + } + + .btn-filter-pill:hover, + .btn-filter-pill.active { + background: rgba(56, 189, 248, 0.18); + border-color: var(--pf-accent); + color: #fff; + } + .active-step-card { background: #111622; border: 1px solid rgba(255, 255, 255, 0.08); @@ -1818,7 +1838,7 @@ - Damgalar + Tipografi & Damga + + + + + + +
-
ÖZEL METİNLİ KAŞE
-
- - +
+
+ +
+
+ + +
+
@@ -3129,14 +3179,37 @@

quickAdd("inpaint") }, { id: "preset", group: "Fotoğraf & AI", groupEn: "Photo & AI", name: "Sinematik LUT Renk Presetleri", nameEn: "Cinematic LUT Color Presets", action: () => quickAdd("preset") }, { id: "blend_layer", group: "Fotoğraf & AI", groupEn: "Photo & AI", name: "Katman Karışım Modu & Opaklık (Blend)", nameEn: "Layer Blend Mode & Opacity", action: () => quickAdd("blend") }, + { id: "typography_studio", group: "Fotoğraf & AI", groupEn: "Photo & AI", name: "Tipografi, Retro Tarih & Telif Damgası", nameEn: "Typography, Retro Date & Copyright Stamp", action: () => { switchLeftTab("stamps"); if (document.getElementById("proLeftPanel")?.classList.contains("collapsed")) toggleLeftPanel(); } }, { id: "duotone", group: "Fotoğraf & AI", groupEn: "Photo & AI", name: "Duotone İki Renkli Gradyan Eşleme", nameEn: "Duotone Two-Tone Gradient Map", action: () => quickAdd("duotone") }, { id: "brightness_contrast", group: "Fotoğraf & AI", groupEn: "Photo & AI", name: "Parlaklık & Kontrast Ayarı", nameEn: "Brightness & Contrast Adjustment", action: () => quickAdd("brightness_contrast") }, { id: "vibrance", group: "Fotoğraf & AI", groupEn: "Photo & AI", name: "Canlılık & Doygunluk (Vibrance)", nameEn: "Vibrance & Saturation", action: () => quickAdd("vibrance") }, @@ -6003,26 +6077,300 @@

p.classList.remove("active")); + if (btn) btn.classList.add("active"); + renderStampsVitrin(); + } + + function insertTodayRetroDate() { + const input = document.getElementById("customStampTextInput"); + const d = new Date(); + const yy = String(d.getFullYear()).slice(-2); + const mm = String(d.getMonth() + 1).padStart(2, "0"); + const dd = String(d.getDate()).padStart(2, "0"); + const sample = `'${yy} ${mm} ${dd}`; + if (input) input.value = sample; + if (statusMessage) statusMessage.textContent = `Tarih şablonu eklendi: ${sample}`; + } + function renderStampsVitrin() { const grid = document.getElementById("stampsVitrinGrid"); if (!grid) return; - grid.innerHTML = PRO_STAMP_PRESETS.map(s => { + const filtered = PRO_TYPOGRAPHY_PRESETS.filter(s => currentStampCategory === "all" || s.cat === currentStampCategory); + grid.innerHTML = filtered.map(s => { const title = currentLang === "en" ? s.nameEn : s.name; const sub = currentLang === "en" ? s.descEn : s.desc; - const rgb = `rgb(${s.color[0]}, ${s.color[1]}, ${s.color[2]})`; + const isStamp = (s.type === "stamp"); + const angle = s.angle || 0; return ` -
-
-
${s.text.slice(0, 8)}
+
+
+
+ ${s.swatchText || s.text.slice(0, 10)} +
${title}
@@ -6033,16 +6381,76 @@

p.id === presetId); + function applyTypographyOrStampPreset(presetId) { + const preset = PRO_TYPOGRAPHY_PRESETS.find(p => p.id === presetId); if (!preset) return; - applyStampWithParams(preset.text, preset.color, preset.angle, preset.opacity, preset.scale); + if (preset.type === "stamp") { + applyStampWithParams(preset.text, preset.color, preset.angle || -12, preset.opacity || 0.9, preset.scale || 0.9); + } else { + applyWatermarkWithParams({ + text: preset.text, + color: preset.color, + font_style: preset.font_style || "sans", + position: preset.position || "bottom-right", + opacity: preset.opacity || 0.85, + scale: preset.scale || 0.35, + box_background: !!preset.box_background, + box_color: preset.box_color || [0, 0, 0] + }); + } } function applyCustomTextStamp() { const input = document.getElementById("customStampTextInput"); - const text = (input?.value || "ONAYLANDI").trim(); - applyStampWithParams(text, [220, 38, 38], -12, 0.88, 0.9); + const fontSel = document.getElementById("customStampFontStyle"); + const colorSel = document.getElementById("customStampColorPreset"); + const text = (input?.value || "PixelFlow").trim(); + const fontStyle = fontSel?.value || "mono"; + const colorKey = colorSel?.value || "amber"; + + const colorMap = { + amber: [255, 140, 0], + green: [34, 197, 94], + white: [255, 255, 255], + red: [220, 38, 38], + blue: [29, 78, 216] + }; + const color = colorMap[colorKey] || [255, 255, 255]; + + applyWatermarkWithParams({ + text, + color, + font_style: fontStyle, + position: (fontStyle === "mono" || colorKey === "amber") ? "bottom-right" : "bottom-left", + opacity: 0.9, + scale: 0.32, + box_background: false, + box_color: [0, 0, 0] + }); + } + + function applyWatermarkWithParams(params) { + let step = activeSteps.find(s => s.op === "watermark"); + if (step) { + step.params = { ...step.params, ...params }; + step.name = `katman_${step.id}_yazi_${params.text.replace(/\s+/g, '_').slice(0, 10)}`; + selectedStepId = step.id; + } else { + const id = stepCounter++; + activeSteps.push({ + id, + op: "watermark", + name: `katman_${id}_yazi_${params.text.replace(/\s+/g, '_').slice(0, 10)}`, + params: { ...params } + }); + selectedStepId = id; + } + pushHistory(); + renderStepsUI(); + scheduleRender(); + statusMessage.textContent = (currentLang === "en") + ? `✓ Typography applied: "${params.text}"` + : `✓ Tipografi uygulandı: "${params.text}"`; } function applyStampWithParams(text, color, angle, opacity, scale) { diff --git a/src/pixelflow/operations/overlay.py b/src/pixelflow/operations/overlay.py index d3fc5c8..943f93e 100644 --- a/src/pixelflow/operations/overlay.py +++ b/src/pixelflow/operations/overlay.py @@ -34,6 +34,9 @@ class WatermarkParams(OperationParams): y: int = Field(default=0, ge=0) color: tuple[int, int, int] = (255, 255, 255) base_dir: str | None = None + font_style: Literal["sans", "serif", "mono", "bold"] = "sans" + box_background: bool = Field(default=False) + box_color: tuple[int, int, int] = (0, 0, 0) @model_validator(mode="after") def validate_source(self) -> WatermarkParams: @@ -90,16 +93,29 @@ def _load_image_watermark(self, target_w: int, target_h: int) -> npt.NDArray[np. cv2.resize(rgba, (new_w, new_h), interpolation=cv2.INTER_AREA), ) + @staticmethod + def _select_font(style: str) -> int: + fonts = { + "serif": cv2.FONT_HERSHEY_COMPLEX, + "mono": cv2.FONT_HERSHEY_PLAIN, + "bold": cv2.FONT_HERSHEY_DUPLEX, + } + return fonts.get(style, cv2.FONT_HERSHEY_SIMPLEX) + def _render_text_watermark(self, target_w: int) -> npt.NDArray[np.uint8]: text = self.params.text or "Pixelflow" - font = cv2.FONT_HERSHEY_SIMPLEX + font = self._select_font(self.params.font_style) font_scale = max(0.4, (target_w * self.params.scale) / max(60.0, len(text) * 18.0)) thickness = max(1, round(font_scale * 2.0)) (tw, th), baseline = cv2.getTextSize(text, font, font_scale, thickness) pad = 6 - h_box = max(1, th + baseline + pad * 2) - w_box = max(1, tw + pad * 2) + h_box, w_box = max(1, th + baseline + pad * 2), max(1, tw + pad * 2) canvas = np.zeros((h_box, w_box, 4), dtype=np.uint8) + if self.params.box_background: + canvas[:, :, 0] = self.params.box_color[0] + canvas[:, :, 1] = self.params.box_color[1] + canvas[:, :, 2] = self.params.box_color[2] + canvas[:, :, 3] = 180 color_rgba = ( int(self.params.color[0]), int(self.params.color[1]), diff --git a/tests/test_overlay.py b/tests/test_overlay.py index 9ee395f..a578471 100644 --- a/tests/test_overlay.py +++ b/tests/test_overlay.py @@ -49,6 +49,24 @@ def test_image_watermark_and_grayscale(tmp_path: Path) -> None: assert np.all(out_of_bounds == 0) +def test_watermark_typography_styles() -> None: + img = np.zeros((100, 100, 3), dtype=np.uint8) + for font in ("sans", "serif", "mono", "bold"): + out = WatermarkOperation( + { + "text": "'98 11 04", + "font_style": font, + "position": "bottom-right", + "opacity": 1.0, + "color": (255, 140, 0), + "box_background": True, + "box_color": (20, 20, 20), + } + ).apply(img) + assert out.shape == (100, 100, 3) + assert np.any(out > 0) + + def test_golden_image_pipeline_with_tolerance() -> None: src = np.zeros((32, 32, 3), dtype=np.uint8) src[8:24, 8:24] = [200, 100, 50]