Application :
A Flash animation should have appeared here, but it seems that your browser has an older version of the Flash Player or it is not installed at all. Please, install the last release of the Flash Player now, then reload this page.
Here is an application i had to develop in Actionscript 3, it lets you capture any content into a JPEG file (JPEG Encoding corelib class) with quality settings and size infos, you can choose between two modes, that lets you save the file on the server or your hard-disk.
Updated on the 09/20/06 : added FLV playback features
Updated on the 10/04/06 : added video navigation bar
Sources : Download
New AMFPHP Version available here
Comments (62)
Hi, any chance to post code?
hi wendel,
let me add some more goodies to the tool and i’ll post the source code, stay tuned
it’s not working ot Fire Fox
but BRAVO – nice work
beau bouleau !
et peut ont faire dialoguer cela avec de l’AS2 ?
flashm >> It’s corrected
How are you posting this back to the server? Are you using base64 and a normal post, or are you using a remote object?
hi jmcwill,
to send this to the server, no need to encode it as Base64, this would be needed for sending the image with SMTP, just add an extra header with the URLRequestHeader saying it’s application-octet stream data and you will receive the bytes on the server in $GLOBALS["HTTP_RAW_POST_DATA"] then just write it
regards,
Thibault
I see, thanks. That is the same header that is sent with the file reference upload by flash. I was going to try to change the URLRequestHeader to make it seem like a file upload so I could set a filename and “fake” a file upload like a browser would. This way Java or PHP could catch it in the FILES array instead of raw data. I don’t think we have that much control over the headers though, unfortunately. The raw post data stream I will try though.
Thanks,
Jason
hi,
i’m glad you like the application, AS3 gives us real power with plenty of new player API’s, for this application the really cool thing is the getPixels() method which returns a bytearray containing pixels color from a particular rectangle in a BitmapData, that really rocks
Hi,
This is a fantastic tool. Any chance you can post the source code soon.
Thanks!
Hello,
Source would be wonderful! I played with the JPEGEncoder in Flash9 Alpha for a bit… *brain not computing* meaning, I just plain couldn’t get it to work.
Fantastic job, keep it up!
Paul
Would love to see the source also. In particular I’m curious how you can offer to save the snapshot immediately as a download.
hey, great job with JPEG Encoder. I have question – do you used in this PHP code?
hi stanislav,
yes PHP is needed in order to write the bytes on the server and to get the download window, the player can’t do that by itself
cheers
OK. So you don’t use PHP, to save JPEG. Cool I can use that. When will you post source code… or planning to do that? Please contact me dfm@abv.bg, I have something in mind.
hi guys,
sources available
Hey, this is cool – just trying to think of some places where I could really use this – is it possible to access byte data of a file (selected through the upload functionality) before the file is sent to the server? Imagine a cool web interface for uploading images directly to your site in which you can crop tweak and compress images before uploading them!
hi Jon,
I have done some research about loading an image into the player and modify it (scale, crop, etc) before the file is sent to the server, but there is no way to access the bytes of the selected file with the FileReference class.
What is possible is to select the file, upload it, load it again with Loader and display it, then work on the image then save the new version, but this is not really optimized.
My code don’t work.
I download the source code, and open my flash (ver 8.0). Then I try to test the aplication and the flash lunch this messages.
**Error** C:\Documents and Settings\KIKOCC\Escritorio\Flash\jpeg_encoder_source\asfiles\encoding\JPEGEncoder.as: Línea 1: Error de sintaxis.
package asfiles.encoding
**Error** C:\Documents and Settings\KIKOCC\Escritorio\Flash\jpeg_encoder_source\asfiles\encoding\JPEGEncoder.as: Línea 2: Los scripts de clase ActionScript 2.0 sólo pueden definir construcciones de clase o interfaz.
{
**Error** C:\Documents and Settings\KIKOCC\Escritorio\Flash\jpeg_encoder_source\asfiles\encoding\JPEGEncoder.as: Línea 7: Atributo utilizado fuera de una clase.
public class BitString {
**Error** C:\Documents and Settings\KIKOCC\Escritorio\Flash\jpeg_encoder_source\asfiles\encoding\JPEGEncoder.as: Línea 8: No se pudo cargar la clase o interfaz ‘int’.
public var len:int = 0;
**Error** C:\Documents and Settings\KIKOCC\Escritorio\Flash\jpeg_encoder_source\asfiles\encoding\JPEGEncoder.as: Línea 9: No se pudo cargar la clase o interfaz ‘int’.
public var val:int = 0;
**Error** C:\Documents and Settings\KIKOCC\Escritorio\Flash\jpeg_encoder_source\asfiles\encoding\JPEGEncoder.as: Línea 12: Atributo utilizado fuera de una clase.
public class JPEGEncoder
**Error** C:\Documents and Settings\KIKOCC\Escritorio\Flash\jpeg_encoder_source\asfiles\encoding\JPEGEncoder.as: Línea 13: La clase que se está compilando, ‘JPEGEncoder’, no coincide con la clase que se importó, ‘asfiles.encoding.JPEGEncoder’.
{
**Error** C:\Documents and Settings\KIKOCC\Escritorio\Flash\jpeg_encoder_source\asfiles\encoding\JPEGEncoder.as: Línea 33: No se pudo cargar la clase o interfaz ‘int’.
private function initQuantTables(sf:int):void
**Error** C:\Documents and Settings\KIKOCC\Escritorio\Flash\jpeg_encoder_source\asfiles\encoding\JPEGEncoder.as: Línea 45: No se pudo cargar la clase o interfaz ‘int’.
for (var i:int = 0; i
What can I do?
I’m new on this themes
Thank you
hi kiko,
you need to open and run the files under Flash 9 Alpha, it’s an AS3 project, you can download Flash 9 Alpha on the labs
labs.adobe.com
cheers,
Thibault
bonjour thibault,
j’ai un souci d’utilisation de ta classe d’encodage JPEG.
Lorsque je veux instancier un objet de type JPEGEncoder, j’ai ce message d’erreur :
Type was not found or was not a compile-time constant: JPEGEncoder.
var monEncodeur:JPEGEncoder = new JPEGEncoder(50);//on définit la qualité de l’encodage jpeg
As-tu une idée ?
merci d’avance
salut tannoy,
as tu bien vérifié que la classe est bien importée en début de script ?
le compilateur ne semble pas trouver la classe, elle ne doit pas être importée,
salut thibault
la classe est bien importée sur la première ligne de script. Bizaremment, ça fonctionne bien si je mets la classe ainsi que mon fichier dans le dossier créé lors de la forma regart alors que si je copie ces fichiers dans un autre dossier, j’ai le message. bizarre non ?
Thank you so much! I’ve been looking for a solution to encode and export JPEGs for hours before I see your code and now it works!! thank you!!!
Has anyone tried speeding up the algorithm yet? On my old PC it takes about 6 seconds to compress a 640×480 image. I’d love to get it down to about 1 sec.
Looking at the algorithm, I see a lot of floating point calculations, so I wonder if some of them could be converted to integer operations, but I don’t know where to start. Any suggestions?
hi sander,
this is something that can be greatly optimized, I don’t have much time for this one right now, but send me an email and we’ll talk about it
Hello,
I’m working on an online repository for artistic tools implemented in AS3– exotic paintbrushes, image-warping tools, tools that convert sound and brush strokes into images, and so on- and I was wondering whether I can use your JPEG encoder, so that site visitors can download their artwork. I plan to make my source code available once I’ve got everything working, and just want to confirm that you’re cool with other people using this neat class of yours.
hi Rezmason,
no problem, you can use it, just drop me an email when it’s online, so that I can see this great project
cheers
Hi, I’m taking a quick capture of a sprite, _tray and trying to save it, but I’m getting weird response. It opens the browser, but the URL reads:
“http://www.kevinsweeneydesign.com/muse/create2.php?name=snapshot.jpg?%C3%BF%C3%98%C3%BF%C3%A0″
and prints out the default error. Any ideas what’s going on? If I run your application from my server it works fine, so I’m probably just not inserting enough code or something:
var bd:BitmapData = new BitmapData(400, 100);
bd.draw(_tray);
var myEncoder:JPEGEncoder = new JPEGEncoder( 75 );
var myCapStream:ByteArray = myEncoder.encode ( bd );
var header:URLRequestHeader = new URLRequestHeader (“Content-type”, “application/octet-stream”);
var myRequest:URLRequest = new URLRequest ( “http://www.kevinsweeneydesign.com/muse/create2.php?name=snapshot.jpg” );
myRequest.requestHeaders.push (header);
myRequest.method = URLRequestMethod.POST;
myRequest.data = myCapStream;
navigateToURL ( myRequest, “_blank” )
hi Kevin,
make sure you are not running your app in the Flash IDE, Flash uses GET when you run an app which uses POST buffer, that’s the reason why you get a bytearray stream description in the url,
let me know
Doh! That was it. Thanks
great
Bonjour, ce script permet il de faire de la capture de swf, flv et au delà, de capturer des zones entieres de l’ecran du player flash?
Merci
Hi, this is brilliant and very fast script. Thank you for sharing.
My question is, I don’t really understand any code in PHP. Is there someone who could lead me expressing the same server side functionality in ASP or ASP.NET?
Very useful, thank you so much for spending your time making it even though it must have been too long to remember =D
Really cool!
This got me inspired – heres an apollo app implementation saving a jpg to filesystem usiong JPEGEncode – heres the code:
—————————————–
———————————————
Where ‘some.jpg’ on the background of the VBox is a jpg of your chosing…
try it – works a treat
Sorry the code didnt come out heres a link to it instead:
http://www.barncar.com/writejpg.mxml
Cheers!
This is cool!
Please where can I download the complete source file.
It will be great If you allow to download.
Thanks
Prakashan.
Hi Prakashan,
sources are available here :
http://www.bytearray.org/wp-content/uploads/2006/09/media_snapshot/jpeg_encoder_source_03.zip
cheers
Thibault, this class is great. I’ve put it to good use with my Apollo webcam video app to save specific video frames as JPEG’s:
http://www.zeropointnine.com/blog/webcam-dvr-for-apollo
Lee Felarca
Thanks Thibault Imbert.
It is really that what exactly i was searching for. Thanks for this script. I agian want to apriciate the work done here.
hi Thibault Imbert
Really You have excellent work done here. I ve downloaded its Source files. but I cant find create.php and create2.php files in the package. Well i am not much aware of php. So can u send me these php files . if u dont mind……
Thanks
Hi Inder,
You can download the sources again, I have included the php files, sorry about that
cheers
Thank You so Much Thibault Imbert
It is really great. it is working amazing.
Thanks
hi, no working, no movie show
Although the current Flash implementation doesn’t allow client-side access to user-selected files, you guys might be interested to know that Silverlight *does* allow this. Google the silverlight project: “Fluxify” to see an example of this.
Is the source no longer available????
Hi Jeff,
Just fixing a bug on the server, I will post them back tomorrow
kind regards
Hi there,
I’d love to use the non-AMFPHP version of this, but can’t find a link to the code. Where can I find your code?
Thanks a lot btw. This should make things a lot easier.
A
Re: my last post. I see a link to the source in an earlier comment, but it gave me a 404.
Hi,
I have been looking for something like this. where can I get the source – the link doesn’t seem to work for me.
Thanks
Rich
Hi Richard,
I will re-upload the sources tonight
regards,
Thibault
Hey ! nice class, but there is a solution to encode a JPG with 300 dpi instead of 72 dpi ?
Where the modification to do it should be ? In JPG Encoder class or in the class witch use it ?
thanks
I found a solution, change in “writeAPP0″ function
this :
writeByte(0); // xyunits
writeWord(1); // xdensity
writeWord(1); // ydensity
into this :
writeByte(1); // xyunits
writeWord(0x12c); // xdensity
writeWord(0x12c); // ydensity
Hi everybody,
I re-uploaded the sources :
http://www.bytearray.org/wp-content/projects/postjpegencoder/standard_jpeg_encoder_source_03.zip
cheers
Thibault
I wondering how i can capture one Movie Clip and not the video
Brilliant. Found this really useful on a project i was working on.
Wow, this is awesome! I have looked through the source and haven’t found anywhere if this holds a license or freely available for use by anyone. Is this possible to use on my website?
Hello mate, i have some problem when I’m going to save to server.
I’m using this to the URLRequest
var myRequest:URLRequest = new URLRequest ( _assets.bt_enviar.selected ? “http://localhost/sites/rba/deploy/Main.html?name=snapshot.jpg” : “http://localhost/sites/rba/src/php/create2.php?name=snapshot.jpg” );
Is this the way to use it? Main.html?name=snapshot.jpg ?
When I click at the save button the File Browser opens to save the image.
I got a error.
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
I try to use the loader.dataFormat to VARIABLES but have no success.
Could you help me?
Thanks in advance!
Trackbacks/Pingbacks (9)
[...] While I was writing the CleVR viewer and hotspot editor I often found myself running up against limitations of Actionscript. One of the ones that bugged me the most was the inability to export jpegs from BitmapData. Luckily, it seems that some of these limitations will be addressed in Actionscript 3, and an excellent demo at ByteArray.org illustrates exactly the solution I was looking for. Bring on Flash 9! [...]
[...] Live JPEG Encoder 0.3 < ByteArray.org (tags: as3 actionscript jpeg) [...]
[...] actionscript 3, as3, daily delicious, encoder, flash, flash video, frame capture, jpeg, jpg, link, rich media, try doing that with AJAX videoI stumbled upon a great actionscript blog and discovered a pretty amazing Actionscript 3 Flash application. Simply, it dynamically encodes a JPEG from a playing FLV (Flash video) file and allows you to either save it to the server or to your own computer. Have a look at the project page for more details. This is just one small yet very cool reason why Actionscript 3 is going to dramatically change what can be done on the web. I have begun to slowly delve into AS3 and I am pretty amazed at what can be done. [...]
trasportatore macchina giardinaggio…
Live JPEG Encoder 0.3 [ by Thibault Imbert ]…
[...] Live JPEG Encoder 0.3 [...]
[...] Here’s how it works. There are some rather annoying, but necessary, limitations in flash that make it a little difficult to use as an editor for personal files. To load an image to edit, it must first be uploaded by flash to the web server hosting the flash file, and then re-downloaded into the flash player. This part isn’t too tough. Then there’s the issue of the image generation. The user needs to be able to get to the image after it’s captioned. It is technically possible to encode jpegs in flash but this puts more bandwidth strain on the server and the user, seeing as the result would then have to be uploaded to the server, and then re-downloaded by the user.. Blech! not to mention, these files can get BIG. So, I got to thinking that Flash can just send the server a representation of the caption, and then server side scripts can render the image, and then flash can pull that image back in, and throw it up onto the webpage for download with some DHTML goodness! [...]
[...] W AS3, dzięki klasie ByteArray, mamy możliwość operowania danymi binarnymi. Wykorzystując tą możliwość, powstało szereg przydatnych bibliotek, które umożliwiają bezpośrednio we flashu np. kompresję zip, jpg, png, etc. Mnie na razie najbardziej zainteresowała klasa JPEGEncoder. [...]
[...] Visual Studio: http://www.fluorinefx.com/docs/fluorine/vswizardnet20.html • Live JPEG Encoder: http://www.bytearray.org/?p=26 • PNG Encoder in AS3: http://www.kaourantin.net/2005/10/png-encoder-in-as3.html • FlashDevelop: [...]
[...] Save JPEG images from webcam (thanks to Thibault Imbert’s AS3 JPEG encoder) [...]