当前位置: 首页>>代码示例>>PHP>>正文


PHP imagick::contrastImage方法代码示例

本文整理汇总了PHP中imagick::contrastImage方法的典型用法代码示例。如果您正苦于以下问题:PHP imagick::contrastImage方法的具体用法?PHP imagick::contrastImage怎么用?PHP imagick::contrastImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在imagick的用法示例。


在下文中一共展示了imagick::contrastImage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createTmb

 protected function createTmb($vd6fe1d0be6347b8ef2427fa629c04485)
 {
     $vd02a169f33469c888396a24dd9d9f1c6 = $this->mimetype($vd6fe1d0be6347b8ef2427fa629c04485);
     if (!$this->canCreateTmb($vd6fe1d0be6347b8ef2427fa629c04485, $vd02a169f33469c888396a24dd9d9f1c6)) {
         return false;
     }
     $vb068931cc450442b63f5b3d276ea4297 = $this->tmbName($vd6fe1d0be6347b8ef2427fa629c04485);
     $va8b687c2e93191d90a6d7b8982ceec4a = $this->tmbPath . DIRECTORY_SEPARATOR . $vb068931cc450442b63f5b3d276ea4297;
     if (($v25d902c24283ab8cfbac54dfa101ad31 = $this->_fopen($vd6fe1d0be6347b8ef2427fa629c04485, 'rb')) == false || ($v90710761341352a9e144d8ad4c92598b = @fopen($va8b687c2e93191d90a6d7b8982ceec4a, 'wb')) == false) {
         return false;
     }
     while (!feof($v25d902c24283ab8cfbac54dfa101ad31)) {
         fwrite($v90710761341352a9e144d8ad4c92598b, fread($v25d902c24283ab8cfbac54dfa101ad31, 8192));
     }
     $this->_fclose($v25d902c24283ab8cfbac54dfa101ad31, $vd6fe1d0be6347b8ef2427fa629c04485);
     fclose($v90710761341352a9e144d8ad4c92598b);
     if (($v03c7c0ace395d80182db07ae2c30f034 = @getimagesize($va8b687c2e93191d90a6d7b8982ceec4a)) == false) {
         return false;
     }
     $result = false;
     $v88029fd68f54ae31758f44d7b965868f = $this->tmbSize;
     list($v9dd4e461268c8034f5c8564e155c67a6, $v415290769594460e2e485922904f345d, $v84b16781293d33e80d74ef9d63280bc0, $v55fc30b57cc1b80e8f68104931fbf716) = $this->tmbEffects($v03c7c0ace395d80182db07ae2c30f034[0], $v03c7c0ace395d80182db07ae2c30f034[1], $v88029fd68f54ae31758f44d7b965868f, $this->options['tmbCrop']);
     switch ($this->imgLib) {
         case 'imagick':
             try {
                 $vb798abe6e1b1318ee36b0dcb3fb9e4d3 = new imagick($va8b687c2e93191d90a6d7b8982ceec4a);
             } catch (Exception $ve1671797c52e15f763380b45e841ec32) {
                 return false;
             }
             $vb798abe6e1b1318ee36b0dcb3fb9e4d3->contrastImage(1);
             if ($this->options['tmbCrop'] == false) {
                 $va8a63b4d63a08aed720d0f5f249e07d9 = new Imagick();
                 $va8a63b4d63a08aed720d0f5f249e07d9->newImage($v88029fd68f54ae31758f44d7b965868f, $v88029fd68f54ae31758f44d7b965868f, new ImagickPixel($this->options['tmbBgColor']));
                 $va8a63b4d63a08aed720d0f5f249e07d9->setImageFormat('png');
                 $vb798abe6e1b1318ee36b0dcb3fb9e4d3->resizeImage($v84b16781293d33e80d74ef9d63280bc0, $v55fc30b57cc1b80e8f68104931fbf716, NULL, true);
                 $va8a63b4d63a08aed720d0f5f249e07d9->compositeImage($vb798abe6e1b1318ee36b0dcb3fb9e4d3, imagick::COMPOSITE_OVER, $v9dd4e461268c8034f5c8564e155c67a6, $v415290769594460e2e485922904f345d);
                 $result = $va8a63b4d63a08aed720d0f5f249e07d9->writeImage($va8b687c2e93191d90a6d7b8982ceec4a);
             } else {
                 $result = $vb798abe6e1b1318ee36b0dcb3fb9e4d3->cropThumbnailImage($v88029fd68f54ae31758f44d7b965868f, $v88029fd68f54ae31758f44d7b965868f) && $vb798abe6e1b1318ee36b0dcb3fb9e4d3->writeImage($va8b687c2e93191d90a6d7b8982ceec4a);
             }
             break;
         case 'gd':
             if ($v03c7c0ace395d80182db07ae2c30f034['mime'] == 'image/jpeg') {
                 $vb798abe6e1b1318ee36b0dcb3fb9e4d3 = imagecreatefromjpeg($va8b687c2e93191d90a6d7b8982ceec4a);
             } elseif ($v03c7c0ace395d80182db07ae2c30f034['mime'] == 'image/png') {
                 $vb798abe6e1b1318ee36b0dcb3fb9e4d3 = imagecreatefrompng($va8b687c2e93191d90a6d7b8982ceec4a);
             } elseif ($v03c7c0ace395d80182db07ae2c30f034['mime'] == 'image/gif') {
                 $vb798abe6e1b1318ee36b0dcb3fb9e4d3 = imagecreatefromgif($va8b687c2e93191d90a6d7b8982ceec4a);
             } elseif ($v03c7c0ace395d80182db07ae2c30f034['mime'] == 'image/xbm') {
                 $vb798abe6e1b1318ee36b0dcb3fb9e4d3 = imagecreatefromxbm($va8b687c2e93191d90a6d7b8982ceec4a);
             }
             if (isset($vb798abe6e1b1318ee36b0dcb3fb9e4d3) && $vb798abe6e1b1318ee36b0dcb3fb9e4d3 && false != ($vfa816edb83e95bf0c8da580bdfd491ef = imagecreatetruecolor($v88029fd68f54ae31758f44d7b965868f, $v88029fd68f54ae31758f44d7b965868f))) {
                 if ($this->options['tmbCrop'] == false) {
                     if ($this->options['tmbBgColor'] == 'transparent') {
                         list($v4b43b0aee35624cd95b910189b3dc231, $vb2f5ff47436671b6e533d8dc3614845d, $v92eb5ffee6ae2fec3ad71c777531578f) = array(0, 0, 255);
                     } else {
                         list($v4b43b0aee35624cd95b910189b3dc231, $vb2f5ff47436671b6e533d8dc3614845d, $v92eb5ffee6ae2fec3ad71c777531578f) = sscanf($this->options['tmbBgColor'], "#%02x%02x%02x");
                     }
                     $ve12224dadfacf7a79886df59f202a403 = imagecolorallocate($vfa816edb83e95bf0c8da580bdfd491ef, $v4b43b0aee35624cd95b910189b3dc231, $vb2f5ff47436671b6e533d8dc3614845d, $v92eb5ffee6ae2fec3ad71c777531578f);
                     if ($this->options['tmbBgColor'] == 'transparent') {
                         $ve12224dadfacf7a79886df59f202a403 = imagecolortransparent($vfa816edb83e95bf0c8da580bdfd491ef, $ve12224dadfacf7a79886df59f202a403);
                     }
                     imagefill($vfa816edb83e95bf0c8da580bdfd491ef, 0, 0, $ve12224dadfacf7a79886df59f202a403);
                     if (!imagecopyresampled($vfa816edb83e95bf0c8da580bdfd491ef, $vb798abe6e1b1318ee36b0dcb3fb9e4d3, $v9dd4e461268c8034f5c8564e155c67a6, $v415290769594460e2e485922904f345d, 0, 0, $v84b16781293d33e80d74ef9d63280bc0, $v55fc30b57cc1b80e8f68104931fbf716, $v03c7c0ace395d80182db07ae2c30f034[0], $v03c7c0ace395d80182db07ae2c30f034[1])) {
                         return false;
                     }
                 } else {
                     if (!imagecopyresampled($vfa816edb83e95bf0c8da580bdfd491ef, $vb798abe6e1b1318ee36b0dcb3fb9e4d3, 0, 0, $v9dd4e461268c8034f5c8564e155c67a6, $v415290769594460e2e485922904f345d, $v88029fd68f54ae31758f44d7b965868f, $v88029fd68f54ae31758f44d7b965868f, $v84b16781293d33e80d74ef9d63280bc0, $v55fc30b57cc1b80e8f68104931fbf716)) {
                         return false;
                     }
                 }
                 $result = imagepng($vfa816edb83e95bf0c8da580bdfd491ef, $va8b687c2e93191d90a6d7b8982ceec4a, 7);
                 imagedestroy($vb798abe6e1b1318ee36b0dcb3fb9e4d3);
                 imagedestroy($vfa816edb83e95bf0c8da580bdfd491ef);
             }
             break;
     }
     return $result ? $vb068931cc450442b63f5b3d276ea4297 : false;
 }
