Watermarker [Deleted]

  • Thread starter Thread starter Deleted member 232995
  • Start date Start date
Can you add a new variable option {currentusername}?



Some time it’s very useful to add a watermark to check which user download and share a photo. You can check, if is a login user to add {currentusername} else board name or empty.

Thanks for yours great add-on.
Why is "{username}" not enough?
 
Of course this is feasible! The only problem is that this is a variable that changes with every view of another user. What makes the caching (which could be used) obsolete.
But the sense of this is clear to me and I think it makes sense. Therefore I will implement. But that there is then no caching must be clear.
 
Of course this is feasible! The only problem is that this is a variable that changes with every view of another user. What makes the caching (which could be used) obsolete.
But the sense of this is clear to me and I think it makes sense. Therefore I will implement. But that there is then no caching must be clear.
Thank you very much, I have a small forum of about 150 users where I have technical drawings only for registered users. The forum only allows new users with an invitation because I want to avoid leaks of these technical drawings. One watermark per user would help me protect my work.
 
X0815\Watermarker\Marker::__construct()

PHP:
@ini_set('gd.jpeg_ignore_warning', 1);

$this->attachment = $attachment;
$this->attachmentData = $attachment->Data;
$this->attachRepo = $this->getAttachmentRepo();
$this->_options = \XF::options();


$this->font = \XF::getRootDirectory() . $this->font;
if(!empty($this->_options['watermarkerType']['font_path']))
{
    $this->font = \XF::getRootDirectory() . $this->_options['watermarkerType']['font_path'];
}

if(!$this->_options['watermarkerType']['enabled_image'] && !$this->_options['watermarkerType']['enabled_text'])
{
    return false;
}

$this->outputImage = $this->attachmentData->getAbstractedWatermarkerDataPath();

if(\XF::fs()->has($this->outputImage))
{
    $simpleCache = \XF::app()->simpleCache();
    $lastSettingsChange = $simpleCache->getValue('X0815\Watermarker', 'lastSettingsChange');

    $fileAge = \XF::fs()->getTimestamp($this->outputImage);

    if(
        \XF::options()->watermarkerCacheRefresh != 0 &&
        ($fileAge >= $lastSettingsChange) &&
        ($fileAge > \XF::$time - (\XF::options()->watermarkerCacheRefresh * 86400))
    )
    {
        $this->status = true;
    }
}

$tempFile = \XF\Util\File::getTempFile();
$stream = \XF::fs()->readStream($this->attachmentData->getAbstractedDataPath());

@file_put_contents($tempFile, $stream, FILE_APPEND | LOCK_EX);

$this->inputImage = $tempFile;

if($this->status)
{
    return false;
}

I am not 100% sure, but I think this might cause unnecessary overhead:
if $this->status is true, the watermarker image does exist and is valid - there is no need to prepare processing.
Hence the input file is not required and the copy to a temporary file seems useless.

Probably better approach:
PHP:
if(!$this->_options['watermarkerType']['enabled_image'] && !$this->_options['watermarkerType']['enabled_text'])
{
    return false;
}

$this->outputImage = $this->attachmentData->getAbstractedWatermarkerDataPath();

if (\XF::fs()->has($this->outputImage))
{
    $simpleCache = \XF::app()->simpleCache();
    $lastSettingsChange = $simpleCache->getValue('X0815\Watermarker', 'lastSettingsChange');

    $fileAge = \XF::fs()->getTimestamp($this->outputImage);

    if(
        \XF::options()->watermarkerCacheRefresh != 0 &&
        ($fileAge >= $lastSettingsChange) &&
        ($fileAge > \XF::$time - (\XF::options()->watermarkerCacheRefresh * 86400))
    )
    {
        $this->status = true;
    }
}

if ($this->status)
{
    return false;
}

@ini_set('gd.jpeg_ignore_warning', 1);

$this->attachment = $attachment;
$this->attachmentData = $attachment->Data;
$this->attachRepo = $this->getAttachmentRepo();
$this->_options = \XF::options();

$this->font = \XF::getRootDirectory() . $this->font;
if(!empty($this->_options['watermarkerType']['font_path']))
{
    $this->font = \XF::getRootDirectory() . $this->_options['watermarkerType']['font_path'];
}

$this->inputImage = \XF:\Util\File::copyAbstractedPathToTempFile($this->attachmentData->getAbstractedDataPath());

Another possible problem:
It seems like X0815\Watermarker\Cron::dailyClean() (which calls \X0815\Watermarker\Marker\Water::removeOldWatermarksImages()) directly performs file operations on internal_data - this violates resource standards rule # 29.
 
Another possible problem:
It seems like X0815\Watermarker\Cron::dailyClean() (which calls \X0815\Watermarker\Marker\Water::removeOldWatermarksImages()) directly performs file operations on internal_data - this violates resource standards rule # 29.
I just changed this completely and adjusted it accordingly. Thanks


I am not 100% sure, but I think this might cause unnecessary overhead:
Thank you this is known to me and would be changed by the new wish anyway! Here I will improve! THANKS
 
Hi, is there a way to display the {uploadDate} as 10.11.2020 format instead of "10 November 2020 at 8:03 PM" as the latter takes up a lot of unnecessary image space? :)
 
0815 updated Watermarker with a new update entry:

1.1.0 Beta 1

Some optimizations have been made. Thanks @Kirby

Added the possibility to create watermarks (image/text) per groups incl. the prioritization of the groups. (This disables caching)

Added new Varibale {visitorUsername} To tag the image with the name of the user who downloaded it. (This disables caching)



Since there have been massive changes, I would be happy if you test these new options extensively. I am happy to receive your sent bugs/ideas.

Read the rest of this update entry...


watermarker_settings1.webp
 
Some server errors en Beta 8.

Code:
Call to a member function getCachedStatus() on null
src/addons/X0815/Watermarker/XF/Pub/View/Attachment/View.php:16
[E_NOTICE] Undefined index: watermarker
src/addons/X0815/Watermarker/XF/Pub/View/Attachment/View.php:13
 
Some server errors en Beta 8.

Code:
Call to a member function getCachedStatus() on null
src/addons/X0815/Watermarker/XF/Pub/View/Attachment/View.php:16
[E_NOTICE] Undefined index: watermarker
src/addons/X0815/Watermarker/XF/Pub/View/Attachment/View.php:13
New version online!


{visitorUsername} not work, show {username}.
works for me
 
See video - no problems
I check again and again, but I think something is wrong. If user_1 go to a post see the watermarker "user_1" but if the user_2 go to same post also see "user_1" watermarker. And if the "user_2" go to the other post before then "user_1" or any user, everybody see watermarker "user_2".
 
OK thanks for the detailed report! I will try to reproduce it here tomorrow.
 
Hi, thank you for updating the add-on's features.

The options look perfect and as requested.

However, I can get a watermark to show up while using the "Watermark normal for all" setting, but whenever I attempt to replicate the same options on the different user groups the watermarks are not showing up.

I will continue testing, but so far I cannot work out what the add-on (or myself) is doing wrong... :)
 
For {visitorUsername} I thing the server cache img_001 when user_1 see and when user_2 see the img_001 server show cached img_001.
 
Top Bottom