因需要先处理生成的二维码图片旋转,再和另外一张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. 高效IO之File文件操作类的基础用法(二)

    更多Android高级架构进阶视频学习请点击:https://space.bilibili.com/474380680 前言 众所周知Java提供File类,让我们对文件进行操作,下面就来简单整理了一 ...

  2. 并发编程之CAS(二)

    更多Android架构进阶视频学习请点击:https://space.bilibili.com/474380680本篇文章将从以下几个内容来阐述CAS: [CAS原理] [CAS带来的ABA问题] 一 ...

  3. C# WinfForm 控件之dev报表 XtraReport (八)动态生成报表

    功能说明:生成一个报表文件DV1,保存到本地AA.rep,再重新加载这个文件到DV2 1.布局如下图: panel1 上有三个button panel2上有个documentView dv1 pane ...

  4. hdu6321 /// 状压DP

    题目大意: 将一个 顶点不重复的边 的边集称为图中的matching 在一个n个点的零图中进行m次操作 + u v为在u v之间加一条边 存在重边 - u v为去掉u v之间的一条边 每次操作后 输出 ...

  5. Install .NET Core Runtime on Linux Ubuntu 16.04 x64

    原文链接https://www.microsoft.com/net/download/linux-package-manager/ubuntu16-04/runtime-current nstall ...

  6. wpf中datagrid绑定数据源发生改变

    1.若datagrid绑定的数据源是同一个的话,即使里面的数据不同.页面也不会刷新,则需要重置数据源,再绑定.处理如下: datagrid1.ItemsSource=ListModule; 若List ...

  7. ES6解构

    解构:“解开--重构” 1.数组的解构: //数组的解构: // let arr=[1,2,3,6] // let[a,b,c,d]=arr; // console.log(a,b,c,d)// 1, ...

  8. html清除页面缓存

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" ...

  9. linux下alsa架构音频驱动播放wav格式文件

    #include<stdio.h> #include<stdlib.h> #include <string.h> #include <alsa/asoundl ...

  10. 小程序怎样将字符串转化为html

    在小程序中通过rich-text 标签,使用nodes将字符串转化为html <rich-text class="allAnswer "  nodes='<span c ...