Creating a Camera App with adding a Watermark Image

Hey Community,

i am actually trying to create an App what Takes the Picture and adds in the Picture a Watermark Image in the Right corner.

I tryed it with Imageutil but i get every time an Error, i want to get an Image to the Picture and save it wih the second Button

Can u Guys help me out?
I use an Samsung S22 Ultra
Sorry for my bad English, i tryed it so good i can :'D

from the Code what i found i have actually this in the Picture shown code, i tryed myself but it dont work well.

Welcome!

What about revealing the exact error message?
What exactly does not work well? What do you expect and what happens instead?
How did you set the DefaultFileScope property in the designer of Screen1?

Taifun

Hello Taifun, i am New in the App Inventor think, it give me an wrong number of Arguments Error, forapplywatermark, I want to get into my Photo what i have taken a Watermark (Logo what i have uploaded in the App into the Photo in the Right corner, but i dont know how i get it work.

And what i want is, Then the Photo is taken, the Photo shows in the App and the Watermark Logo Image shows in the right corner and is savable with the Second Savebutton.
What i see, the Savebutton dont work by me, i hope u can help me, or anyone else, I just want a own Camera App what takes Pictures, set the Logo into the Picture and Save it in one Image in any Folder, can be a own Folder too.

Well, there are a lot of empty sockets in your method call... what about providing reasonable values there?

See the documentation of that extension for help

Taifun

I tried with the ImageUtil extansion a watermark but it dont worked, i cannot Take the Picture in it what i want to use, thats why i ask here for help, my code is actually trash :smile:

i dont get it to work like i want to, also it dont save the Image, i cannot find it in my Storage.

Here is an example of how to use that method

The author of the extension @gordonlu310 might be able to help more..

Taifun

ok thanks for it, i get now another error,

Runtime Error:
com.google.appinventor.components.runtime.canvas$CanvasView cannot be cast to Android.widget.Imageview.

My Code Looks now like in the Screenshot, still cannot save the Image or set the Watermark
hkv

Which means, this


must be an image component and can't be a canvas component. .

After taking the picture, displayi it using an image component and then use the ApplyWatermark method together with that image component

Taifun

So i have to input a Image nit a canvas to it, and the Problem with the picture saving, can u help me there?

You see, in math class you should have learned that you cannot divide numbers by 0. Look back in your code.

What exactly is the problem with picture saving?
Please follow

Taifun

Also, for the "image" parameter, only take Image components as inputs. You may not use a canvas component, which caused the error.

My Problem is, that then i Click on save Image, it apeats the Window to name it , but then i look at my Smartphone, i dont see it saved.

I have removed Canvas in all and only use Image, there i dont get the error.

I had the hope u can help me with this code to get it to work, i just want that the app takes the picture, print the Watermark in it and get saved with the second button.

Edit: I get the runtime Error Width and height must be > 0
before i get the error, i get this:

Runtime error: Attempt to invoke virtual Method "android.graphics.Bitmap android.graphics.drawable.Bitmapdrawable.getbitmap()" on a null object reference.

Move the ApplyWatermark method into the AfterPicture event
Also: What is the purpose of using the canvas?
EDIT: to find out, where the image is stored, display the image from the AfterPicture event in a label...
To see files stored in the ASD of your app, use a good file manager like Total Commander

Taifun

Thank you for this fast Answer, Now it works till Photo is Taken, then i press my Save Button it Sais Width and height must be > 0, what i have to write and who?

I just have canvas for the call Canvas.saveas funktion, in Image i dont find the function.

@gordonlu310 might want to explain, how to save a modified image...

My guess is, the original image will be overwritten automatically without need of using a canvas

EDIT: is the watermark correctly displayed now?
Did you check the original image, if it was modified?

Taifun

This Shows me, i want it in the right corner and mabe Not as Text, more as a picture what i have uploaded, mabe the creator can help there :slight_smile:

1 Like

I'm sorry, I was sleeping,so I couldn't answer your questions.

The extension does not overwrite the image saved in the path, it only edits the image component itself. All changes are unsaved.

this looks great! this is what the extension can do, see the documentation

Applies watermark text to the given image's content.

to have an image as watermark, try the Overlay method from the image extension https://puravidaapps.com/image.php

no need to apologize, noone is here 24/7

so how can someone save the modified image?

Taifun

2 Likes

They could use the ComponentToImage extension? (not sure what impact that has on quality...)