fix apply
This commit is contained in:
@@ -170,8 +170,8 @@ async fn export_batch(images: Vec<ExportImageTask>, watermark: WatermarkSettings
|
||||
let scaled_font = PxScale::from(scale_px);
|
||||
let (t_width, _t_height) = imageproc::drawing::text_size(scaled_font, &font, &watermark.text);
|
||||
|
||||
// 3. Ensure it fits width (Padding 10%)
|
||||
let max_width = (width as f32 * 0.90) as u32;
|
||||
// 3. Ensure it fits width (Padding 15%)
|
||||
let max_width = (width as f32 * 0.85) as u32;
|
||||
if t_width > max_width {
|
||||
let ratio = max_width as f32 / t_width as f32;
|
||||
scale_px *= ratio;
|
||||
@@ -395,8 +395,8 @@ async fn layout_watermark(path: String, text: String, base_scale: f64) -> Result
|
||||
let mut font_scale = PxScale::from(scale_px);
|
||||
let (mut t_width, mut t_height) = imageproc::drawing::text_size(font_scale, &font, &text);
|
||||
|
||||
// 3. Auto-Fit Width (Limit to 90% of image width)
|
||||
let max_width = (width as f32 * 0.90) as u32;
|
||||
// 3. Auto-Fit Width (Limit to 85% of image width)
|
||||
let max_width = (width as f32 * 0.85) as u32;
|
||||
if t_width > max_width {
|
||||
let ratio = max_width as f32 / t_width as f32;
|
||||
scale_val *= ratio as f64;
|
||||
@@ -411,9 +411,15 @@ async fn layout_watermark(path: String, text: String, base_scale: f64) -> Result
|
||||
let center_x = zca.x * width as f64;
|
||||
let center_y = zca.y * height as f64;
|
||||
|
||||
let half_w = t_width as f64 / 2.0;
|
||||
let half_h = t_height as f64 / 2.0;
|
||||
let padding = width as f64 * 0.02;
|
||||
// Add safety margin to measured text size (Renderer mismatch buffer)
|
||||
let safe_t_width = t_width as f64 * 1.05;
|
||||
let safe_t_height = t_height as f64 * 1.05;
|
||||
|
||||
let half_w = safe_t_width / 2.0;
|
||||
let half_h = safe_t_height / 2.0;
|
||||
|
||||
// Increase edge padding to 4%
|
||||
let padding = width as f64 * 0.04;
|
||||
|
||||
let min_x = half_w + padding;
|
||||
let max_x = width as f64 - half_w - padding;
|
||||
|
||||
Reference in New Issue
Block a user