Noticing the watermarking done by the 1.x version of Gallery doesnt do blending/transparency by default with ImageMagic (aside from transparent gif/png), I edited a few files to add it. The below diff is off of 1.5.4. It adds a field to the watermark forms to allow the user to enter a percentage for the watermark to be blended. Previewing the watermark will show the expected results. Note that this simply turns on the ImageMagick -dissolve feature and passes around the $dissolve var. It appears NetPBM already includes alpha blending of some sort, but I dont have NetPBM to test. It looks like adding -opacity=($dissolve/100) to the NetPBM $args should accomplish the same results as this does with ImageMagick, but I didnt add since again, I dont have it installed to test with.
diff -r gallery/classes/Album.php ../gallery/classes/Album.php
1155c1155
< function addPhoto($file, $tag, $originalFilename, $caption, $pathToThumb = '', $extraFields = array(), $owner = '', $votes = NULL, $wmName = '', $wmAlign = 0, $wmAlignX = 0, $wmAlignY = 0, $wmSelect = 0, $exifRotate = true) {
---
> function addPhoto($file, $tag, $originalFilename, $caption, $pathToThumb = '', $extraFields = array(), $owner = '', $votes = NULL, $wmName = '', $wmAlign = 0, $wmAlignX = 0, $wmAlignY = 0, $wmSelect = 0, $exifRotate = true, $dissolve = 30) {
1335c1335
< $wmName, '', $wmAlign, $wmAlignX, $wmAlignY, 0, 0, $wmSelect);
---
> $wmName, '', $wmAlign, $wmAlignX, $wmAlignY, 0, 0, $wmSelect, $dissolve);
1839c1839
< function watermarkPhoto($index, $wmName, $wmAlphaName, $wmAlign, $wmAlignX, $wmAlignY, $preview=0, $previewSize=0, $wmSelect=0) {
---
> function watermarkPhoto($index, $wmName, $wmAlphaName, $wmAlign, $wmAlignX, $wmAlignY, $preview=0, $previewSize=0, $wmSelect=0, $dissolve = 0) {
1851c1851,1852
< $wmSelect
---
> $wmSelect,
> $dissolve
1860c1861
< function watermarkAlbum($wmName, $wmAlphaName, $wmAlign, $wmAlignX, $wmAlignY, $recursive=0, $wmSelect=0) {
---
> function watermarkAlbum($wmName, $wmAlphaName, $wmAlign, $wmAlignX, $wmAlignY, $recursive=0, $wmSelect=0, $dissolve = 0) {
1871c1872
< $wmAlign, $wmAlignX, $wmAlignY, $recursive, $wmSelect);
---
> $wmAlign, $wmAlignX, $wmAlignY, $recursive, $wmSelect, $dissolve);
1880c1881
< $wmSelect);
---
> $wmSelect, $dissolve);
diff -r gallery/classes/AlbumItem.php ../gallery/classes/AlbumItem.php
517c517
< function watermark($dir, $wmName, $wmAlphaName, $wmAlign, $wmAlignX, $wmAlignY, $preview=0, $previewSize=0, $wmSelect=0) {
---
> function watermark($dir, $wmName, $wmAlphaName, $wmAlign, $wmAlignX, $wmAlignY, $preview=0, $previewSize=0, $wmSelect=0, $dissolve=0) {
549c549
< $wmAlign, $wmAlignX, $wmAlignY
---
> $wmAlign, $wmAlignX, $wmAlignY, $dissolve
567c567
< $wmAlign, $wmAlignX, $wmAlignY
---
> $wmAlign, $wmAlignX, $wmAlignY, $dissolve
586c586
< $wmAlignY
---
> $wmAlignY, $dissolve
diff -r gallery/edit_watermark.php ../gallery/edit_watermark.php
38,39c38,39
< list($wmName, $wmAlign, $wmAlignX, $wmAlignY, $wmSelect) =
< getRequestVar(array('wmName', 'wmAlign', 'wmAlignX', 'wmAlignY', 'wmSelect'));
---
> list($wmName, $wmAlign, $wmAlignX, $wmAlignY, $wmSelect, $dissolve) =
> getRequestVar(array('wmName', 'wmAlign', 'wmAlignX', 'wmAlignY', 'wmSelect', 'dissolve'));
63c63,64
< isset($wmSelect) ? $wmSelect : 0
---
> isset($wmSelect) ? $wmSelect : 0,
> isset($dissolve) ? $dissolve : 0
77c78,80
< isset($previewFull) ? $previewFull : 0
---
> isset($previewFull) ? $previewFull : 0,
> '',
> ($dissolve > 0) ? $dissolve : 0
diff -r gallery/layout/watermarkform.inc ../gallery/layout/watermarkform.inc
33a34
> global $dissolve;
54a56,58
> if (!isset($dissolve)) {
> $dissolve = 0;
> }
145a150,152
> <tr>
> <td colspan=3>Dissolve %<input type="text" name="dissolve" value="<?php if ($dissolve>0) echo $dissolve; else echo 0; ?>" size=4 maxlength=3></td>
> </tr>
diff -r gallery/lib/imageManipulation.php ../gallery/lib/imageManipulation.php
177c177
< function watermark_image($src, $dest, $wmName, $wmAlphaName, $wmAlign, $wmAlignX, $wmAlignY) {
---
> function watermark_image($src, $dest, $wmName, $wmAlphaName, $wmAlign, $wmAlignX, $wmAlignY, $dissolve) {
316c316
< $srcOperator = "-geometry +$wmAlignX+$wmAlignY $overlayFile";
---
> $srcOperator = "-geometry +$wmAlignX+$wmAlignY -dissolve $dissolve $overlayFile";
diff -r gallery/watermark_album.php ../gallery/watermark_album.php
36,37c36,37
< list($index, $save, $preview, $wmAlign, $wmName, $wmSelect) =
< getRequestVar(array('index', 'save', 'preview', 'wmAlign', 'wmName', 'wmSelect'));
---
> list($index, $save, $preview, $wmAlign, $wmName, $wmSelect, $dissolve) =
> getRequestVar(array('index', 'save', 'preview', 'wmAlign', 'wmName', 'wmSelect', 'dissolve'));
77c77,78
< $wmSelect
---
> $wmSelect,
> $dissolve
97,98c98,102
< isset($previewFull) ? $previewFull : 0);
< }
---
> isset($previewFull) ? $previewFull : 0,
> '',
> ($dissolve > 0) ? $dissolve : 0
> );
> }
This was a quick/simple hack, and it works, but Im not guaranteeing this will not open you up to some mailicious buffer overflow in the ImageMagick -dissolve option (should probably check the value the form comes back with).
Posts: 6818
Can you make a unified diff please ?
Also a good idea is to upload this into the patch tracker.
Assign it to me (JensT)
Jens
--
Last Gallery v1 Developer and v1 translation manager.
Posts: 5
done:
Same diff, this time with -u, only changes reflected are those for this mod, diff is against stock downloaded 1.5.4. Does not have the NetPBM fix I suggested, but can be easily added, just edit line 321 of lib/imageManipulation.php (after applying the diff) and add -opacity=($dissolve/100) to the value of $args (still untested though). I will also upload to the tracker as you requested...