MAIS

    Colocando marca d’água nas imagens

    - Anúncio -
    - Anúncio -

     

     

    Para quem quiser colocar uma marca d’água nas imagens para evitar que sejam copiadas segue o tutorial.
    **lembrando que é sempre bom fazer um backup dos arquivos existentes**

    Testado na versão 1.5.3

    1- criar o arquivo watermark.png e colocar na pasta image/

    2- alterar o arquivo image.php -> system/library/image.php
    localizar o código abaixo : linhas 93 a 121

    public function watermark($file, $position = 'bottomright') {
                    $watermark = $this->create($file);
                   
                    $watermark_width = imagesx($watermark);
                    $watermark_height = imagesy($watermark);
                   
                    switch($position) {
                        case 'topleft':
                            $watermark_pos_x = 0;
                            $watermark_pos_y = 0;
                            break;
                        case 'topright':
                            $watermark_pos_x = $this->info['width'] - $watermark_width;
                            $watermark_pos_y = 0;
                            break;
                        case 'bottomleft':
                            $watermark_pos_x = 0;
                            $watermark_pos_y = $this->info['height'] - $watermark_height;
                            break;
                        case 'bottomright':
                            $watermark_pos_x = $this->info['width'] - $watermark_width;
                            $watermark_pos_y = $this->info['height'] - $watermark_height;
                            break;
                    }
                   
                    imagecopy($this->image, $watermark, $watermark_pos_x, $watermark_pos_y, 0, 0, 120, 40);
                   
                    imagedestroy($watermark);
                }

    e alterar por este:

            public function watermark($file, $position = 'bottomright') {
               
             
               $watermark = imagecreatefrompng($file);
                   
                    $watermark_width  = imagesx($watermark);
                    $watermark_height = imagesy($watermark);
                    
    switch($position) {
                        case 'topleft':
                            $watermark_pos_x = 0;
                            $watermark_pos_y = 0;
                            break;
                        case 'topright':
                            $watermark_pos_x = $this->info['width'] - $watermark_width;
                            $watermark_pos_y = 0;
                            break;
                        case 'bottomleft':
                            $watermark_pos_x = 0;
                            $watermark_pos_y = $this->info['height'] - $watermark_height;
                            break;
                        case 'bottomright':
                            $watermark_pos_x = $this->info['width'] - $watermark_width;
                            $watermark_pos_y = $this->info['height'] - $watermark_height;
                            break;
                     case 'center':
                        $watermark_pos_x = ($this->info['width']- $watermark_width)/2;
                        $watermark_pos_y = ($this->info['height']- $watermark_height)/2;
                        break;
                    }
                   
                    imagecopy($this->image, $watermark, $watermark_pos_x, $watermark_pos_y, 0, 0, $watermark_width, $watermark_height);
                   
                    imagedestroy($watermark);
                }

    3- Alterar o arquivo catalog/model/tool/image.php

    Localizar a linha:

            $image = new Image(DIR_IMAGE . $old_image);

    e logo abaixo acrescentar:

            if (($width > 400 || $height > 300) AND (strpos($old_image,"slide") === FALSE)) {   
           $image->watermark(DIR_IMAGE . 'watermark.png', 'center');
        }

    4- excluir os arquivos que estão em cache
    image/cache/data/ “deletar todas as pastas aqui”

    isso ira criar novos arquivos com a marca d’água, agora só atualizar seu site e testar.

     

     

     

    - Anúncio -

    Artigos recentes

    Continue lendo

    DEIXE UMA RESPOSTA

    Please enter your comment!
    Please enter your name here