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
php_imagick是怎么实现复古效果的呢?的更多相关文章
- Cocos2D添加精灵纹理滤镜实现图像复古效果的转换
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 大家知道Cocos2d本身是一个非常强悍的2d游戏引擎,其中自 ...
- [js高手之路] html5 canvas系列教程 - 像素操作(反色,黑白,亮度,复古,蒙版,透明)
接着上文[js高手之路] html5 canvas系列教程 - 状态详解(save与restore),相信大家都应该玩过美颜功能,而我们今天要讲的就是canvas强大的像素处理能力,通过像素处理,实现 ...
- Cocos2D结合CoreGraphics实现RPG人物中空黑洞吸入效果
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 之前的博文中我们实现了RPG人物的复古效果. 现在我们再完点h ...
- 相识HTML5 canvas
Canvas是HTML的API,我们可以用它在网页中实时的来生成图像. 文章导读 1.必备技能 2.用于画图的函数 例子: -会话气泡- -心形- -钟表- -星球里的星星- - ...
- canvas的用法介绍
目录 概述 绘图方法 图像处理方法 drawImage方法 getImageData方法,putImageData方法 toDataURL方法 save方法,restore方法 动画 像素处理 灰度效 ...
- PS教程1000例
http://www.missyuan.com/thread-446934-1-1.html Photoshop绘制逼真头发发丝效果http://www.missyuan.com/thread-446 ...
- 【转】15个无比华丽的HTML5/CSS3动画应用
原文转自:http://www.html5cn.org/article-7089-1.html 前几天,HTML5标准已经尘埃落定,未来的Web将会是由HTML5主导,当然作为开发者对这一喜讯更为动心 ...
- 16款最佳HTML5超酷动画演示及源码
1.HTML5/CSS3图片选择动画 可选择多张图片 之前我们已经分享过几款很酷的HTML5图片特效,像HTML5 3D图片折叠特效.HTML5 3D旋转图片相册等应用.今天我们来分享一款既炫酷又实用 ...
- h5 canvas
概述 Canvas API(画布)用于在网页实时生成图像,并且可以操作图像内容,基本上它是一个可以用JavaScript操作的位图(bitmap). 使用前,首先需要新建一个canvas网页元素. & ...
随机推荐
- tcpdump 抓包
简介 用简单的话来定义tcpdump,就是:dump the traffic on a network,根据使用者的定义对网络上的数据包进行截获的包分析工具. tcpdump可以将网络中传送的数据包的 ...
- Linux实现自动登录
使用expect实现自动登录的脚本,网上有很多,可是都没有一个明白的说明,初学者一般都是照抄.收藏.可是为什么要这么写却不知其然.本文用一个最短的例子说明脚本的原理. 脚本代码如下: #!/usr/b ...
- 我认为最节省时间的CSS命名规范
CSS命名规范一 js中对变量的命名最好使用camel case驼峰式命名法,但CSS中更适用于red-box命名规范. CSS命名规范二 BEM命名规范 B=>block E=>elem ...
- 499 单词计数 (Map Reduce版本)
原题网址:https://www.lintcode.com/problem/word-count-map-reduce/description 描述 使用 map reduce 来计算单词频率http ...
- JS中的一些函数式编程术语
组合 Composition 组合某种类型(含函数)的两个元素,进而生成一个该类型的新元素: JavaScript 1 2 3 4 5 6 7 let compose = (f ...
- 谈谈数据库sql编写
本文主要给初学者关于关系数库的一个浮光掠影式的介绍,如果想深入理解,必须对于下文提到的每个内容单独深入学习! it-information technology的简称,中文是信息机技术,信息其实就是数 ...
- Python爬虫工程师必学——App数据抓取实战
Python爬虫工程师必学 App数据抓取实战 整个课程都看完了,这个课程的分享可以往下看,下面有链接,之前做java开发也做了一些年头,也分享下自己看这个视频的感受,单论单个知识点课程本身没问题,大 ...
- Django--Cookie和Session组件
什么是Cookie: cookie的工作原理是:由服务端产生内容,浏览器收到请求之后保存在本地:当浏览器再次访问的时候,浏览器会自动带上这个cookie,这样服务端就能去通过这个cookie来判断你是 ...
- TensorFlow的安装 (python3.6在有pip的条件下如何安装TensorFlow)
1.Window,MacOS,Linux都已支持Tensorflow. 2.Window用户只能使用python3.5(64bit).MacOS,Linux支持python2.7和python ...
- Leetcode138. Copy List with Random Pointer复制带随机指针的链表
给定一个链表,每个节点包含一个额外增加的随机指针,该指针可以指向链表中的任何节点或空节点. 要求返回这个链表的深度拷贝. 方法一: class Solution { public: RandomLis ...