1
karomaz
Is there a module to add a small logo of my site on the images of my articles?
  • 2011/12/10 8:39

  • karomaz

  • Just popping in

  • Posts: 21

  • Since: 2011/10/8


hi,

I want to know if there is a module so that my members can add images in the articles directly from their computer and not from an external link.

I also want to know if there is a module to add a logo to my website on the images of my articles to protect them (an watermark)


and thank you in advance ...

2
Anonymous
Re: Is there a module to add a small logo of my site on the images of my articles?
  • 2011/12/10 11:18

  • Anonymous

  • Posts: 0

  • Since:


The module extgallery has an option for automatically adding watermarks to uploaded pictures. But cannot be used to upload pictures directly from a content module...

3
wishcraft
Re: Is there a module to add a small logo of my site on the images of my articles?

I made a thing called 'random.jpg' for outputting information. The HTACCESS looks like:

RewriteEngine On
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d

RewriteRule 
^random.jpg index.php  [L,NC,QSA]


The PHP for index.php which you would have to modify this code so you could do for example yoursite.com/images/watermark.jpg?image=/uploads/smartsection/yourimage.jpg to watermark the image. IT is using the framework WideImage to do its internal processes.

<?php
@include ('../../mainfile.php');
@include 
$GLOBALS['xoops']->path('/Frameworks/wideimage/WideImage.php');
$GLOBALS['xoopsLogger']->activated false;
$dir XOOPS_VAR_PATH."/images/erotica/";
$watermarkdir XOOPS_VAR_PATH."/images/watermarks/erotica/";

$image = array();
if (
is_dir($dir)) {
    if (
$dh opendir($dir)) {
        while ((
$file readdir($dh)) !== false) {
            if (
strpos(strtolower($file),".jpg")>0||strpos(strtolower($file),".gif")>0||strpos(strtolower($file),".png")>0)
            {
                
$image[] = $file;
            }
        }
        
closedir($dh);
    }
}

