Node.js how to download webp image - node.js

It´s very easy to download images via the request module. But this is only working for me when then end of the url contains .jpg or .png
But how can you download as example this image?
https://lh3.googleusercontent.com/VpoWDgQ2I_RlTNM1Srlo5Q0VQglr-gdbzJ48TwYRXM2U4iF75PMrv76rBiu5c3l1UJs=s180-rw
Does anybody know a method to download the image as .jpg?

I found a solution on howtogeek
"Click the URL bar, delete the last three characters in the address (the “-rw”), and then press “Enter.” The same image will be displayed again, but this time it’s rendered in its original format, usually JPEG or PNG."

Related

trigger and fill image upload from url via chrome extension

I'm currently working on a chrome extension that injects a content script into a webpage that allows the user to autofill a form, and everything seems to be working correctly, with the text inputs. But I have not been able to figure out how to upload an image programmatically (simulating user input).
I need help creating a function that takes in a parameter of image url or data uri, and automatically triggers the file upload as if the user uploaded the image manually, to an input selector of my choice. End result should still keep the thumbnail and similar resolution intact.
Scope:
triggers file(image specifically) input automatically. Must include thumbnail and similar resolution intact
must include a parameter for image url/ or data uri
must include a parameter for input selector I target
must work from a chrome extension content script
must work on any file/image input on any page would be ideal
can be written in javascript or jquery, whichever you prefer
An extension that solves this problem perfectly can be found here, so I know this is possible, I just have not been able to replicate it: https://chrome.google.com/webstore/detail/upload-image-from-url/eiglgndkjiabiepkliiemoabepkkhacb. (the code is obfuscated, so I can't figure out how to replicate.

Template variable input type IMAGE but WebP file

I optimised my images and converted them into WebP format... image.webp
It seems to improve page speed significantly.
However, I have a template-variable IMAGE [blogpost-image] defined.
Now with this .webp extension (= Chrome HTML document), I cannot open the IMAGES directory and add the images to my resource docs. I tried changing the input type to URL and also to FILE for my template-variable, but none seems to work.
How can I get my images in .webp on front-end with a template variable?
Take a look at the System Settings. Under Area: File System you should see the Uploadable Image Type setting (or similar depending on your MODX version). The default is a list of usual image file types: .jpg, .png etc. You probably need to add the .webp extension in order to upload those to the image browser.

Converting a data URI back to SVG

Might be a silly question but is it possible to convert a data URI back to SVG? I've Googled & searched SO and found nothing on the subject, loads of stuff on the other way round of course.
Thanks!
Edit: sorry should've been more specific - a data:image like this:
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA4MCA4MCI+PHBhdGggZmlsbD0iIzFBMzc2MSIgZD0iTTE3Ljc4IDI1LjY1Yy44OS0uODkgMi4zNS0uODkgMy4yNSAwTDQwIDQ0LjU5bDE4Ljk3LTE4Ljk1Yy44OS0uODkgMi4zNS0uODkgMy4yNCAwbDIuNDMgMi40M2MuODkuODkuODkgMi4zNSAwIDMuMjVMNDEuNjIgNTQuMzVjLS45Ljg5LTIuMzUuODktMy4yNSAwTDE1LjM1IDMxLjMzYy0uODktLjg5LS44OS0yLjM1IDAtMy4yNWwyLjQzLTIuNDN6Ii8+PC9zdmc+
View the data URI in a web browser
Use inspect element
Open the data URI in new browser window/tab
Save the image as an .svg file
I am going to assume you mean a Base64 encoded data URI.
The answer is yes. The URI will look something like:
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0c...
The Base64 part is the part that starts with PH. Copy that part into an online converter such as this one.
Using javascript, you can open developer tool and run this code in the
console:
var dataURI = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA4MCA4MCI+PHBhdGggZmlsbD0iIzFBMzc2MSIgZD0iTTE3Ljc4IDI1LjY1Yy44OS0uODkgMi4zNS0uODkgMy4yNSAwTDQwIDQ0LjU5bDE4Ljk3LTE4Ljk1Yy44OS0uODkgMi4zNS0uODkgMy4yNCAwbDIuNDMgMi40M2MuODkuODkuODkgMi4zNSAwIDMuMjVMNDEuNjIgNTQuMzVjLS45Ljg5LTIuMzUuODktMy4yNSAwTDE1LjM1IDMxLjMzYy0uODktLjg5LS44OS0yLjM1IDAtMy4yNWwyLjQzLTIuNDN6Ii8+PC9zdmc+';
var svg = atob(dataURI.replace(/data:image\/svg\+xml;base64,/, ''));
console.log(svg);
The atob() method decodes a base-64 encoded string.
Check out this website SVG VIEWER. You can put your .svg file or SVG Text-Based to this website. After that, you can download as .svg, .jsx, and .png extension.

Send path of SDWebImage stored image to a UIWebView

I need to be able to get a path to images that cached.
While I am wondering if there is a way to do this using SDWebImage, I could probably get away with just having the knowledge to return a path to an image stored in the cache so I can display it within a uiwebview inside an image tag.
According to this https://github.com/rs/SDWebImage/issues/25 it would seem you can simply refer to the image by it's original url and it will be correctly picked up from cache.

I Need Help Modifying CKEditor's Default Image Property Paths

I am using CKEditor with Drupal 6.19. I have tried my installation with both CKFinder and IMCE. When an image is inserted from the image browser into the Image Properties window, CKEditor gets a url similar to:
/sites/example.com/files/images/my_image.jpg
I want CKEditor to simply have:
/files/images/my_image.jpg
file structure of my site is this:
/sites/all/modules/ckeditor/ckeditor
/sites/all/modules/ckeditor/ckfinder
/sites/all/modules/imce
/sites/example.com/files/images/my_mages.jpg
Is this url passed from the file browser, or a default in CKEditor?
If it is CKEditor, where do I find the code to change this, or is it even possible?
The URL suggested /sites/example.com/files/images/my_image.jpg is the correct path. Thats because all files are uploaded to the /sites/example.com/files/ folder. The behavior is correct and should not be modified. (Unless I've not understood your problem correctly or there is a very good reason why you want to store your images under DRUPAL_ROOT/files/images)

Resources