Get GraphicsMagick to open file from a https url? - https

I can use GraphicsMagick to download images given a URL, however when the URL starts with a https I get the following error (for https://example.com/image.png):
Unable to open file (//example.com/image.png) [No such file or directory].
I am using the gm driver for node.js with code like so:
gm = require('gm');
gm(url).write(name);
but have also tried the gm directly from the command line with the same issue.
As stated already, it works fine for http URLS, can I get it to work for https?

GraphicsMagick uses the HTTP support from libxml2, which does not currently support HTTPS. Try using an external program like 'wget' or 'curl' (which use OpenSSL to support HTTPS) to retrieve the file. Then you can pass the returned file to GraphicsMagick.

As Bob said, HTTPS is still not supported BUT:
Using the https module you can create a buffer and input it directly into GraphicsMagick.
https.get('https://www.eff.org/files/https-everywhere2.jpg', function(response) {
gm(response, 'image.jpg')
.write('test.jpg', function(err) {
if (err) return handle(err);
console.log('Created an image from a Buffer!');
});
});

Related

Cannot access webmasters.dat: No such file or directory

i am trying to access google search console api - tried the sample [https://github.com/googleapis/google-api-python-client/blob/master/samples/searchconsole/search_analytics_api_sample.py][1]
i followed the instructions:
1) Install the Google Python client library, as shown at
https://developers.google.com/webmaster-tools/v3/libraries.
2) Sign up for a new project in the Google APIs console at
https://code.google.com/apis/console.
3) Register the project to use
OAuth2.0 for installed applications.
4) Copy your client ID, client
secret, and redirect URL into the client_secrets.json file included in
this package.
5) Run the app in the command-line as shown below.
Sample usage: $ python search_analytics_api_sample.py
'https://www.example.com/' '2015-05-01' '2015-05-30'
of course for my site and newer dates..
recieved in cmd the warning:
\AppData\Local\Programs\Python\Python38\lib\site-packages\oauth2client_helpers.py:255:
UserWarning: Cannot access webmasters.dat: No such file or directory
in the window opened in the browser got the message:
Error 400: redirect_uri_mismatch The redirect URI in the request,
http://localhost:8080/, does not match the ones authorized for the
OAuth client. To update the authorized redirect URIs, visit:
https://console.developers.google.com/apis/credentials/oauthclient/xxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com?project=xxxxxxxxxxxx
i configured the redirect URI as http://localhost:8080/ but still the same
appreciate any help thanks

How to Get Response String from HTTP Server using HTTPSRedirect.h (NodeMCU)

