Bug 328457

Summary: BQM Watermark tool : doesn't apply zero margins
Product: [Applications] digikam Reporter: mnaugendre
Component: Plugin-Bqm-WaterMarkAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: ahmed.fathi.abdelmageed, caulier.gilles
Priority: NOR    
Version: 3.5.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In: 5.5.0
Sentry Crash Report:
Attachments: a patch to solve the margin problem
Screen shots for before and after the batch

Description mnaugendre 2013-12-05 16:07:26 UTC
When adding a watermark with both X and Y margins set to 0%, there seem to be at least 1 remaining pixel on one or two margin(s).

Reproducible: Always

Steps to Reproduce:
1. put a picture in the batch queue
2. set up the watermark tool with a .png file bigger than the picture, and set size to 100% and X and Y margins to 0
3. run BQM
Actual Results:  
Generated picture always has at least 1 pixel margin on one or two margins, depending on the placement choice.

Expected Results:  
Zero margins on all four sides of the picture.

I use this tool to add a drop shadow on all four sides of the picture, to add it more depth. But this won't work if there some margins remain on one or two sides.
Comment 1 Ahmed Fathi 2017-01-21 19:34:17 UTC
Created attachment 103576 [details]
a patch to solve the margin problem

HI , I solved this "bug" and here is the batch .
In the following post I will send screenshots

There were two problems :-

First in the function calls : watermarkRect.moveTopRight() , watermarkRect.moveBottomLeft(), watermarkRect.moveBottomRight() , We needed to pass (Width -1 ) and (height -1 ) instead of Width and height.

The second problem was that the watermark photo has a different aspect ration than the original photo. An option to "Keep Aspect ratio" of the waterMark was used, so however large the watermark Image was , keeping its aspect ratio will always leave spaces in the actual image. 
Changing the option from Qt::KeepAspectRatio  to  Qt::IgnoreAspectRatio  will solve the problem and make the watermark always have the aspect ratio of the original photo as @mnaugendre requires. but it is not logical to Always ignore the aspect ratio of the watermark and stretch it to be exactly like the image. So I added a new checkbox to allow the user to ignore the water mark aspect ratio If that is what he really needs , which is unchecked by default.
Comment 2 Ahmed Fathi 2017-01-21 19:37:09 UTC
Created attachment 103577 [details]
Screen shots for before and after the batch

Screen shots for 
1- before the batch
2- after the batch with the new Checkbox Checked
3- after the batch with the new Checkbox UnChecked
Comment 3 caulier.gilles 2017-01-22 10:49:30 UTC
Git commit 921115bd46668b1ce54db32080d6d2f76c10ea52 by Gilles Caulier.
Committed on 22/01/2017 at 10:48.
Pushed by cgilles into branch 'master'.

apply patch #103576 from Ahmed Fathi
FIXED-IN: 5.5.0

M  +2    -1    NEWS
M  +61   -41   utilities/queuemanager/tools/decorate/watermark.cpp
M  +1    -1    utilities/queuemanager/tools/decorate/watermark.h

https://commits.kde.org/digikam/921115bd46668b1ce54db32080d6d2f76c10ea52