$watermarks = array();
if (
is_dir($watermarkdir)) {
    if (
$dh opendir($watermarkdir)) {
        while ((
$file readdir($dh)) !== false) {
            if (
strpos(strtolower($file),".jpg")>0||strpos(strtolower($file),".gif")>0||strpos(strtolower($file),".png")>0)
            {
                
$watermarks[] = $file;
            }
        }
        
closedir($dh);
    }
}
if (
sizeof($image)>0)
{
    
srand((((float)('0' substr(microtime(), strpos(microtime(), ' ') + 1strlen(microtime()) - strpos(microtime(), ' ') + 1))) * mt_rand(3099999)));
    
srand((((float)('0' substr(microtime(), strpos(microtime(), ' ') + 1strlen(microtime()) - strpos(microtime(), ' ') + 1))) * mt_rand(3099999)));
        
    if (
sizeof($watermarks)>0) {
        
$which mt_rand(0,sizeof($image)-1);
        
$water mt_rand(0,sizeof($watermarks)-1);
        
error_reporting(E_ALL);
        
$img WideImage::load($dir.$image[$which]);
        
$watermark WideImage::load($watermarkdir.$watermarks[$water]);
        
$wwidth $watermark->getWidth();
        
$wheight $watermark->getHeight();
        if (isset(
$_GET['resize'])) {
            
$resizeimg $img->resize(intval($_GET['resize']).'%');
            
$resizeimg->output("JPG");
        } elseif (isset(
$_GET['width'])&&isset($_GET['height'])) {
            
$width $img->getWidth();
            
$height $img->getHeight();
            if (
$width>$height) {
                
$resizeimg $img->resize(NULL,intval($_GET['height']),'inside''down')->crop("center""middle"intval($_GET['width']), intval($_GET['height']));
                
$imgb $resizeimg->merge($watermarksprintf("right - %s"$wwidth*(1/5)), sprintf("bottom - %s"$wheight*(1/5)), 75);
            } else {
                if (
$width>intval($_GET['width'])&&$height>intval($_GET['height'])) {
                    
$resizeimg $img->resize(intval($_GET['width']),intval($_GET['height']),'inside''down');
                    
$imgb $resizeimg->merge($watermarksprintf("left + %s"mt_rand(5,25)), sprintf("top + %s"mt_rand(9,35)), 75);
                } else {
                    
$resizeimg $img->resize(intval($_GET['width']),intval($_GET['height']),'inside''up');
                    
$imgb $resizeimg->merge($watermarksprintf("left + %s"mt_rand(5,25)), sprintf("top + %s"mt_rand(9,35)), 75);
                }
            }
            
$imgb->output("JPG");
            exit(
0);
        } elseif (isset(
$_GET['width'])) {
            
$width $img->getWidth();
            
$height $img->getHeight();
            if (
$width>$height) {
                
$resizeimg $img->resize(NULL,$height* (intval($_GET['width'])/$width),'inside''down')->crop("center""middle"intval($_GET['width']), intval($_GET['height']));
                
$imgb $resizeimg->merge($watermarksprintf("right - %s"$wwidth*(1/5)), sprintf("bottom - %s"$wheight*(1/5)), 75);
            } else {
                if (
$width>intval($_GET['width'])) {
                    
$resizeimg $img->resize(intval($_GET['width']),NULL,'inside''down');
                    
$imgb $resizeimg->merge($watermarksprintf("left - %s"mt_rand(5,25)), sprintf("top + %s"mt_rand(9,35)), 75);
                } else {
                    
$resizeimg $img->resize(intval($_GET['width']),NULL,'inside''up');
                    
$imgb $resizeimg->merge($watermarksprintf("left + %s"mt_rand(5,25)), sprintf("top + %s"mt_rand(9,35)), 75);
                }
            }
            
$imgb->output("JPG");
            exit(
0);
        } elseif (isset(
$_GET['height'])) {
            
$width $img->getWidth();
            
$height $img->getHeight();
            if (
$width>$height) {
                
$resizeimg $img->resize($width* (intval($_GET['height'])/$height),NULL,'inside''down')->crop("center""middle"intval($_GET['width']), intval($_GET['height']));
                
$imgb $resizeimg->merge($watermarksprintf("right - %s"$wwidth*(1/5)), sprintf("bottom - %s"$wheight*(1/5)), 75);
            } else {
                if (
$height>intval($_GET['height'])) {
                    
$resizeimg $img->resize(NULL,intval($_GET['height']),'inside''down');
                    
$imgb $resizeimg->merge($watermarksprintf("left + %s"mt_rand(5,25)), sprintf("top + %s"mt_rand(9,35)), 75);
                } else {
                    
$resizeimg $img->resize(NULL,intval($_GET['height']),'inside''up');
                    
$imgb $resizeimg->merge($watermarksprintf("left + %s"mt_rand(5,25)), sprintf("top + %s"mt_rand(9,35)), 75);
                }
            }
            
$imgb->output("JPG");
            exit(
0);            
        }
        
$img->output("JPG");
    } else {
        
$which mt_rand(0,sizeof($image));
        
$img WideImage::load($dir.$image[$which]);
        if (isset(
$_GET['resize'])) {
            
$resizeimg $img->resize(intval($_GET['resize']).'%');
            
$resizeimg->output("JPG");
        } elseif (isset(
$_GET['width'])&&isset($_GET['height'])) {
            
$width $img->getWidth();
            
$height $img->getHeight();
            if (
$width>$height) {
                
$resizeimg $img->resize(NULL,intval($_GET['height']),'inside''down')->crop("center""middle"intval($_GET['width']), intval($_GET['height']));
            } else {
                if (
$width>intval($_GET['width'])&&$height>intval($_GET['height'])) {
                    
$resizeimg $img->resize(intval($_GET['width']),intval($_GET['height']),'inside''down');
                } else {
                    
$resizeimg $img->resize(intval($_GET['width']),intval($_GET['height']),'inside''up');
                }
            }
            
$resizeimg->output("JPG");
            exit(
0);
        } elseif (isset(
$_GET['width'])) {
            
$width $img->getWidth();
            
$height $img->getHeight();
            if (
$width>$height) {
                
$resizeimg $img->resize(NULL,$height* (intval($_GET['width'])/$width),'inside''down')->crop("center""middle"intval($_GET['width']), intval($_GET['height']));
            } else {
                if (
$width>intval($_GET['width'])) {
                    
$resizeimg $img->resize(intval($_GET['width']),NULL,'inside''down');
                } else {
                    
$resizeimg $img->resize(intval($_GET['width']),NULL,'inside''up');
                }
            }
            
$resizeimg->output("JPG");
            exit(
0);
        } elseif (isset(
$_GET['height'])) {
            
$width $img->getWidth();
            
$height $img->getHeight();
            if (
$width>$height) {
                
$resizeimg $img->resize($width* (intval($_GET['height'])/$height),NULL,'inside''down')->crop("center""middle"intval($_GET['width']), intval($_GET['height']));
            } else {
                if (
$height>intval($_GET['height'])) {
                    
$resizeimg $img->resize(NULL,intval($_GET['height']),'inside''down');
                } else {
                    
$resizeimg $img->resize(NULL,intval($_GET['height']),'inside''up');
                }
            }
            
$resizeimg->output("JPG");
            exit(
0);            
        }
        
$img->output("JPG");
    }
    exit(
0);
}
?>


This would probably be the best way of watermarking your images is to have a path you call for it.
Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

Login

Who's Online

149 user(s) are online (99 user(s) are browsing Support Forums)


Members: 0


Guests: 149


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits