如何在上传时设置图像不透明度的不透明度? [英] how to set opacity of an image opacity at the time of Upload?

查看:190
本文介绍了如何在上传时设置图像不透明度的不透明度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景,我必须上传一个图像和上传的图像另一个图像也存储在数据库中低不透明度。请告诉我如何在使用PHP上传图片时操作图片不透明度。

I have a scenario where i have to upload an image and with that uploaded image another image also stores with low opacity in the Database. Kindly tell me how can i manipulate image opacity at the time of uploading an image using PHP.

感谢。

推荐答案

你可以通过画布。所以流程如下。

You can do it thru canvas. So the Flow is as follows.


  1. 从imput文件上传图片,并获取其基础的64个字符串。

  2. 创建html图片标记,将您的基础64添加到其src属性。

  3. 将该图片绘制到画布上。这里你应该指定在画布中的不透明度。
    随意到google如何在画布上绘制不透明的图像。

  4. 从画布(根据需要绘制图像),获取图像的基础64。
  5. 执行帖子请求以将基本46图片保存到后端。

  1. upload image from imput file, and get its base 64 string.
  2. create html image tag, add your base 64 to it`s src attribute.
  3. draw that image to canvas. Here you should specify opacity whyle drawing in canvas. Feel free to google how to draw image with opacity in canvas.
  4. from canvas (with image drawn as you wanted), get base 64 of the image.
  5. do a post request to save your base 46 image to back end.

编辑。

我假设您要从浏览器上传图片。
原始图像可以从简单的形式上传。 (编辑的基础64一个可以在后台添加到相同的形式)
这是一个从输入文件获取base 64的示例。
在上传之前预览图片

I am assuming you want to upload the image from the browser. The original image can be uploaded from simple form. (edited base 64 one could be added to same form too in background) Here is an example of getting base 64 from input file. Preview an image before it is uploaded

这篇关于如何在上传时设置图像不透明度的不透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