I am using power autoamte to convert an image in base64, and then I put this code in html.
Here is what I do:
- I convert the original image to base64
- I put this code in the html content in the <
img src='myBase64'>
tag. - I convert the html to pdf format
Everything is fine, but when my html file reaches more than 2 mb my flow stops working. This is the limit for this conversion operation.
My question is:
Is it possible to resize the base64 code? I know there are external connectors resize images like Encodian, but I don’t want to use them.
I searched on the internet, but without much results.
Thank you in advance
>Solution :
Yes, it is possible to resize base64 code representing the image. There are a few ways to do this:
-
Use an online tool like Base64 Image Decoder to resize the base64 code.
-
Use a program like ImageMagick to resize the base64 code.
-
Use a script like the following to resize the base64 code:
#!/usr/bin/env python
import base64
from PIL import Image
def resize_base64_code(base64_code, width, height):
img = Image.open(io.BytesIO(base64.b64decode(base64_code)))
img = img.resize((width, height), Image.ANTIALIAS)
return base64.b64encode(img.tobytes()).decode()
if __name__ == '__main__':
base64_code = '...' # your base64 code here
width = 200
height = 200
resized_base64_code = resize_base64_code(base64_code, width, height)
print(resized_base64_code)