Send a Pillow image in a Discord's embed - discord

I have an image created using Pillow that I would like to send in an embed (ie by using embed.set_image) and without saving the image into the hard drive. I have seen other posts on Stack but they suggest sending the image as a file with
with io.BytesIO() as image_binary:
image.save(image_binary, 'PNG')
image_binary.seek(0)
await channel.send(embed = embed, file=discord.File(fp=image_binary, filename='image.png'))
which is not my usecase because it sends the image as a file and messes with the formatting (eg if I have a footer) - I want the image to be part of the embed.
Is it possible to do something along the lines of embed.set_image(image_binary)?

Related

TipTap React Image Uploader with Placeholder

I am trying to build plug in the image extension (#tiptap/extension-image) to my tiptap editor, however the issue I find is with bigger images, there is no easy way to add a sort of placeholder image or text to tell the user the image is being uploaded.
The current flow is this:
const imageUrl = await doUpload();
editor.chain().focus().setImage({ src: imageUrl }).run()
So between uploading the image and setting the image, there is a delay and no feedback to the user.
So I have tried to extend the Image extension and I am able to create a method to set some text, but then I am not sure how to clear that text. Does anyone have a good solution for this?

How do I pull a random gif from tenor in discord.py?

I'm doing a discord bot using discord.py and one of the functions I want to add is on a command !gif it sends a random gif from tenor. Is it possible to do that? So basically what I need is an explanation as to how to fetch GIFs from tenor.
You would need to query Tenors random gif api:
https://tenor.com/gifapi/documentation#endpoints-random
This requires you to provide a search term and will return a randomised list of gif for that keyword.
You can then respond to the command with either a link to the gif or the gif itself as a file.

How do I show a gif attachment in Discord bot message embed?

Currently, my bot is set to send an embed message each time a command is used, but for some reason, the gif is not showing. This is what my code looks like:
let ballembed = new Discord.MessageEmbed()
.setColor(0x000000)
.setDescription(`**${mention}** was just harshly bonked!`)
.attachFiles("https://media.giphy.com/media/JrkbVRQA5adwle1ykt/giphy.gif")
message.channel.send(ballembed);
The code works fine if it's a png, but will not show if I use a gif.
What happens is that the embed message sends itself but without the gif, and there are no errors in the terminal.
I've tried using .attachFiles however, what happens is that the gif sends outside of the embed message.
I would like to be able to send the embed message with the gif inside.
You can use .setImage like Lily suggested or use an array instead like intended
.attachFiles(["https://media.giphy.com/media/JrkbVRQA5adwle1ykt/giphy.gif"]);

Can I change size of fedex label pdf?

I've created label using fedex API.
and I save that PDF Image into AWS. Below is url.
https://s3-ap-northeast-2.amazonaws.com/gmp01/temp/tmp-137164OTxA4P5MVJ1.pdf
This label has 4X6 size. but you can see pdf size is A4 in that link.
I've tried to find How can I remove this white space but I can't find in Fedex API Document.
If you have had this similar issue, please help me.
I am using Angular.js 1.x and Node.js
We get the 4x6 PDF label for FedEx and trim the white space by getting the PNG file first. Below you can find the parameter.
LabelFormatType = COMMON2D
ImageType = PNG
LabelStockType = PAPER_4X6
If you want to save time, you can use RESTful shipping API like Postmen which simplifies the API request for label generation.

Receive multi file post with google app engine

I want to receive multi file post from image uploader.(i use this)
Most examples show how to receive one image from post.
I tried many ways but never got the results.
For example
self.request.POST['Filename']
gives only first filename.
What to do when there are multiple files/images in post?
The reason for this is to resize before upload images, that are too big for google app engine
to upload.
EDIT:
self.request.POST.multi.__dict__
shows
{'_items':
[('Filename', 'camila1.jpg'),
('Filedata[]', FieldStorage('Filedata[]', 'camila1.jpg')),
('Upload', 'Submit Query\r\n--negpwjpcenudkacqrxpleuuubfqqftwm----negpwjpcenudkacqrxpleuuubfqqftwm\r\nContent-Disposition: form-data; name="Filename"\r\n\r\nbornToBeWild1.jpg'),
('Filedata[]', FieldStorage('Filedata[]', 'bornToBeWild1.jpg')),
('Upload', 'Submit Query')]}
Your flash uploader is designed to work with PHP and sends multiple Filedata[] fields (php interprets this as an array for easy access)
So you need to iterate and get them all:
def post(self):
for file_data in self.request.POST.getall('Filedata[]'):
logging.info(file_data.filename)
data should be file_data.value
Are you using the Django libraries available to you? If so, check this out.
Call self.request.POST.getall('Filename') to get a list of FieldStorage objects; each one contains one file. You can access the file data with .value, the name with .name, and the mimetype with .type.
I have no idea how that multi uploader works, I have made one in the past however and I just added a number on the end of input field name, then hide it. Then add a new file input field to add another file. The reason for this is that they don't let you play around with input file fields to much because you could make it upload files they didn't want you uploading.
Using my conventions, in your example the 2 files in your example would be "Filename0" and "Filename1". You could also use firebug to see what it renaming the input file fields to.
Edit: I had a look, and it's using flash. So i have no idea how it works.

Resources