开发者ID:BGCX261,项目名称:zimmerli-svn-to-git,代码行数:79,代码来源:elFinderVolumeDriver.class.php

示例2: _tmb

 /**
  * Create image thumbnail
  *
  * @param  string  $img  image file
  * @param  string  $tmb  thumbnail name
  * @return bool
  **/
 protected function _tmb($img, $tmb)
 {
     if (false == ($s = getimagesize($img))) {
         return false;
     }
     $tmbSize = $this->_options['tmbSize'];
     if ($this->_options['tmbCrop'] == false) {
         /* Calculating image scale width and height */
         $xscale = $s[0] / $tmbSize;
         $yscale = $s[1] / $tmbSize;
         if ($yscale > $xscale) {
             $newwidth = round($s[0] * (1 / $yscale));
             $newheight = round($s[1] * (1 / $yscale));
         } else {
             $newwidth = round($s[0] * (1 / $xscale));
             $newheight = round($s[1] * (1 / $xscale));
         }
         /* Keeping original dimensions if image fitting into thumbnail without scale */
         if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
             $newwidth = $s[0];
             $newheight = $s[1];
         }
         /* Calculating coordinates for aligning thumbnail */
         $align_y = ceil(($tmbSize - $newheight) / 2);
         $align_x = ceil(($tmbSize - $newwidth) / 2);
     }
     switch ($this->_options['imgLib']) {
         case 'imagick':
             try {
                 $_img = new imagick($img);
             } catch (Exception $e) {
                 return false;
             }
             $_img->contrastImage(1);
             if ($this->_options['tmbCrop'] == false) {
                 $img1 = new Imagick();
                 $img1->newImage($tmbSize, $tmbSize, new ImagickPixel($this->_options['tmbBgColor']));
                 $img1->setImageFormat('png');
                 $_img->resizeImage($newwidth, $newheight, NULL, true);
                 $img1->compositeImage($_img, imagick::COMPOSITE_OVER, $align_x, $align_y);
                 return $img1->writeImage($tmb);
             } else {
                 return $_img->cropThumbnailImage($tmbSize, $tmbSize) && $_img->writeImage($tmb);
             }
             break;
         case 'mogrify':
             if (@copy($img, $tmb)) {
                 list($x, $y, $size) = $this->_cropPos($s[0], $s[1]);
                 // exec('mogrify -crop '.$size.'x'.$size.'+'.$x.'+'.$y.' -scale '.$tmbSize.'x'.$tmbSize.'! '.escapeshellarg($tmb), $o, $c);
                 $mogrifyArgs = 'mogrify -resize ' . $tmbSize . 'x' . $tmbSize;
                 if ($this->_options['tmbCrop'] == false) {
                     $mogrifyArgs .= ' -gravity center -background "' . $this->_options['tmbBgColor'] . '" -extent ' . $tmbSize . 'x' . $tmbSize;
                 }
                 if ($this->_options['tmbCrop'] == false) {
                     $mogrifyArgs .= ' ' . escapeshellarg($tmb);
                 }
                 exec($mogrifyArgs, $o, $c);
                 if (file_exists($tmb)) {
                     return true;
                 } elseif ($c == 0) {
                     // find tmb for psd and animated gif
                     $mime = $this->_mimetype($img);
                     if ($mime == 'image/vnd.adobe.photoshop' || ($mime = 'image/gif')) {
                         $pinfo = pathinfo($tmb);
                         $test = $pinfo['dirname'] . DIRECTORY_SEPARATOR . $pinfo['filename'] . '-0.' . $pinfo['extension'];
                         if (file_exists($test)) {
                             return rename($test, $tmb);
                         }
                     }
                 }
             }
             break;
         case 'gd':
             if ($s['mime'] == 'image/jpeg') {
                 $_img = imagecreatefromjpeg($img);
             } elseif ($s['mime'] == 'image/png') {
                 $_img = imagecreatefrompng($img);
             } elseif ($s['mime'] == 'image/gif') {
                 $_img = imagecreatefromgif($img);
             }
             if (!$_img || false == ($_tmb = imagecreatetruecolor($tmbSize, $tmbSize))) {
                 return false;
             }
             if ($this->_options['tmbCrop'] == false) {
                 list($r, $g, $b) = sscanf($this->_options['tmbBgColor'], "#%02x%02x%02x");
                 imagefill($_tmb, 0, 0, imagecolorallocate($_tmb, $r, $g, $b));
                 if (!imagecopyresampled($_tmb, $_img, $align_x, $align_y, 0, 0, $newwidth, $newheight, $s[0], $s[1])) {
                     return false;
                 }
             } else {
                 list($x, $y, $size) = $this->_cropPos($s[0], $s[1]);
                 if (!imagecopyresampled($_tmb, $_img, 0, 0, $x, $y, $tmbSize, $tmbSize, $size, $size)) {
                     return false;
//.........这里部分代码省略.........
开发者ID:hucongyang,项目名称:lulucms2,代码行数:101,代码来源:elFinder.class.php

示例3: _tmb

 /**
  * Create image thumbnail
  *
  * @param  string  $img  image file
  * @param  string  $tmb  thumbnail name
  * @return bool
  **/
 private function _tmb($img, $tmb)
 {
     if (false == ($s = getimagesize($img))) {
         return false;
     }
     $tmbSize = $this->_options['tmbSize'];
     switch ($this->_options['imgLib']) {
         case 'imagick':
             try {
                 $_img = new imagick($img);
             } catch (Exception $e) {
                 return false;
             }
             $_img->contrastImage(1);
             return $_img->cropThumbnailImage($tmbSize, $tmbSize) && $_img->writeImage($tmb);
             break;
         case 'mogrify':
             if (@copy($img, $tmb)) {
                 list($x, $y, $size) = $this->_cropPos($s[0], $s[1]);
                 // exec('mogrify -crop '.$size.'x'.$size.'+'.$x.'+'.$y.' -scale '.$tmbSize.'x'.$tmbSize.'! '.escapeshellarg($tmb), $o, $c);
                 exec('mogrify -resize ' . $tmbSize . 'x' . $tmbSize . '^ -gravity center -extent ' . $tmbSize . 'x' . $tmbSize . ' ' . escapeshellarg($tmb), $o, $c);
                 if (file_exists($tmb)) {
                     return true;
                 } elseif ($c == 0) {
                     // find tmb for psd and animated gif
                     $mime = $this->_mimetype($img);
                     if ($mime == 'image/vnd.adobe.photoshop' || ($mime = 'image/gif')) {
                         $pinfo = pathinfo($tmb);
                         $test = $pinfo['dirname'] . DIRECTORY_SEPARATOR . $pinfo['filename'] . '-0.' . $pinfo['extension'];
                         if (file_exists($test)) {
                             return rename($test, $tmb);
                         }
                     }
                 }
             }
             break;
         case 'gd':
             if ($s['mime'] == 'image/jpeg') {
                 $_img = imagecreatefromjpeg($img);
             } elseif ($s['mime'] == 'image/png') {
                 $_img = imagecreatefrompng($img);
             } elseif ($s['mime'] == 'image/gif') {
                 $_img = imagecreatefromgif($img);
             }
             if (!$_img || false == ($_tmb = imagecreatetruecolor($tmbSize, $tmbSize))) {
                 return false;
             }
             list($x, $y, $size) = $this->_cropPos($s[0], $s[1]);
             if (!imagecopyresampled($_tmb, $_img, 0, 0, $x, $y, $tmbSize, $tmbSize, $size, $size)) {
                 return false;
             }
             $r = imagepng($_tmb, $tmb, 7);
             imagedestroy($_img);
             imagedestroy($_tmb);
             return $r;
             break;
     }
 }
开发者ID:vitalya-xxx,项目名称:vitacod.ru,代码行数:65,代码来源:elFinder.class.php

示例4: createTmb

 /**
  * Create thumnbnail and return it's URL on success
  *
  * @param  string  $path  file path
  * @param  string  $mime  file mime type
  * @return string|false
  * @author Dmitry (dio) Levashov
  **/
 protected function createTmb($path)
 {
     $mime = $this->mimetype($path);
     if (!$this->canCreateTmb($path, $mime)) {
         return false;
     }
     $name = $this->tmbName($path);
     $tmb = $this->tmbPath . DIRECTORY_SEPARATOR . $name;
     // copy image in tmbPath so some drivers does not store files on local fs
     if (($src = $this->_fopen($path, 'rb')) == false || ($trg = @fopen($tmb, 'wb')) == false) {
         return false;
     }
     while (!feof($src)) {
         fwrite($trg, fread($src, 8192));
     }
     $this->_fclose($src, $path);
     fclose($trg);
     if (($s = @getimagesize($tmb)) == false) {
         return false;
     }
     $result = false;
     $tmbSize = $this->tmbSize;
     list($x, $y, $size_w, $size_h) = $this->tmbEffects($s[0], $s[1], $tmbSize, $this->options['tmbCrop']);
     switch ($this->imgLib) {
         case 'imagick':
             try {
                 $img = new imagick($tmb);
             } catch (Exception $e) {
                 return false;
             }
             $img->contrastImage(1);
             if ($this->options['tmbCrop'] == false) {
                 $img1 = new Imagick();
                 $img1->newImage($tmbSize, $tmbSize, new ImagickPixel($this->options['tmbBgColor']));
                 $img1->setImageFormat('png');
                 $img->resizeImage($size_w, $size_h, NULL, true);
                 $img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
                 $result = $img1->writeImage($tmb);
             } else {
                 $result = $img->cropThumbnailImage($tmbSize, $tmbSize) && $img->writeImage($tmb);
             }
             break;
         case 'gd':
             if ($s['mime'] == 'image/jpeg') {
                 $img = imagecreatefromjpeg($tmb);
             } elseif ($s['mime'] == 'image/png') {
                 $img = imagecreatefrompng($tmb);
             } elseif ($s['mime'] == 'image/gif') {
                 $img = imagecreatefromgif($tmb);
             } elseif ($s['mime'] == 'image/xbm') {
                 $img = imagecreatefromxbm($tmb);
             }
             if ($img && false != ($tmp = imagecreatetruecolor($tmbSize, $tmbSize))) {
                 if ($this->options['tmbCrop'] == false) {
                     if ($this->options['tmbBgColor'] == 'transparent') {
                         list($r, $g, $b) = array(0, 0, 255);
                     } else {
                         list($r, $g, $b) = sscanf($this->options['tmbBgColor'], "#%02x%02x%02x");
                     }
                     $bgcolor = imagecolorallocate($tmp, $r, $g, $b);
                     if ($this->options['tmbBgColor'] == 'transparent') {
                         $bgcolor = imagecolortransparent($tmp, $bgcolor);
                     }
                     imagefill($tmp, 0, 0, $bgcolor);
                     if (!imagecopyresampled($tmp, $img, $x, $y, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
                         return false;
                     }
                 } else {
                     if (!imagecopyresampled($tmp, $img, 0, 0, $x, $y, $tmbSize, $tmbSize, $size_w, $size_h)) {
                         return false;
                     }
                 }
                 $result = imagepng($tmp, $tmb, 7);
                 imagedestroy($img);
                 imagedestroy($tmp);
             }
             break;
     }
     return $result ? $name : false;
 }
开发者ID:JoeDukes,项目名称:ScheduleIt,代码行数:88,代码来源:elFinderVolumeDriver.class.php

示例5: resizeImg

 /**
  * Resize image
  *
  * @param  string   $path       image file
  * @param  int      $width      new width
  * @param  int      $height     new height
  * @param  bool	    $crop       crop image
  * @param  bool	    $exactfit   fit into given dimensions exactly
  * @param  string   $imgLib     image library
  * @param  string   $bgcolor    image background color
  * @param  string   $destformat image destination format
  * @return string|false
  * @author Dmitry (dio) Levashov, Alexey Sukhotin
  **/
 protected function resizeImg($path, $width, $height, $crop = false, $exactfit = false, $imgLib = 'imagick', $bgcolor = '#0000ff', $destformat = null)
 {
     if (($s = @getimagesize($path)) == false) {
         return false;
     }
     $result = false;
     list($x, $y, $size_w, $size_h) = $this->getResizeCropDimensions($s[0], $s[1], $width, $height, $crop, $exactfit);
     switch ($imgLib) {
         case 'imagick':
             try {
                 $img = new imagick($path);
             } catch (Exception $e) {
                 return false;
             }
             $img->contrastImage(1);
             if ($crop == false) {
                 $img->resizeImage($size_w, $size_h, NULL, true);
                 if ($exactfit == true) {
                     $img1 = new Imagick();
                     $img1->newImage($width, $height, new ImagickPixel($bgcolor));
                     $img1->setImageFormat($destformat != null ? $destformat : $img->getFormat());
                     $img->resizeImage($size_w, $size_h, NULL, true);
                     $img1->compositeImage($img, imagick::COMPOSITE_OVER, $x, $y);
                     $result = $img1->writeImage($path);
                     return $result ? $path : false;
                 }
             } else {
                 $img->cropImage($width, $height, $x, $y);
             }
             $result = $img->writeImage($path);
             return $result ? $path : false;
             break;
         case 'gd':
             if ($s['mime'] == 'image/jpeg') {
                 $img = imagecreatefromjpeg($path);
             } elseif ($s['mime'] == 'image/png') {
                 $img = imagecreatefrompng($path);
             } elseif ($s['mime'] == 'image/gif') {
                 $img = imagecreatefromgif($path);
             } elseif ($s['mime'] == 'image/xbm') {
                 $img = imagecreatefromxbm($path);
             }
             $init_w = $size_w;
             $init_h = $size_h;
             if ($exactfit == true) {
                 $init_w = $width;
                 $init_h = $height;
             }
             if ($img && false != ($tmp = imagecreatetruecolor($init_w, $init_h))) {
                 if ($crop == false) {
                     if ($bgcolor == 'transparent') {
                         list($r, $g, $b) = array(0, 0, 255);
                     } else {
                         list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
                     }
                     $bgcolor1 = imagecolorallocate($tmp, $r, $g, $b);
                     if ($bgcolor == 'transparent') {
                         $bgcolor1 = imagecolortransparent($tmp, $bgcolor1);
                     }
                     imagefill($tmp, 0, 0, $bgcolor1);
                     if (!imagecopyresampled($tmp, $img, $x, $y, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
                         return false;
                     }
                 } else {
                     if (!imagecopy($tmp, $img, 0, 0, $x, $y, $width, $height)) {
                         return false;
                     }
                 }
                 if ($destformat == 'jpg' || $destformat == null && $s['mime'] == 'image/jpeg') {
                     $result = imagejpeg($tmp, $path, 100);
                 } else {
                     if ($destformat == 'gif' || $destformat == null && $s['mime'] == 'image/gif') {
                         $result = imagegif($tmp, $path, 7);
                     } else {
                         $result = imagepng($tmp, $path, 7);
                     }
                 }
                 imagedestroy($img);
                 imagedestroy($tmp);
                 return $result ? $path : false;
             }
             break;
     }
     return false;
 }
开发者ID:laiello,项目名称:avecms,代码行数:99,代码来源:elFinderVolumeDriver.class.php


注:本文中的imagick::contrastImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。