The following code is responible for getting a string from HTTP Server
while (client.connected())
{
if (client.available())
{
String line = client.printRedir(url3, host);
Serial.println(line);
}
}`
Error Message:
no matching function for call to 'HTTPSRedirect::printRedir(String&,
const char*&)
How to store the response string from server
The use of HTTPSRedirect library makes the task much simpler by avoiding the need of any third party service. So, the first thing you need to do is to copy the HTTPSRedirect library files from GitHub and install into your Arduino libraries folder. I have also posted the zipped library files at the following link for convenience.
Download HTTPSRedirect Library
Update: The above library is outdated.
Please go to GitHub Sujay Phadke and download the updated library. Thanks Sujay.
from above discussion it must be you are using old version of HTTPSRedirect library,
to get new got to [Updated Library ] and download the library and copy the HTTPSRedirect folder from zip folder into the Arduino Ide libraries.
the above process solved my issue.
Define the host as below
const char* host = "your host";
And for string use
String url = "your complete url";

VLC Lua scripting https request

I'm writing a small vlc extension for nba league pass, actually i rewrite kodi addon for vlc, and i'm stuck at very beginning with LogIn function, i write working lua script in ZeroBrain Studio
http = require("socket.http")
json = require("dkjson")
ltn12 = require("ltn12")
https = require("ssl/https")
data = "username=user&password=pass"
res, code, response_headers, status = https.request {
response_body = {} ,
method = "POST",
headers= {
["Content-Type"]="application/x-www-form-urlencoded",
["Content-Length"] = data:len()
},
url = 'https://watch.nba.com/nba/secure/login?',
source = ltn12.source.string(data),
sink = ltn12.sink.table(response_body)
}
print (response_headers["set-cookie"])
Problem is that it uses "https". I've tried do this but get error
Error while running script C:\Program Files (x86)\VideoLAN\VLC\lua\extensions\nba_league_pass.lua, function (null)(): error loading module 'socket.core' from file '.\socket\core.dll': dynamic libraries not enabled; check your Lua installation
So, my question is how to make https request in vlc?
Thanks.
error loading module 'socket.core' from file '.\socket\core.dll': dynamic libraries not enabled; check your Lua installation
"dynamic libraries not enabled" usually indicates that your Lua interpreter is compiled without LUA_DL_DLL compilation flag (on Windows); specifying this compilation flag enables loading of dynamic libraries. (The Lua interpreter would be the one packaged with or embedded into VLC if that's what you are running.)

Cannot open File protocol links in Resource protocol page in Firefox 41

I've made a local file (log.html) in Firefox profile and tried to open it in an add-on page (add-on folder/data/log.html and it's shown as Resource protocol in URL bar).
self.port && self.port.on('add-log-path', function(payLoad) {
addLogPath(payLoad);
});
function addLogPath(url) {
// url == "file:///Users/usr/Library/Application Support/Firefox/Profiles/05rhodfg.cfxo/log.html"
$('#logpath').attr('href', url);
}
I've also tried changing that to JS method window.open
function addLogPath(url) {
$('#logpath').on("click", function() {
window.open(url);
});
}
But the error is
JavaScript error: , line 0: Error: Access to
'file:///Users/usr/Library/Application%20Support/Firefox/Profiles/05rhodfg.cfxo/log.html'
from script denied
BTW, before Firefox version 41, it has no problem doing this.
Can you suggest other workaround to solve this? Thank you!
edit:
added add-on example to reproduce the problem
download and run the following statement in Terminal:
$ cd fileProtocolExample && cfx run
Do self.data.url('filename_here') to get that path to your file.
It will look something like resource://your-extension-id/data/filename_here, then this should load fine. That resource:// in front is important, make sure you get and use that URL.
The file:// won't work, because your addon is packed in a zip. Its not extracted into the system. How did it work in Firefox 41? Was your addon unpacked at that time? This is an Addon-SDK addon right?

saving image from HTTP_RAW_POST_DATA does not work in MAMP

I'm using the following to upload an image from post data. it works on my server using php version: 5.2.16
When I try running the exact same script on my local server using MAMp and PHP Version 5.2.17
the file is not created.
if (isset($HTTP_RAW_POST_DATA))
{
// Get the data
$imageData=$HTTP_RAW_POST_DATA;
// Remove the headers (data:,) part.
// A real application should use them according to needs such as to check image type
$filteredData=substr($imageData, strpos($imageData, ",")+1);
// Need to decode before saving since the data we received is already base64 encoded
$unencodedData=base64_decode($filteredData);
echo "unencodedData: ".$unencodedData;
$key = microtime();
$key = md5($key);
// Save file.
$fp = fopen( '../../../uploadedImages/original/' . $key . '.jpg', 'wb' );
fwrite( $fp, $unencodedData);
fclose( $fp );
}
it looks like the post data does exist if I look at it in firebug. Any ideas why this isn't working in mamp?
Some things to try:
Check to make sure you are getting the raw data when the script is running on MAMP
Check the permissions of the directory it is trying to write to and make sure you have write access to it and apache has write access to it.
I had issues running some php modules on MAMP so I switched to using versions I installed using MacPorts. It gave me more control of extra extension I wanted to install and I got the latest versions of apache, php, and the php extensions.

Resources