0

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.

Thanks.

user3480644
  • 557
  • 4
  • 8
  • 22
  • Another image means? you replicate the same image and change the opacity for the replicated one? and tell us the issue ur facing. share what have you tried so far. – Krish Jul 15 '14 at 07:05
  • Yes..I made a replica of the original image and change it opacity. – user3480644 Jul 15 '14 at 07:08
  • check the http://php.net/manual/en/imagick.setimageopacity.php – Krish Jul 15 '14 at 07:21

2 Answers2

2

You cannot manipulate the image's opacity while it uploads. You'll have to upload the image, save it, and then process it at a later time with something like setimageopacity()

Madara's Ghost
  • 158,961
  • 49
  • 244
  • 292
2

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

  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.

    Edit.

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

Community
  • 1
  • 1
Artur Aleksanyan
  • 460
  • 4
  • 10