Problem using 'websave'
Afficher commentaires plus anciens
Hi
I'm using 'websave' to save an url into an image file.
Code as below:
url='http://www.clker.com/cliparts/Q/9/h/4/M/z/female-icon.svg'; filename='female.png'; outfile=websave(filename,url);
However, the saved image file can't be opened. The thumbnail looks like shown below.

However, if I open the url in the web browser and save it manually, I could actually save it as a .png file since it has this option shown in the screenshot below.

After saved it this way, the thumbnail looks something like below

So I wonder why 'websave' saved the image but the image couldn't be displayed properly. Because when I saved it manually it worked fine and I suppose 'websave' does the same job.
Could anyone help?
Many thanks.
7 commentaires
Eric Maris
le 26 Mar 2018
It is not good that MathWorks is not following up on this question. If they did, then they would have found out that the websave function does not correctly transfer data between a webserver and a local storage system. I got into serious trouble downloading zip files from a colleague's webserver, and then decided to check the md5sum hash of the files (which I obtained from my colleague). The md5sum hash of the downloaded files were different. When using the Linux wget command instead of websave, the hash was identical to the one I obtained from my colleague.
best, Eric Maris
Rik
le 26 Mar 2018
That sounds like a different issue from this question. This question is merely someone assuming websave will detect the file type of the remote file and the file type of the local file name and perform a conversion. If you found a bug, you should contact Mathworks support (see the contact us button). If you open your own question and show the code you used, we might be able to help you find a possible bug in your code.
Eric Maris
le 26 Mar 2018
Come on, Rik, the downloaded file should be identical independent of the function used to download. The fact that the one downloaded via websave could not be opened (and the other one could) should have made you suspicious.
Eric Maris
le 26 Mar 2018
I filed a bug report to Mathworks support.
Rik
le 26 Mar 2018
Yes, files should be identical whatever the function used, but that is not what OP describes. It looks like the browser offers a 'save as' option that includes a conversion from one file type (svg) to another (png). That is something completely different from simply saving that svg file with another extension. Why would it make me suspicious that simply changing the extension doesn't result in a converted file?
Anyway, I'dd be interested to know the result of that bug report.
Guillaume
le 26 Mar 2018
I agree with Rik, the initial bug report is a non-bug. Just somebody not realising that right-clicking Save image as... is not the same at all as saving the original file.
As for the problem with the zip file, while bugs are always possible, the bulk of the work of websave is handed down to Java. It is very unlikely that there is a bug in the Java code. I would suspect that it may be some connection issues or possibly an incorrectly configured webserver.
Walter Roberson
le 26 Mar 2018
"It is not good that MathWorks is not following up on this question."
This resource, MATLAB Answers, is not an official MATLAB technical support site: it is a site for community members to help other community members. Mathworks does not read the questions (not unless someone opens a bug report and points them to the question.)
Réponses (0)
Catégories
En savoir plus sur String Parsing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!