Does anyone know of a script, preferably PHP-based that will allow conversion of a static flash to an image?
As long as you're talking about converting a flash DisplayObject (which nearly everything in flash is) to a jpeg, as3 core libs has a fantastic jpeg exporter that I use on a regular basis. It sends the converted jpeg or png as raw post data, so you can pretty much do anything you want with it on the php side of things.
You can get the as3corelib package here: http://github.com/mikechambers/as3corelib - There's many many tutorials on getting the bitmap encoder up and running all over the web, and it's super simple, but if you need help with that I can help as well.
Related
I am trying to optimize my website using pagespeed, and I got the advice to use JPEG2000 instead of normal JPG. So I converted all my images but when I changed the images it doesn't show on my laptop. So I checked "caniuse" and now I see that this extension is only supported on mobile phones (android and ios)
So how do I implement this in my website? Do I need to use javascript to change the extension to jpf if the device is a mobile phone?
I use picture and srcset based on screensize, but that doesn't work if I drag my screen smaller on my laptop.. Does anyone know how to use this new JPEG2000?
Someone gave you some really bad advice. Support for JPEG 2000 is very limited. It's likely you system simply cannot decode the image.
The problem with the JPEG standards is they are done from an academic egghead perspective. The original JPEG standard was entirely unimplementable. At the time there was no good 24-bpp format for photographs available so, as fate would have it a group of developers stepped in and filled the gaps in the standard. That resulted in the JFIF file format and the IJG encoder/decoder.
The JPEG2000 standard is even worse from an implementation point of view. It contains no end-to-end description of the encoding and decoding process. Add to that JPEG2000 provides limited benefits over existing image formats so there is is little incentive for developers to wade through the confusing standard and create implementations for it. Compare the PNG standard to the JPEG2000 and you will quickly see the difference. The PNG standard is a guide for implementors while the JPEG2000 standard seems like an academic paper.
As such, there is little incentive to adopt JPEG2000. It's just one of a myriad of image format out there that are rarely used.
JPEG 2000 is supported by Safari and no other browser.
Using it as the default image format is a terrible idea.
You could use srcset to provide images in a range of formats for clients with different levels of support.
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.
I would like to know if it could be possible to convert an swf file, with his flashvars to a bitmap image. But all that in PHP, is it possible ? I precise that I would like to do it several times, and that the .swf file is not mine (is not on my site, I take it from a other site).
I allready thank you for your answers ! :)
I think the closest you will get is with SWFTOOLS: http://www.swftools.org/
It can extract bitmaps and flashvars. There are windows and linux binaries available so you'll have to run it from the commandline, that should not be a problem. The main problem of converting an swf to jpeg is that a lot of flash files require execution of ActionsScript in order to show something usefull, and then still you have to have the right frame, so it might not be so straightforward.
So my answer would be: Yes, it might be possible if the movie is very simple and only consists of simple bitmaps. But also no: for most swf's it will be very difficult without a flash client and screenshot capabilities if you really need the output of the movie.
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.