因需要先处理生成的二维码图片旋转,再和另外一张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. JSON 教程首页

    JSON教程 JSON或JavaScript对象表示法是一个轻量级的基于文本的开放式标准,旨在为人类可读的数据交换. JSON格式最初是由Douglas Crockford规定,在RFC4627中描述 ...

  2. 用EditText控件的属性inputType

    android:inputType参数类型说明 android:inputType="none"--输入普通字符 android:inputType="text" ...

  3. python-selenium -- 弹出框处理

    弹出框有两种:页面弹出框(可定位元素能操作).Windows弹出框(不能直接定位) 一.页面弹出框 等待弹出框出现之后,定位弹出框,操作其中元素 如: driver = webdriver.Chrom ...

  4. VS系列远程调试

    其实很多时候,远程调试的话,我还是更喜欢用WinDBG的, 首先,可以练习WinDBG的使用手段, 其次,可以增加WinDBG的熟练度, 最重要的,WinDBG在内核调试部分很常用,我也很喜欢它,所以 ...

  5. 内网渗透_linux_socks代理_reGeorg+proxychains

    过程演示 测试前提是目标服务器已经getshell. 1.将 reGeorgSocksProxy 中的 tunnel.jsp 文件放置到目标服务器web目录,查看能否正常访问(如图). 2.设置kal ...

  6. 利用纯css写三角形,弧度箭头,吃豆人,气泡。放大镜,标签的源码

    1. 向上三角形

  7. java oop第11章_反射、BaseDao的进一步改造

      引言:从Java5开始,Java中引用了一个新的概念反射,当程序运行时,能动态感知到程序中拥有的所以信息,这个获取信息的过程是采用反射机制来完成. 一.       Class类: Class类用 ...

  8. react-router v4 理解

    1.Router (1)最基础的路由器,必须有history属性 (2)BrowserRouter和HashRouter都是由Router组件扩展而来 2.BrowserRouter (1)Brows ...

  9. 2018-12-21-微软最具价值专家-MVP-如何获得-Resharper-的免费功能

    title author date CreateTime categories 微软最具价值专家 MVP 如何获得 Resharper 的免费功能 lindexi 2018-12-21 11:29:0 ...

  10. 明年将制定个人信息保护法 网站部署https迫在眉睫

    12月20日,全国人大常委会法工委举行第三次记者会.全国人大常委会法工委发言人岳仲明表示,中国明年将制定个人信息保护法.数据安全法等. 数据泄露为何频频出现 你是否经常接到骚扰电话?推销.诈骗等等均有 ...