Hi,
I am calling an API and receiving some data
one of the objects is a img url for example “https://webiste.com/products/product1/image.jpg”
i would like to save that image in the assets folder.
I have tried load image / save image action but it gives me an error
“!Invalid Path! https://webiste.com/products/product1/image.jpg” (the error returns correct url to the image i want to save)
Server action looks something like this
-API Action
-Repeat (repeating API results)
So a this point i tried to load an image (using image url from API results)
and then i tried to use save image action
Still i am getting !invalid path error,
bare in mind that the images Im trying to save are hosted on different server / domain
than my wappler website.
Is it even possible to download image from external source?
This currently doesn’t work. You can use a dropzone photo upload and then click in the box and when it pops up paste the URL in and it will upload the image. Other than that I haven’t found a way to do this.
User clicks a button ‘create QR for image watermark’
SC adds the path to https://api.qrserver.com/v1/create-qr-code/?size=370x370&data=https://www.example.com
SC then saves the image returned from the API above to a folder on the server
Imagepath is recorded to the db so we can pull it out anytime after.
This qr code than then be used at a later date to use as a dynamically created watermark on another image (thats the easy bit)
Battled with a similar problem myself a few years ago with the same API. My solution was, rather than store the QR code, i simply recreate it each time it needed to be displayed.
Thanks for that update, I’ve spent a fair bit of time on that too - I am already loading live from the API in an <img> tag but I need it to save as I’m using dynamic image rendering by the excellent www.cloudimage.io - the main image is resized and optimised using dynamic urls, they work perfectly, but adding a qrcode as a watermark is problematic as the url for cloudimage needs an actual file and not a generated one from an API.
On the page, I’m using this to resize/optimise image: <img alt="image" title="image" dmx-bind:src="'https://xxxxxxxxx.cloudimg.io/toms-url.com'+imgFile+'?func=crop&width=300'" id="aa">
to add the qr code watermark, I’d need to use the URL of a file (this can be dynamically generated, same as the image url above), it looks something like this: <img alt="image" title="image" dmx-bind:src="'https://xxxxxxxxx.cloudimg.io/toms-url.com'+imgFile+'?func=crop&width=300&wat=1&wat_url=http://sample.li/qr-code-image-link-here.png&wat_scale=45&wat_gravity=southeast&wat_pad=15'" id="aa">
Its working great for logos, but I really need a QR code in there as well.
I know with PHP you fetch a file from a URL and then save it… im just passing some ideas… maybe generate the qr code first… and then import the image…
<?php
// URL of the QR code
$url = 'https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=Example';
// Get the QR code image
$qr_code = file_get_contents($url);
if ($qr_code !== false) {
// Save the image
file_put_contents('qr_code.png', $qr_code);
echo 'QR code saved successfully as qr_code.png';
} else {
echo 'Failed to retrieve QR code';
}
?>