Hello ,
I want to re-scale (crop and resize) an image with a simple image upload form and convert it to base64 to save the database. Is there a way to do this with wappler?
I want to do this server-side.
Hello ,
I want to re-scale (crop and resize) an image with a simple image upload form and convert it to base64 to save the database. Is there a way to do this with wappler?
I want to do this server-side.
Hello, I have the same issue here.
Thanks!
you can do this with custom formatter on server side
1 create custom.php (dmxConnectionLib > lib > formatters)
2 create function
<?php
namespace lib\core;
function formatter_baseimage($val,$url) {
$img = file_get_contents('http://yourdomain.com'.$url);
// Encode the image string data into base64
return $data = base64_encode($img);
}
I really can’t make it work… How do I set the image path? It’s not a fixed path? I need to encode a image previously uploaded to send via API to an API service
You can do whatever you want with this function. (if you are using PHP)
example usage;
{{a.baseimage(newImage1)}}
But inside here, what should i put? And isn't the code incomplete (the php is not closed)
You should write at what address image is published.
Which image? the encoded one? I need the image encoded value inside a variable to post it in a form
on html
<img alt="" dmx-bind:src="'data:image/jpeg;base64,'+thumbpath"></a>
You can use the function in this way when saving to database.
{{a.baseimage(big11)}}
This right here is a life saver function.