Changeset 12956


Ignore:
Timestamp:
Jan 24, 2012, 10:50:47 PM (12 years ago)
Author:
rvelices
Message:

feature 2548 multisize - watermark for imagick extension

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/image.class.php

    r12922 r12956  
    4242
    4343  function resize($width, $height);
    44  
     44
    4545  function sharpen($amount);
    46  
     46
    4747  function compose($overlay, $x, $y, $opacity);
    4848
     
    9797  {
    9898    $starttime = get_moment();
    99    
     99
    100100    // width/height
    101101    $source_width  = $this->image->get_width();
     
    119119
    120120    $this->image->set_compression_quality($quality);
    121    
     121
    122122    if ($strip_metadata)
    123123    {
     
    130130      $this->image->crop($resize_dimensions['crop']['width'], $resize_dimensions['crop']['height'], $resize_dimensions['crop']['x'], $resize_dimensions['crop']['y']);
    131131    }
    132    
     132
    133133    $this->image->resize($resize_dimensions['width'], $resize_dimensions['height']);
    134134
     
    183183      }
    184184    }
    185    
     185
    186186    $ratio_width  = $width / $max_width;
    187187    $ratio_height = $height / $max_height;
    188     $destination_width = $width; 
     188    $destination_width = $width;
    189189    $destination_height = $height;
    190    
     190
    191191    // maximal size exceeded ?
    192192    if ($ratio_width > 1 or $ratio_height > 1)
    193193    {
    194194      if ($ratio_width < $ratio_height)
    195       { 
     195      {
    196196        $destination_width = round($width / $ratio_height);
    197197        $destination_height = $max_height;
    198198      }
    199199      else
    200       { 
    201         $destination_width = $max_width; 
     200      {
     201        $destination_width = $max_width;
    202202        $destination_height = round($height / $ratio_width);
    203203      }
     
    233233      return null;
    234234    }
    235    
     235
    236236    if (!function_exists('exif_read_data'))
    237237    {
     
    240240
    241241    $rotation = null;
    242    
     242
    243243    $exif = exif_read_data($source_filepath);
    244    
     244
    245245    if (isset($exif['Orientation']) and preg_match('/^\s*(\d)/', $exif['Orientation'], $matches))
    246246    {
     
    275275                        array(-1,   -1,    -1),
    276276                );
    277    
     277
    278278    $norm = array_sum(array_map('array_sum', $matrix));
    279279
     
    432432                return  $this->image->convolveImage($m);
    433433  }
    434  
     434
    435435  function compose($overlay, $x, $y, $opacity)
    436436  {
    437     // todo
    438     return false;
     437    $ioverlay = $overlay->image->image;
     438    /*if ($ioverlay->getImageAlphaChannel() !== Imagick::ALPHACHANNEL_OPAQUE)
     439    {
     440      // Force the image to have an alpha channel
     441      $ioverlay->setImageAlphaChannel(Imagick::ALPHACHANNEL_OPAQUE);
     442    }*/
     443
     444    global $dirty_trick_xrepeat;
     445    if ( !isset($dirty_trick_xrepeat) && $opacity < 100)
     446    {// NOTE: Using setImageOpacity will destroy current alpha channels!
     447      $ioverlay->evaluateImage(Imagick::EVALUATE_MULTIPLY, $opacity / 100, Imagick::CHANNEL_ALPHA);
     448      $dirty_trick_xrepeat = true;
     449    }
     450
     451    return $this->image->compositeImage($ioverlay, Imagick::COMPOSITE_DISSOLVE, $x, $y);
    439452  }
    440453
     
    525538  {
    526539    $m = pwg_image::get_sharpen_matrix($amount);
    527    
     540
    528541    $param ='convolve "'.count($m).':';
    529542    foreach ($m as $line)
     
    536549    return true;
    537550  }
    538  
     551
    539552  function compose($overlay, $x, $y, $opacity)
    540553  {
     
    564577    $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"';
    565578    @exec($exec, $returnarray);
    566    
     579
    567580    //echo($exec);
    568581    return is_array($returnarray);
     
    686699                return imageconvolution($this->image, $m, 1, 0);
    687700  }
    688  
     701
    689702  function compose($overlay, $x, $y, $opacity)
    690703  {
     
    695708    $ow = imagesx($ioverlay);
    696709    $oh = imagesy($ioverlay);
    697      
     710
    698711                // Create a new blank image the site of our source image
    699712                $cut = imagecreatetruecolor($ow, $oh);
Note: See TracChangeset for help on using the changeset viewer.