因需要先处理生成的二维码图片旋转,再和另外一张png图片合并,图片都是png

<?php
// this file writes the image into the http response,
// so we cant have any output other than headers and the file data
ob_start(); $filename = 'qrcode.png'; //my qrcode background color is white
$degrees = 7; // open the image file
$im = imagecreatefrompng( $filename ); // create a transparent "color" for the areas which will be new after rotation
// r=255,b=255,g=255 ( white ), 127 = 100% transparency - we choose "invisible black"
$transparency = imagecolorallocatealpha( $im,255,255,255,0 ); // rotate, last parameter preserves alpha when true
$rotated = imagerotate( $im, $degrees, $transparency, 1); //maybe there have make white color is transparent
$background = imagecolorallocate($rotated , 255, 255, 255);
imagecolortransparent($rotated,$background); // disable blendmode, we want real transparency
imagealphablending( $rotated, false );
// set the flag to save full alpha channel information
imagesavealpha( $rotated, true ); // now we want to start our output
ob_end_clean();
// we send image/png
header( 'Content-Type: image/png' ); imagepng( $rotated );
// clean up the garbage
imagedestroy( $im );
imagedestroy( $rotated );

因为图片旋转之后,图片的大小是会变化的,所以可以 使用 imagesx,imagesy 可以获取图片资源的宽度和高度,就不需要 保存图片,之后读取图片,再使用 getimagesize 获取图片的宽度和高度。

参考
  1. imagecreatefrompng() Makes a black background instead of transparent? -- 学习用到 imagecolortransparent() 方法
  2. Rotate a PNG then resave with Image Transparency -- 主要参考这个回答旋轉 png 并透明低

php 图片旋转和png透明的更多相关文章

  1. JS框架_(coolShow.js)图片旋转动画特效

    百度云盘 传送门 密码:ble6 coolShow.js插件图片旋转动画效果 <!DOCTYPE HTML> <head> <meta http-equiv=" ...

  2. ffmpeg第五篇:让水印图片旋转起来

    这篇把上次挖的坑填上 ffmpeg正式篇的上一篇(传送门)说了,这一篇要让水印旋转起来,但是后面有事情一直没有时间搞,今天,它来了............ 如果想实现旋转的功能,需要使用ffmpeg过 ...

  3. 自己积累的一些Emgu CV代码(主要有图片格式转换,图片裁剪,图片翻转,图片旋转和图片平移等功能)

    using System; using System.Drawing; using Emgu.CV; using Emgu.CV.CvEnum; using Emgu.CV.Structure; na ...

  4. PHPThumb处理图片,生成缩略图,图片尺寸调整,图片截取,图片加水印,图片旋转

    [强烈推荐]下载地址(github.com/masterexploder/PHPThumb). 注意这个类库有一个重名的叫phpThumb,只是大小写的差别,所以查找文档的时候千万注意. 在网站建设过 ...

  5. js无刷新上传图片,服务端有生成缩略图,剪切图片,iphone图片旋转判断功能

    html: <form action="<{:AppLink('circle/uploadimg')}>" id="imageform" me ...

  6. jQuery图片旋转展示收缩效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. iOS_UIImage_图片旋转

    一.目的: 有时候我们获得到的图片我们不是我们想要的方向,需要对图片进行旋转.比如:图片旋转90度180度等. 二.实现过程. 1.获取到该UIImage. 2.开启上下文. 3.上下文的具体操作. ...

  8. Rotating Image Slider - 图片旋转切换特效

    非常炫的图片旋转滑动特效,相信会给你留下深刻印象.滑动图像时,我们会稍稍旋转它们并延缓各元素的滑动.滑块的不寻常的形状是由一些预先放置的元素和使用边框创建.另外支持自动播放选项,鼠标滚轮的功能. 在线 ...

  9. JQuery插件让图片旋转任意角度且代码极其简单

    引入下方的jquery.rotate.js文件,然后通过$("选择器").rotate(角度);可以旋转任意角度, 例如$("#rotate-image").r ...

随机推荐

  1. Centos光盘ISO安装过程再理解

    ISO启动时的基本流程 vmlinuz  -> 加载initrd.img -> 加载内核基本驱动 -> 挂载光盘至/run/install/repo -> 启动anaconda ...

  2. windows 修改远程登录端口号

    运行regedit.exe打开注册表编辑器,即在cmd的dos窗口输入regedit命令 找到如下注册表子项: HKEY_LOCAL_MACHINE\System\CurrentControlSet\ ...

  3. 传输文件到docker容器

    传输文件到docker容器 首先需要知道docker容器的container_id,可以使用docker ps命令来查看你要操作的docker容器的container_id Docker容器向宿主机传 ...

  4. 单向连通图 Going from u to v or from v to u? poj2762

    http://poj.org/problem?id=2762 强连通求子图和子图关系 + 子图关系是链式结构 #include <cstdio> #include <cstdlib& ...

  5. cehsi

    weibo https://oapi.dingtalk.com/robot/send?access_token=8c9ef96c99925383347c5f9f733ad6b8579c3f8ad072 ...

  6. js简单图片切换

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...

  7. 矩阵乘法分配律+bitset优化——hdu4920

    因为是模3,所以把原矩阵拆成两个01矩阵,然后按分配律拆开分别进行矩阵乘法,行列用bitset来存进行优化即可 注意 int bitset<int>::count() 函数可以统计bits ...

  8. 强大的pdf文件操作小工具——PDFtk的小白用法 【转载】

    转载出处https://www.cnblogs.com/basterdaidai/p/6204518.html 前言 作为程序员,大家都知道的,总是会被技术小白问各种跟编程没什么关系的硬件.软件问题. ...

  9. git删除持久化存储的账号密码.git-credentials

    git在提交时,发现提交不了,个人信息不是自己的,通过 git config --list 看到邮箱和用户名都是自己的. 这时候就需要把以前记录过的信息都删掉. 1. 通过 git config -- ...

  10. 如何通过编程发现Java死锁

    本文由 ImportNew - rookie_sam 翻译自 Dzone.欢迎加入翻译小组.转载请见文末要求. 死锁是指,两个或多个动作一直在等待其他动作完成而使得所有动作都始终处在阻塞的状态.想要在 ...