I have a html5 based mobile application, where I send data from the server (PHP) in textual format.
The problem is that my Data is pretty big, around 18Mo but when compressed using gzcompress it became a lot smaller.
My Problem is how uncompress the string back in JavaScript I used the plugin JXG and its working very well in both browser and simulator but the app crashes when running in my iPad 2, does any one know a better way ?
A few month ago, I made a function which uncompress gzip files... Try it... Hope this help you. If you have some question, mail me !
Related
I need to convert .pdf -file to .zpl -label file for printing with zebra printers, but is this even possible?
The PDF comes in as a base64 encoded string, and somehow I need to output that as a .zpl -file.
I use PHP in my project, and I prefer the method in PHP, but basically any programming language is fine, as long as it gets the job done.
I was thinking about converting the PDF to image(which seems to be possible by quick googling), and then from image(PNG, JPG, etc.) to ZPL(which also seems to be ok by quick googling), but does anyone have any knowledge about this kind of operation or any insights before I start to do this? I'm on a tight schedule here, and I cannot afford any fruitless work.
Update 4.8.2016
I went the other way and created the ZPL from the scratch because it keeps our service faster than doing some conversions. So I don't have any more info on this than what the google already offers, if someone comes wondering about this same thing. PS. ZPL isn't that hard of a language. ;)
I had the some problem to solve: take a PDF file, convert it into ZPL code somehow and print it using a Zebra printer.
Thanks to stackoverflow and the ZPL Programming Guide, I learned about embedding bitmaps with the Graphic Field command (^GF).
Basically, you have to do these steps:
Render a PDF file as a bitmap
Make it monochrome
Convert the bitmap into ASCII hexadecimal (as defined by ZPL)
Compress the ASCII hexadecimal (otherwise our printers struggled with megabytes of bitmap data)
Put the data into this code template ^XA^GFA{some parameters and tons of bitmap data}^XZ
Our services were running on ASP.NET so I wrote a C# library to do just that. It wraps the native calls to Google's PDFium for rendering and returns a string with valid ZPL code for printing.
You could convert base64 encoded PDF files like that:
public static string GetZplCode(string pdfBase64, int page = 0, int dpi = 203)
{
return PDFtoZPL.Conversion.ConvertPdfPage(pdfBase64, page: page, dpi: dpi);
}
I hope this nuget package will prevent others from spending weeks in searching on how to make this ^GF command work.
A mobile AIR app needs to send a large image to the back end for later display in a web page.
It takes for ever for PNGEncoder in the AIR app to complete, so the idea is to convert the image data to a ByteArray, compress it and send it to the PHP backend where it is saved as PNG by the PHP code. So I'm looking to port PNGEncoder.as and BitmapData class to PHP to accomplish this. I found PNGEncoder.as in as3corelib but can't find source for BitmapData class that it uses.
So the questions are
1. Is there code out there that does what I'm trying to do?
2. Where can I find BitmapData source code?
3. Is there another way to accomplish this that I'm missing?
Note1. I realize that I can decompile airglobal.swf where BitmapData resides, but looking for a cleaner way
Note2. I'm aware of AMFPHP but it does not support BitmapData type
Thanks
Andy
I see two solutions to this issue.
First, you can consider using a Worker to do just the conversion and sending routine, because image conversion is a pretty standalone and straightforward task to offload, and since most modern devices have more than one core anyway, it's better to put the hardware to work on the client rather than on server. Of course, you will have to take some measures to provide the worker instance with required data and to properly upload the image (cookies might not be handled well in a worker), but this approach is generally cleaner and requires no server side alterations.
The second approach is to use BitmapData.getPixels() to convert a region of pixels into a sequence of bytes, then send them unaltered to the server for conversion. Be warned however, the amount of data in a raw bitmap can be too large for the server to accept, you are looking to no less than 4 bytes per pixel, as bitmaps in AS3 are 32-bit. You can use a server side image encoder to convert raw data on the server after uploading.
hello i was wondering what is a good way to forward my web cam stream to my php server? I am not quite sure how to do this other than saving the video as a file and transferring it to my server or capture frame images every x amount of time and sending it to my server. i was wondering if there were other methods available other than this?
thank you.
I am not sure what exactly is the intent but you might be interested in something like http://www.red5-recorder.com/
For video chat look into this http://www.tokbox.com/opentok/api , I have tested this and its awesome!
I'm doing a bit of preliminary research on an upcoming project and I have a quick question that I figure I'll throw up here while I look elsewhere, in case anyone has any experience with this.
The question is simple: is it possible to read a QR code using JavaScript? Is there a remote service to which I can pass a bitmap object from a camera and do it that way? Are there currently any libraries that allow this?
The project is going to be deployed to various mobile devices and we'd like to try to use Appcelerator to make it work. I know Appcelerator does expose the Camera API on its host devices, but whatever we do with it has to be able to parse QR codes. Is this something that can be done?
Thanks in advance!
myk
I bet it's possible, but it would be a challenge. Someone's written an AS3 library for reading QR codes. I'd start by reading up on image manipulation in Canvas.
If you go down the remote API route, Kaywa have an API you may be able to use.
You can use the getUserMedia API to get video from the webcam and you could put it into a canvas element and use the canvas to read the pixels and decode a QR code.
I don't know of a library to decode QR codes but here is one library that can do bar codes.
There's a javascript library already, however the comments are mostly in Japanese and there's no documentation.
Because of memory limits for JavaScript on mobile devices, it's likely to take too long for practical use, if it is possible with purely JS.
I don't know exactly how the Appcelerator API works with external native libraries, but your best bet is to pass the image data to the native code (Objective-C or Java) and then use a lower-level library (like iphone-qrcode) to parse the QR code, then pass the result back to the JS execution context.
This has the added advantage of working offline, which a remote service could not do.
If you want a proof-of-concept, then here it is - a motion tracker written in pure Javascript.
However, support for it is not widespread right now. Only FF and the latest Webkit builds support it afaik.
Just noticed that you wanted this for a mobile device. Then absolutely go with a remote service. It will be really taxing even on the most high end devices assuming they even support it, which I highly doubt.
I'm sure this has been asked before, but as I can't seem to find a good answer, here I am, asking... again. :)
Is there any way, using only a mixture of HTML, JavaScript/AJAX, and PHP, to report the actual progress of a file upload?
In reply to anyone suggesting SWFUpload or similar:
I know all about it. Been down that road. I'm looking for a 100% pure solution (and yes, I know I probably won't get it).
Monitoring your file uploads with PHP/Javascript requires the PECL extension:
uploadprogress
A good example of the code needed to display the progress to your users is:
Uber Uploader
If I'm not mistaken it uses JQuery to communicate with PHP.
You could also write it yourself, It's not that complex.
Add a hidden element as the first element of upload form, named UPLOAD_IDENTIFIER.
Poll a PHP script that calls uploadprogress_get_info( UPLOAD_IDENTIFIER )
It return an array containing the following:
time_start - The time that the upload began (unix timestamp),
time_last - The time that the progress info was last updated,
speed_average - Average speed in bytes per second,
speed_last - Last measured speed in bytes per second,
bytes_uploaded - Number of bytes uploaded so far,
bytes_total - The value of the Content-Length header sent by the browser,
files_uploaded - Number of files uploaded so far,
est_sec - Estimated number of seconds remaining.
Let PHP return the info to Javascript and you should have plenty of information.
Depending on the audience, you will likely not use all the info available.
If you have APC installed (and by this point, you really should; it'll be standard in PHP6), it has an option to enable upload tracking.
There's some documentation, and Rasmus has written a code sample that uses YUI.
If you're able to add PECL packages into your PHP, there is the uploadprogress package.
The simplest way would be to just use swfupload, though.
Is there any way, using only a mixture of HTML, JavaScript/AJAX, and PHP, to report the actual progress of a file upload?
I don't know of any way to monitor plain HTML (multipart/form-data) file uploads in webserver-loaded PHP.
You need to have access to the progress of the multipart/form-data parser as the data comes in, but this looks impossible because the ways of accessing the HTTP request body from PHP ($HTTP_RAW_POST_DATA and php://input) are documented as being “not available with enctype="multipart/form-data"”.
You could do a script-assisted file upload in Firefox using an upload field's FileList to grab the contents of a file to submit in a segmented or non-multipart way. Still a bunch of work to parse though.
(You could even run a PHP script as a standalone server on another port just for receiving file uploads, using your own HTTP-handling code. But that's a huge amount of work for relatively little gain.)
I'd recommend you to five FancyUpload a try it's a really cool solution for progress bar and it's not necesarely attached to php. Checkout also the other tools at digitarald.de
cheers
IMHO, this is the problem that Web browsers should solve. We have progress meter for downloads, so why not for uploads as well?
Take a look at this for example:
http://www.fireuploader.com/