Compress HTML string containing embeded image with javascript - javascript

I am trying to do a javascript app which uses local storage to store HTML data which occasionally contains embedded images.but the problem is here i am apposed to a size constraint.do you guys know of any javascript library to compress HTML with embedded image?
I have tried lz-string but it fails with embedded image.any idea?

It's probably JPEG images that is embedded, right? You cannot compress the images any further anyway, so focus on the HTML. On desktop browsers you probably just have 10MB of local storage, so It's not the best solutions I'm afraid.
For HTML compression, I would also recommend lz-string.

Related

How can I prevent a PDF file from being downloaded or printed with PHP or JavaScript?

I am looking for ways to present a PDF file in the browser but make it not downloadable or printable.
If someone really goes through all the trouble to disable the JavaScript library or anything like that, that is fine. This is more for the reason that the content within the PDF will be updated regularly so if you download it it will be out of date by the next day.
I also cannot rely on marking the pdf as protected or encryption as a reasonable way to accomplish this.
If you have any library recommendations or anything else it would be appreciated. I am currently exploring if it is feasible using PDF.js and ViewerJS
I was able to find a solution using ViewerJS and this CSS. The CSS shows a blank page when you try to print (ViewerJS already distorts it to a non-printable state) and ViewerJS prevents you from downloading as a PDF file and instead tries to save as an HTML file.
This meets the requirements of making it just inconvenient enough to discourage users from trying to download the file since the file is always easily accessible on almost any page of the site.
https://gist.github.com/ActuallyConnor/2a80403c7827dd1f78077fb2b5b7e785

Is it possible to store a whole webpage in a single binary file and display the site using JS?

Assuming I have some images, css and html concatenated in one file. Is it possible to use JS to display the html with images and css properly by ripping up the concatenated binary file somehow?
There are some ways to pack everything into a single file. But all of them are not crossbrowser. Everything depends on your goals.
Take a look at these formats:
MHTML http://en.wikipedia.org/wiki/MHTML
Webarchive http://en.wikipedia.org/wiki/Webarchive
Mozilla Archive Format http://en.wikipedia.org/wiki/Mozilla_Archive_Format
All of them are browser specific and even requires some extensions to be installed.
The easiest and the most supported way is to put all css and js files right into your html file. And use data:uri format to include your images into html.
Theoretically it is even possible to write a binary file reader in javascript.

What is the way to store image files and audio files in a Windows Modern(Metro) UI apps?

I have around 30 image files and 30 audio files in my Windows 8 Modern(Metro) UI app.Currently my application size is around 30MB.I want to reduce the size of my app.
So is there a way to repesent image files and aduio files in the format of the text/strings using any WinJS API ,so that it reduces size of the application.
If your images or audio are uncompressed for some reason, you could certainly use a compressed format (jpeg or mp3 for example). But, one methodology you might follow to reduce the size of your appx would be to only include images and audio that you immediately need and download the rest from a web service when the app first runs or when the files are actually needed. There is a Compressor Class in WinRT, but it will not give you any real compression benefit over an already compressed image type like jpeg or audio type like mp3.
30MB is an acceptable size for a Windows 8 App. Why are you concerned about the size?
Storing your images as zipped resources won't help because .appx packages are already compressed so all you would do is CPU overhead at runtime because you need to uncompress unnecessarily.
I wouldn't worry about it too much. 30MB is okay but of course you should always strive to keep your size to a minimum. One sure way to reduce size is to be smart on how you store your images and audio files.
For audio files
Check that you don't have uncompressed files (.wav).
Check that your .mp3 files or similar use an appropriate bitrate. You probably only need 128kbps
For image files
Check that your image files use an appropriate compression method. Some files might be okay to store as JPEG, others are best stored as GIF while still others might be best to be stored as PNG.
Optimize your PNG files with tools like PNG Gauntlet. These tools bring down file sizes substantially without reducing quality of the PNG files.
Windows 8 Scaling support
Also, make sure that your images properly support windows 8 image scaling. More information can be found here.

Security considerations when using canvas in conjunction with file uploading

I'm working on a image editor/uploader based around Pixastic where I grab image data out of an <input> tag, put it into a canvas, and after manipulating it, encode the data in base 64 and post it to my app with javascript, where it will be saved as a new image file. If it were a standard file upload, I would give the file a new (safe) name, test to make sure it was really an image file and copy it to strip any potentially malicious/personal EXIF data before making it available to users.
My question is - do those security measures make sense in the canvas situation, or are they pointless? Additionally, are there any security issues with my approach that I'm overlooking?
Fyi: the serverside decoding/etc will be done with php.
Thanks.
Some of what you have asked (Not sure if all) are discussed by Shiflett Here
Check it and comment what you think of it!

How to display local image using Flash?

Suppose that, I have local image path that get from <input type="file"... web control using javascript.
I want to pass this path to Flash object and display that image in it.
I believe what you are looking for info on is FlashVars.
Flash Vars are ways to pass data to swf files. Very similar to Query Strings.
They size limit is 64k and are support on Flash Player 6 and newer I believe.
Here is the adobe site on them.
I hope this helps some

Categories

Resources