php_imagick是怎么实现复古效果的呢?

php_imagick程序示例

1.创建一个缩略图并显示出来

<?php
header(‘Content-type: image/jpeg‘);
$image = new Imagick(‘image.jpg‘);
// If 0 is provided as a width or height parameter,// aspect ratio is maintained
$image->thumbnailImage(100, 0);
echo $image;
?>

2.创建一个目录下的缩略图,并保存

<?php
$images = new Imagick(glob(‘images/*.JPG‘));
foreach($images as $image) {
// Providing 0 forces thumbnailImage to maintain aspect ratio
$image->thumbnailImage(1024,0);
}
$images->writeImages();
?>

3.缩略GIF动画图片

<?php
/* Create a new imagick object and read in GIF */
$im = new Imagick("example.gif");
/* Resize all frames */
foreach ($im as $frame) {
/* 50x50 frames */
$frame->thumbnailImage(50, 50);
/* Set the virtual canvas to correct size */
$frame->setImagePage(50, 50, 0, 0);
}/* Notice writeImages instead of writeImage */
$im->writeImages("example_small.gif", true);
?>

利用php_imagick实现复古效果的方法

先来看下效果图


复古效果展示

要实现以上效果,我们先用Photoshop用以下步骤实现。

打开原图
新建图层,使用颜色#C0FFFF填充后,不透明度设为44%,图层混合模式为柔光
新建图层,使用颜色#000699填充后,不透明设置为48%,图层混合模式为排除
合并图层

用PHP代码,也就只需要按照以上步骤实现即可,代码如下:

//打开图片
$im = new Imagick(‘./hebe.jpg‘);
//新建图层,使用颜色`#C0FFFF`填充后,不透明度设为`44%`
$layer = new Imagick();
$layer->newImage($im->getImageWidth(), $im->getImageHeight(), ‘#C0FFFF‘);
$layer->setImageOpacity (0.44);
//叠加到原图上,图层混合模式为`柔光`
$im->compositeImage($layer, Imagick::COMPOSITE_SOFTLIGHT, 0, 0);
//新建图层,使用颜色`#000699`填充后,不透明设置为`48%`
$layer = new Imagick();
$layer->newImage($im->getImageWidth(), $im->getImageHeight(), ‘#000699‘);
$layer->setImageOpacity (0.48);
//叠加到原图上,图层混合模式为`排除` 
$im->compositeImage($layer, Imagick::COMPOSITE_EXCLUSION, 0, 0);
//完成!
$im->writeImage(‘./vintage.jpg‘);

A new addition to Laravel is the ability to specify the creation of a resourceful controller when you are creating a new Model through Artisan. This means you can pass a -c or --controller flag to make:model:

php artisan make:model Post --controller Laravel Image Dimensions Validation

New in Laravel v5.3 is the ability to validate image files to ensure they meet certain dimensions and through the validator this can be setup with a string format:

‘avatar‘ => ‘dimensions:min_width=100,min_height=200,ratio=3/2‘

Now in v5.3.19 this can be specified through a fluent syntax similar to unique and exists validation rules :

Rule::dimensions()->minWidth(100)->minHeight(100)->ratio(3/2) Laravel Validation in and not_in

The in and not_in validation received the ability to pass an array.

// Previous in:php,laravel,... // New Rule::in([‘php‘,‘laravel‘])

Then the same for not_in

// Previous not_in:php,laravel,... // New Rule::notIn([‘php‘, ‘laravel‘])

Either style is valid and the new object-based style parses down into the old way. So you are free to use whichever suits your app.

After Validation Hook

Now your controllers can have a new withValidator method so you can easily call any hooks after validation:

protected function withValidator($validator) { $validator->after(function($validator) { if ($this->somethingElseIsInvalid()) { $validator->errors()->add(‘field‘, ‘Something is wrong with this field!‘); } }); }

Previously you had to manually setup the $validator = Validator::make() before you could use an after hook which meant you lost the ability to utilize the ValidatesRequests trait.

Upgrading Laravel

To get this latest version all you need to do is run composer update and you can find a complete list of changes in the changelog

时间: 2024-08-07 16:14:33

php_imagick是怎么实现复古效果的呢?的相关文章

Cocos2D结合CoreGraphics实现RPG人物中空黑洞吸入效果

大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 之前的博文中我们实现了RPG人物的复古效果. 现在我们再完点high的,我们准备实现这么一种效果: 人物从中心点开始形成一个空洞,洞的边缘产生一种吸入变形效果. 有了上一篇的铺垫,我们可以很快搞定它. 首先看一下Apple对其CIHoleDistortion滤镜的说明: Creates a circular area that pushes the image

[js高手之路] html5 canvas系列教程 - 像素操作(反色,黑白,亮度,复古,蒙版,透明)

接着上文[js高手之路] html5 canvas系列教程 - 状态详解(save与restore),相信大家都应该玩过美颜功能,而我们今天要讲的就是canvas强大的像素处理能力,通过像素处理,实现反色,黑白,亮度,复古,蒙版,透明等美颜效果. getImageData:获取一张图片的像素数据 cxt.getImageData( x, y, width, height ) x:图片所在的x坐标 y: 图片所在的y坐标 width,height 要获取的像素区域 返回值是一个对象,对象包括一个d

必备的Canvas接口和动画效果大全

1.概述 <canvas>元素用于生成图像.它本身就像一个画布,JavaScript 通过操作它的 API,在上面生成图像.它的底层是一个个像素,基本上<canvas>是一个可以用 JavaScript 操作的位图(bitmap).它与 SVG 图像的区别在于,<canvas>是脚本调用各种方法生成图像,SVG 则是一个 XML 文件,通过各种子元素生成图像.使用 Canvas API 之前,需要在网页里面新建一个<canvas>元素. <canvas

Canvas API

概述 绘图方法 图像处理方法 drawImage方法 getImageData方法,putImageData方法 toDataURL方法 save方法,restore方法 像素处理 灰度效果 复古效果 红色蒙版效果 亮度效果 反转效果 参考链接 概述 Canvas API(画布)用于在网页实时生成图像,并且可以操作图像内容,基本上它是一个可以用JavaScript操作的位图(bitmap). 使用前,首先需要新建一个canvas网页元素. <canvas id="myCanvas"

canvas的api

Canvas API(画布)用于在网页实时生成图像,并且可以操作图像内容,基本上它是一个可以用JavaScript操作的位图(bitmap).使用前,首先需要新建一个canvas网页元素. 1 2 3 4 <canvas height="200" id="myCanvas" width="400">     您的浏览器不支持canvas! </canvas> <!-- 如果浏览器不支持这个API,则就会显示canva

Canvas简单动画和像素处理

动画 利用JavaScript,可以在canvas元素上很容易地产生动画效果. var posX = 20, posY = 100; setInterval(function() { context.fillStyle = "black"; context.fillRect(0,0,canvas.width, canvas.height); posX += 1; posY += 0.25; context.beginPath(); context.fillStyle = "w

PS教程1000例

http://www.missyuan.com/thread-446934-1-1.html Photoshop绘制逼真头发发丝效果http://www.missyuan.com/thread-446912-1-1.html Photoshop合成在空中漂移的陆地http://www.missyuan.com/thread-446909-1-1.html Photoshop制作漂亮的紫色水晶字效果http://www.missyuan.com/thread-446908-1-1.html Pho

HTML5 Canvas八大核心技术及其API用法

什么是canvas? Canvas元素是HTML5的一部分,允许脚本语言动态渲染 位图像.Canvas由一个可绘制区域HTML代码中的属性定义高度和宽度(注:用其属性width和height设置宽度和高度时不能跟像素单位 “px”).JavaScript代码可访问该区域,通过一套完整的绘图功能类似于其他通用二维的API,从而生成动态的图形. Canvas八大核心技术(3D3R公司创始人兼CEO Ohad Eder-Pressman的独到见解): 1.游戏 HTML5在基于Web的图像显示方面比F

HTML5新标签之Canvas

1.概述 Canvas 用于在网页展示图像,并且可以定制内容,基本上它是一个可以用JavaScript操作的位图(bitmap). Canvas API用于网页实时生成图像,JavaScript通过API来操作图像内容.这样做的优点是:减少HTTP请求数,减少下载的数据,加快网页载入时间,可以对图像进行实时处理. 使用前,首先需要建一个Canvas网页元素. <canvas id="myCanvas" width="400" height="200&