Is there a native Javascript module that allows creating / modifying EXIF and IPTC sections inside the JPEG file ?
Note: I already have the Exif data of the image that I am receiving from iPhone along with the image. Since he image does not include all the metadata in itself, I want to combine it and save it on my server.
I came across a one module in my search but that seems abandoned and it never implemented writing of EXIF.
https://github.com/logicalparadox/exifdata
Does anyone know of a pure Javascript module that I can use ?
I did find a C library "libexif" that can do the job. I have not tested it yet. I'm still trying to stay with Javascript.
Write exif data to jpg using libexif
Thanks in advance.
PiexifJS did the job for me. Runs on the browser and on node. No external dependencies.
Related
I was working on a little app and I was trying to upload images to Parse. These images are taken with camera using the cordova camera plugin (I am using ngCordova). Well my question is, the camera plugin can return the image in base64 or an url. I've read that is not a good practice manipulating base64 encoded images because this leads to memory problems. The alternative I think was using Cordova File Transfer plugin but the problem is Parse does not support "multipart/form-data". So, What method should I use to upload images to Parse? I also thought of using Javascript Parse SDK which lets me upload files in base64 but I am still concern of memory leaks.
Thanks you all very much
You can probably set chunkedMode on the file transfer plugin to false to avoid multipart being sent. The problem is that then you've still got to read the whole thing into memory in order to send it and you won't be able to get the progress callback. I don't know if this matters but it should help to get around the restriction.
I have a node web app that needs to convert a docx file into pdf (using client side resources only and no plugins). I've found a possible solution by converting my docx into HTML using docxjs and then HTML to PDF using jspdf (docx->HTML->PDF).
This solution could make it but I encountered several issues especially with rendering. I know that docxjs doesn't keep the same rendering in HTML as the docx file so it is a problem...
So my question is do you know any free module/solution that could directly do the job without going through HTML (I'm open to odt as a source as well)? If not, what would you advise me to do?
Thanks
As you already know there is no ready-to-use and open libs for this.. You just can't get good results with available variants. My suggesition is:
Use third party API. Like https://market.mashape.com/convertapi/word2pdf-1#!documentation
Create your own service for this purpose. If you have such ability, I suggest to create a small server on node.js (I bet you know how to do this). You can use Libreoffice as a good converter with good render quality like this:
libreoffice -headless -invisible -convert-to pdf {$file_name} -outdir /www-disk/
Don't forget that this is usually takes a lot of time, do not block the request-answer flow: use separate process for each convert operation.
And the last thing. Libreoffice is not very lightweight but it has good quality. You can also find notable unoconv tool.
As of January 2019, there is docx-wasm, which works in node and performs the conversion locally where node is installed. Proprietary but freemium.
It appears that even after three years ncohen had not found an answer. It was also unclear if it had to be a free (as in dollars) solution.
The original requirements were:
using client side resources only and no plugins
Do you mean you don't want server side conversion? Right, I would like my app to be totally autonomous.
Since all the other answers/comments only offered server side component solutions, which the author clearly stated was not what they wanted, here is a proposed answer.
The company I work for has had this solution for a few years now, that can convert DOCX (not odt yet) files to PDF completely in the browser, with no server side component required. This currently uses either asm.js/PNaCl/WASM depending on the exact browser being used.
https://www.pdftron.com/samples/web/samples/viewing/viewing/
Open an office file using the demo above, and you will see no server communication. Everything is done client side. This demo works on mobile browsers also.
I would like to implement an in-browser Microsoft Word document merge feature that will convert the merged document into PDF and offer it to the user for download. I would like to this process to be supported in Google Chrome and Firefox. Here is how I would like it to work:
Client-side JavaScript obtains the Word template document in docx format, either from a server, or by asking the user for a file upload (which it can then read using the FileReader API)
The JavaScript uses its local data structures (e.g., data lists it has obtained via Ajax) to expand the template into a document. It can do this either directly, by unzipping the docx file and processing its contents, or using DOCx.js. The template expansion is just a matter of substituting template variables with values obtained from the local data structures.
The JavaScript then converts the expanded template into PDF.
The JavaScript offers the PDF file to the user for download, e.g., using Downloadify.
The difficulty I am having is in step 3. My understanding (based on all the Googling I have done so far) is that I have the following options:
Require that the local machine is a Windows machine, and invoke Word on it, to convert to PDF. This can be done using a little bit of scripting using WScript.shell, and it looks doable with Internet Explorer. But based on what I have read, it doesn't look like I can call WScript.shell from within either Chrome or Firefox, because of their security constraints.
I am open to trying Silverlight to do the conversion, but I have not found enough documentation on how to do this. Ideally, if I used Silverlight, I would like to write the Silverlight code in JavaScript, because (a) I don't know much CSharp, and (b) I think it would be much easier in JavaScript.
Create a web service that will convert a given docx file to a pdf file, and invoke that service via Ajax. I would rather not do this, if possible, for a few reasons: (a) I tried using docx4java (I am a reasonably skilled Java programmer) but the conversion process is far too slow, and it does not preserve document content very well; and (b) I would like to avoid a call out to the network, to avoid security issues. It does seem possible to write a little service on a Windows server for doing the conversion, and if there is no other good option, I might go that route.
If I have been unclear about anything, please let me know. I would appreciate your ideas and feedback.
I love command line tools.
Load the doc to your server and use LibreOffice to convert it to PDF via the command line
soffice.exe --headless --convert-to pdf --outdir E:\Docs\Out E:\Docs\In\a.doc
You can display a progress bar to the user and when complete give them the option to download the doc.
More info on LibreOffice's command line parameters go here
Done.
Old old question now, but for anyone who stumbles across this, web assembly (wasm) now makes this sort of approach possible.
We've just released https://www.npmjs.com/package/#nativedocuments/docx-wasm which can perform the conversion locally.
Could someone please help me with this situation:
I have to retrieve images (stored in BLOB) from an Oracle SQL Database.
This is already done and images are pushed into a temporary attribute in HEX.
These images are later pushed to a Directory Server using LDAP.
The only problem is, that I want to resize each image to a specific size and add a simple border on the fly using Javascript without using the file system of the host, before pushing them to the LDAP Directory Server.
Note: I can't use browser specific methods or objects, since my java runtime is used by a different host rather than a browser.
It's been a week since I am looking for a solution and unfortunately, I haven't found one yet.
Any advice will be greatly appreciated!
Thanks in advance!
Bobby
Mentioning Oracle and LDAP makes me think that your JS runtime is not a browser. But if it is, you can use canvas for both resizing and adding border, you can then get the data back as data URL using canvasEl.toDataURL('image/png'). Read up on how to use canvas https://developer.mozilla.org/en/Canvas_tutorial
Since File API will enable access to the content of local files it is now possible to do image resize before upload (a fairly common task) without any additional technology like Flash or Silverlight. Except that I can't find any Javascript library that would be able to handle images in binary form. Is there any? Maybe there is some in Flashe's ECMA script that could be adapted, but I simply can't find anything.
Although I haven't find such libs, I have found a way how to accomplish the described task:
Read image as Data URL
Load an image into a canvas tag and resize it
Encode canvas image data into some image format, for example JPG. Or use Canvas.toDataUrl() and then (optionaly) some base64 decoder.
Client side image resizing and upload with pure javascript. That's cool, isn't it?
Even if you do find something that understands images in pure javascript, you would still need the DOM to render it, making it incredibly slow.
Don't know if this is what you want, but there are some scripts on Userscripts.org that handle images: http://userscripts.org/scripts/show/38736
One problem with calavera.info's answer (sorry I cannot seem to comment directly on that answer) is that the call to either CanvasRenderingContext2D.getImageData or Canvas.toDataURL mentioned in the third bullet will fail. They each throw a SECURITY_ERR: DOM Exception 18 as the image is not from the same origin or domain as the document that owns the canvas element. That seems inevitable since the image comes from the local file system (via an input type="file" tag), but the page comes from your web server.