{"_id":"@codemotion/j-i-c","_rev":"14-70f9c4084c2818331d83d5d3c32a2552","name":"@codemotion/j-i-c","description":"J I C is a Javascript Image Compressor using HTML5 Canvas & File API that allows you to compress your jpeg & png images before uploading to the server (100% client-side and no extra libraries required!)","dist-tags":{"latest":"2.0.2"},"versions":{"2.0.2":{"name":"@codemotion/j-i-c","version":"2.0.2","description":"J I C is a Javascript Image Compressor using HTML5 Canvas & File API that allows you to compress your jpeg & png images before uploading to the server (100% client-side and no extra libraries required!)","main":"src/JIC.js","directories":{"example":"example"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/codemotionapps/J-I-C.git"},"keywords":["javascript","image","compressor","js","canvas","html5"],"author":{"name":"Bruno Barbieri"},"license":"MIT","bugs":{"url":"https://github.com/codemotionapps/J-I-C/issues"},"homepage":"https://github.com/codemotionapps/J-I-C#readme","gitHead":"a7bbe70f29bb97b0b15a5f414cf572600e5725e1","_id":"@codemotion/j-i-c@2.0.2","_shasum":"f693b0605b63d17f76649d2bb59bb28202340788","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.1","_npmUser":{"name":"dimitarnestorov","email":"mitkones@gmail.com"},"dist":{"shasum":"f693b0605b63d17f76649d2bb59bb28202340788","tarball":"https://registry.npmjs.org/@codemotion/j-i-c/-/j-i-c-2.0.2.tgz","integrity":"sha512-79AV/LjSspfW/HwCCY+uDJRDuLNfW6ONrbNqgKw6uCtVXHrXSoHGkZeWkQaUqDEX8xDuovPXqdQMq4fmghkroQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFzliWfmgqzZgrnznYyFhaiWtoAP0fDblAbHBoyKVjhXAiEA17Rd4rmKfMyZGLYBYNqqGW/57Di+sQUqpqCIU2oiLXQ="}]},"maintainers":[{"name":"dimitarnestorov","email":"mitkones@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/j-i-c-2.0.2.tgz_1499088433849_0.1973896659910679"}}},"readme":"# J I C \n**J I C** is a Javascript Image Compressor using HTML5 Canvas & File API that allows you to compress your jpeg & png images before uploading to the server (100% client-side and no extra libraries requried!)\n\nCould you imagine how much bandwidth we can save if Google, Twitter and r Facebook implement this image compression before we upload those 5MB photos? This approach will make the internet faster!!\n\nYou can check the working demo here : http://makeitsolutions.com/labs/jic/\n\n## Requirements or Dependencies\n\n- NONE\n\n## Install via NPM\n\n```sh\nnpm install j-i-c\n```\n\n## Install via Bower\n\n```sh\nbower install JIC\n```\n\n\n## How it works\n\nTo compress the image, first it converts an image object to canvas and then compress it with the canvas method **toDataURL(mimetype, quality)**\n\nThen to upload the image object it uses the XMLHTTPRequest method sendAsBinary and sends the data url of the compressed image to the server and that's all!! Easy huh? \n\n\n## Example\n\n**J I C** has only 2 methods: compress & upload. Check it out:\n\n```javascript\n\n//========= Step 1 - Client Side Compression ===========\n\n//Images Objects\nvar source_img = document.getElementById(\"source_img\"),\n    target_img = document.getElementById(\"target_img\");\n\n//(NOTE: see the examples/js/demo.js file to understand how this object could be a local image \n//from your filesystem using the File API)\n\n//An Integer from 0 to 100\nvar quality =  80,\n// output file format (jpg || png)\noutput_format = 'jpg', \n//This function returns an Image Object \ntarget_img.src = jic.compress(source_img,quality,output_format).src;  \n\n\n//======= Step 2 - Upload compressed image to server =========\n\n//Here we set the params like endpoint, var name (server side) and filename\nvar server_endpoint = 'upload.php',\n\tserver_var_name = 'file',\n\tfilename = \"new.jpg\";\n\n//This is the callback that will be triggered once the upload is completed\nvar callback = function(response){ console.log(response); }\n\n//Here goes the magic\njic.upload(target_img, server_endpoint, server_var_name, filename, callback);\n\n//=======  Optional parameters example: errorCallback, duringCallback and customHeaders ======= \n// This function gets called on an error response of the server - status code of >= 400.\nvar errorCallback = function () {\n\t// Handle upload failure\n};\n\n// This function gets called while the file is uploading. Returns the percent completeness of the image being uploaded\nvar duringCallback = function (progressPercent) {\n\t//progressPercent can be used to show a progress bar\n};\n\n// Custom Request Headers, nifty for things like Basic Authorization\n\nvar customHeaders = { 'Authorization': 'Basic someBase64EncodedHash=====' };\n\njic.upload(target_img, server_endpoint, server_var_name, filename, successCallback, errorCallback, duringCallback, customHeaders);\n\n\n```\n\n\nCollaborators\n-------\n\n- [@JustinBeaudry](https://github.com/JustinBeaudry)  - Added MIT License\n\n- [@davidfq](https://github.com/davidfq) - Updated readme\n\n- [@alastairparagas](https://github.com/alastairparagas) - Added errorCallback, progressCallback and customHeaders parameters\n \n\nLicense\n-------\n\nThis code is released under the [MIT License\nlicense](http://opensource.org/licenses/MIT)\n\nCopyright (c) 2012 Bruno Barbieri\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\nEnjoy!\n","maintainers":[{"email":"uffo686@gmail.com","name":"uffo"},{"email":"nikolay@yanev.co","name":"nyanev"},{"email":"nikolas181492@gmail.com","name":"nikolay_543"}],"time":{"modified":"2023-05-30T09:21:17.513Z","created":"2017-07-03T13:27:16.013Z","2.0.2":"2017-07-03T13:27:16.013Z"},"homepage":"https://github.com/codemotionapps/J-I-C#readme","keywords":["javascript","image","compressor","js","canvas","html5"],"repository":{"type":"git","url":"git+https://github.com/codemotionapps/J-I-C.git"},"author":{"name":"Bruno Barbieri"},"bugs":{"url":"https://github.com/codemotionapps/J-I-C/issues"},"license":"MIT","readmeFilename":"README.md"}