Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need help using tarker with "Image must be in png or jpeg and base64 encoded in embedded format" #53

Open
hernanbozzano opened this issue Aug 30, 2024 · 9 comments

Comments

@hernanbozzano
Copy link

Hi everyone

I've been trying to convert a jpeg image to send it through whastapp (using tasker in android).. unfortunately, i tried many ways of converting but never succeded, does anyone have an example o explanation more detailed as a hint?

thanks in advance
hernan

@lordacer0
Copy link

First you have to read the file in binary to a variable. Then you have to remove the \n line breaks from that variable. The result is the base64 encoding of the file.
A question, do audio webhooks work for you? And if they work, could you tell me if you use docker or run Wuzapi locally? Thank you.

@hernanbozzano
Copy link
Author

You are a genius lordcer0! the \n thing did the trick! however, i can't see the thumbnail before i download the image in my phone, the "preview".. did you manage to fix it?

unfortunately, my robot is not meant to download audios i receive so i can't give you any information about.. i will let you know if i incorporate that stuff to my project

@lordacer0
Copy link

You are a genius lordcer0! the \n thing did the trick! however, i can't see the thumbnail before i download the image in my phone, the "preview".. did you manage to fix it?

unfortunately, my robot is not meant to download audios i receive so i can't give you any information about.. i will let you know if i incorporate that stuff to my project

If you correctly set the mimetype when sending, for example image/jpeg, a thumbnail of the image is displayed in WhatsApp before opening it.
Regarding the audio webhooks, the only thing I would need is to know if the webhooks arrive (if Wuzapi reacts) when they send an audio and if this is how you implemented Wuzapi, whether locally or with Docker (I with Docker). Greetings.

@hernanbozzano
Copy link
Author

in the API references https://github.com/asternic/wuzapi/blob/main/API.md#send-image-message the image/jpeg is already in the http request '{"Phone":"5491155554444","Caption":"Look at this", "Image":"data:image/jpeg;base64,iVBORw0KGgoAAAANSU..."}', are you talking about something else?

on the other hand, regarding your question, my project runs on android tasker app and my webhook alert does not trigger when an audio is received (i checked).. why dont you let the audios auto-download and grab them from the downloaded folder?

@lordacer0
Copy link

in the API references https://github.com/asternic/wuzapi/blob/main/API.md#send-image-message the image/jpeg is already in the http request '{"Phone":"5491155554444","Caption":"Look at this", "Image":"data:image/jpeg;base64,iVBORw0KGgoAAAANSU..."}', are you talking about something else?

on the other hand, regarding your question, my project runs on android tasker app and my webhook alert does not trigger when an audio is received (i checked).. why dont you let the audios auto-download and grab them from the downloaded folder?

Exactly, by sending the image encoded in base64 and sending the mimetype correctly, it already shows the thumbnail in the received message.
Regarding audio webhooks, I do not use "base" cell phones, only one session. Do you run Wuzapi on Android with Termux? I run it in Docker, I need to test it running locally.

@hernanbozzano
Copy link
Author

unfortunately it does not shows the blurry image before the image is opened :(

yes, i run wuzapi on android with termux!

@George-Seven
Copy link

It's not the platform, it's because wuzapi doesn't have code to set thumbnail preview here -

wuzapi/handlers.go

Lines 865 to 874 in 9987988

msg := &waProto.Message{ImageMessage: &waProto.ImageMessage{
Caption: proto.String(t.Caption),
URL: proto.String(uploaded.URL),
DirectPath: proto.String(uploaded.DirectPath),
MediaKey: uploaded.MediaKey,
Mimetype: proto.String(http.DetectContentType(filedata)),
FileEncSHA256: uploaded.FileEncSHA256,
FileSHA256: uploaded.FileSHA256,
FileLength: proto.Uint64(uint64(len(filedata))),
}}

You need to manually add the code to set the thumbnail preview from here - tulir/whatsmeow#204 (comment)

Also, to properly see the effect of not setting thumbnails, you need to turn off media auto-download from WhatsApp Chat settings.

All images/videos sent from wuzapi will now appear blurry or blank until manually downloaded.

@hernanbozzano
Copy link
Author

It's not the platform, it's because wuzapi doesn't have code to set thumbnail preview here -

wuzapi/handlers.go

Lines 865 to 874 in 9987988

msg := &waProto.Message{ImageMessage: &waProto.ImageMessage{
Caption: proto.String(t.Caption),
URL: proto.String(uploaded.URL),
DirectPath: proto.String(uploaded.DirectPath),
MediaKey: uploaded.MediaKey,
Mimetype: proto.String(http.DetectContentType(filedata)),
FileEncSHA256: uploaded.FileEncSHA256,
FileSHA256: uploaded.FileSHA256,
FileLength: proto.Uint64(uint64(len(filedata))),
}}

You need to manually add the code to set the thumbnail preview from here - tulir/whatsmeow#204 (comment)

Also, to properly see the effect of not setting thumbnails, you need to turn off media auto-download from WhatsApp Chat settings.

All images/videos sent from wuzapi will now appear blurry or blank until manually downloaded.

thank you for your explanation. unfortunately, this is way above my understanding and my knowledge, i will end up using without the blurry effect..

i was using another github repo https://github.com/HunterXProgrammer/Tasker-mdtest-v4 but unfortunately -until now- it is not under mantaince by the developer

@asternic
Copy link
Owner

Please review the commit 4c2ec6e for image sending.... If it works, I can do someting similar to video messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants