{"id":13452912,"url":"https://github.com/mattclements/jpegcam","last_synced_at":"2025-03-23T21:35:14.959Z","repository":{"id":2316441,"uuid":"3276656","full_name":"mattclements/jpegcam","owner":"mattclements","description":"Clone of jpegcam which is no longer maintained","archived":false,"fork":false,"pushed_at":"2012-10-17T06:26:05.000Z","size":286,"stargazers_count":42,"open_issues_count":4,"forks_count":20,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-08-01T08:06:53.956Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"ActionScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattclements.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-26T19:27:53.000Z","updated_at":"2022-11-04T14:11:52.000Z","dependencies_parsed_at":"2022-09-16T14:10:56.557Z","dependency_job_id":null,"html_url":"https://github.com/mattclements/jpegcam","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattclements%2Fjpegcam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattclements%2Fjpegcam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattclements%2Fjpegcam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattclements%2Fjpegcam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattclements","download_url":"https://codeload.github.com/mattclements/jpegcam/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221918546,"owners_count":16901644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T08:00:27.452Z","updated_at":"2024-10-28T19:31:04.754Z","avatar_url":"https://github.com/mattclements.png","language":"ActionScript","funding_links":[],"categories":["ActionScript","Unsorted"],"sub_categories":["Other API"],"readme":"JPEGCam v1.0.11\n===============\n\nLICENCE\n-------\nWebcam library for capturing JPEG images and submitting to a server\nCopyright (c) 2008 - 2009 Joseph Huckaby \u003cjhuckaby@goldcartridge.com\u003e\nCopyright (c) 2011 - 2012 Matt Clements \u003cmatt@mattclements.co.uk\u003e\nLicensed under the GNU Lesser Public License\nhttp://www.gnu.org/licenses/lgpl.html\n\nCONTRIBUTIONS\n-------------\n* Original Version: Joseph Huckaby\n* Ongoing Support: Matt Clements\n* onAllow Functionality: Liyan Chang\n* Additional Changes: Richard Nicholls\n\nOVERVIEW\n--------\nJPEGCam is a simple, JavaScript and Flash library that allows you to enable\nyour users to submit Webcam snapshots to your server in JPEG format.  The\nFlash movie is variable-sized, and has no visible user interface controls.\nAll commands sent to the movie are done so from JavaScript, so you can\nimplement your own look \u0026 feel on your site, create your own buttons, and\ntell the Flash movie what to do from your own code.\n\nREQUIREMENTS\n------------\n* JavaScript-enabled browser\n* Flash Player 9+\n\nEMBEDDING IN YOUR PAGE\n----------------------\n(For a working example, see \"test.html\" in the htdocs folder.)\n\nFirst, copy the following files to your web server:\n\n* webcam.js\n* webcam.swf\n* shutter.mp3\n\nNext, edit your HTML and load the JavaScript library:\n\n\t\u003cscript type=\"text/javascript\" src=\"webcam.js\"\u003e\u003c/script\u003e\n\nConfigure a few settings (see API CALLS for complete list):\n\n\t\u003cscript language=\"JavaScript\"\u003e\n\t\twebcam.set_api_url( 'test.php' );\n\t\twebcam.set_quality( 90 ); // JPEG quality (1 - 100)\n\t\twebcam.set_shutter_sound( true ); // play shutter click sound\n\t\u003c/script\u003e\n\nLoad the movie into the page.  If you want to load the movie immediately, \nsimply use document.write() as shown below.  If you are designing a DHTML\napplication, you can call webcam.get_html(...) at any time to dynamically\npopulate a DIV or other element after the page is finished loading.\n\n\t\u003cscript language=\"JavaScript\"\u003e\n\t\tdocument.write( webcam.get_html(320, 240) );\n\t\u003c/script\u003e\n\nAdd some controls for sending commands to the movie (see API CALLS):\n\n\t\u003cbr/\u003e\u003cform\u003e\n\t\t\u003cinput type=button value=\"Configure...\" onClick=\"webcam.configure()\"\u003e\n\t\t\u0026nbsp;\u0026nbsp;\u0026nbsp;\n\t\t\u003cinput type=button value=\"Take Snapshot\" onClick=\"webcam.snap()\"\u003e\n\t\u003c/form\u003e\n\nFinally, add some code for handling the server response:\n\n\t\u003cscript language=\"JavaScript\"\u003e\n\t\twebcam.set_hook( 'onComplete', 'my_callback_function' );\n\t\tfunction my_callback_function(response) {\n\t\t\talert(\"Success! PHP returned: \" + response);\n\t\t}\n\t\u003c/script\u003e\n\nThat's it! See the following sections for a complete list of all the \navailable API calls, and how to write the server-side code.\n\nAPI CALLS\n\nHere are all the available API calls for the JPEGCam JavaScript library.\nEverything is under a top-level global 'webcam' namespace.\n\n*webcam.set_hook( HOOK_NAME, USER_FUNCTION );*\n\n\tThis allows you to set a user callback function that will be fired for\n\tvarious events in the JPEGCam system.  Here are all the events you \n\tcan hook:\n\t\n\tonLoad\n\t\tFires when the Flash movie is loaded on the page.  This is useful\n\t\tfor knowing when the movie is ready to receive scripting calls. Your \n\t\tfunctions will be passed the initial allow state.\n\t\n\tonAllow\n\t\tFires when the 'Allow' option has been selected.\n\t\t\n\tonComplete\n\t\tFires when the JPEG upload is complete.\n\t\tYour function will be passed the raw output from the API script \n\t\tthat received the file upload, as the first argument.\n\t\n\tonError\n\t\tFires when an error occurs.  If this hook is not defined, the library\n\t\twill display a simple JavaScript alert dialog.  Your function will be\n\t\tpassed the error text as the first argument.\n\n*webcam.set_api_url( URL );*\n\n\tThis allows you to set the URL to your server-side script that will \n\treceive the JPEG uploads from the Flash movie. Beware of cross-domain \n\trestrictions in Flash.\n\n*webcam.set_swf_url( URL );*\n\n\tThis allows you to set the URL to the location of the \"webcam.swf\" Flash\n\tmovie on your server.  It is recommended to keep this file in the same\n\tdirectory as your HTML page, but if that is not possible, set the path\n\tusing this function.  Beware of cross-domain restrictions in Flash.\n\tThe default is the current directory that your HTML page lives in.\n\n*webcam.set_quality( QUALITY );*\n\n\tThis allows you to adjust the JPEG compression quality of the images \n\ttaken from the camera.  The range is 1 - 100, with 1 being the lowest\n\tquality (but smallest size files), to 100 being the highest quality\n\t(but largest files).  This does NOT control the resolution of the images,\n\tonly the JPEG compression.  The default is 90.\n\n*webcam.set_shutter_sound( ENABLED, [ URL ] );*\n\t\n\tThis allows you to enable or disable the \"shutter\" sound effect that \n\tthe Flash movie makes when a snapshot is taken.  Pass in a boolean\n\ttrue or false to the function.  It defaults to true.  If set to false\n\tthe sound effect will not even be loaded.\n\t\n\tYou can optionally pass a second argument to this function, which \n\tshould be a URL (relative to page or fully qualified) to an MP3\n\tsound effect for the shutter sound.  This defaults to 'shutter.mp3'\n\tin the current directory relative to the HTML page.\n\t\n\tThese values cannot be changed after get_html() is called (see below).\n\t\n*webcam.get_html( WIDTH, HEIGHT, [SERVER_WIDTH, SERVER_HEIGHT] );*\n\n\tThis returns the necessary HTML code to embed the Flash movie into your\n\tpage.  Pass in the desired pixel width \u0026 height, which not only controls\n\tthe visual size of the movie, but also the JPEG image width \u0026 height.\n\tStandard sizes are 320x240 and 640x480.\n\t\n\tYou can optionally pass a desired server image width and height.  If \n\tthese differ from the video width and height, the captured images will \n\tbe resized to match just prior to upload.\n\n*webcam.snap();*\n\n\tThis instructs the Flash movie to take a snapshot and upload the JPEG\n\tto the server.  Make sure you set the URL to your API script using \n\twebcam.set_api_url(), and have a callback function ready to receive\n\tthe results from the server, using webcam.set_hook().\n\n*webcam.configure( PANEL );*\n\n\tThis launches one of Flash's configuration panels, used to setup camera\n\tdevices, privacy settings, and more.  Pass in one of the following strings\n\twhich sets the default panel \"tab\" in the settings dialog:\n\t\"camera\", \"privacy\", \"default\", \"localStorage\", \"microphone\", or \n\t\"settingsManager\".  Example:\n\t\n\twebcam.configure( 'camera' );\n\n*webcam.freeze();*\n\n\tOptional, new in v1.0.4.  This is not required if you use webcam.snap(),\n\tdescribed above.\n\t\n\tThis captures an image from the webcam but does NOT upload it.\n\tInstead, the image is displayed \"frozen\" in the Flash movie, and the user \n\tmay take further action.  For example, you may provide separate \"Upload\"\n\tand \"Reset\" buttons to upload the frozen image and/or reset the camera.\n\n*webcam.upload();*\n\n\tOptional, new in v1.0.4.  This is not required if you use webcam.snap(),\n\tdescribed above.\n\t\n\tThis uploads the captured image to the server, previously frozen with\n\twebcam.freeze().  This is provided as its own function so you can\n\thave separate \"Capture\" and \"Upload\" buttons for the user.\n\n*webcam.reset();*\n\n\tOptional, new in v1.0.4.  This resets the frozen image, previously captured\n\twith webcam.freeze(), and restores the live webcam feed for further\n\tcapturing.\n\nSERVER-SIDE CODE\n\nThe Flash movie makes a HTTP POST to your server-side script, using the\nContent-Type 'image/jpeg'.  This is a NON-STANDARD method which is unlike\nsubmitting a form from a web page.  If you are using PHP, the JPEG data\nwill NOT be in the normal $_POST variable.  Instead, you should read it\nfrom the special PHP file wrapper 'php://input'.  For example:\n\n\t$jpeg_data = file_get_contents('php://input');\n\nYou can write this raw, binary JPEG data to a file handle using the PHP\nfunction file_put_contents():\n\n\t$filename = \"my_file.jpg\";\n\t$result = file_put_contents( $filename, $jpeg_data );\n\nAny output from your script is passed back through the Flash movie to the \nJavaScript code, which in turn passes it to your onComplete callback function.\n\nFor example, if you want your script to pass back a URL to the JPEG image,\nsave the file where you want it, and construct a URL to the file.  Then simply\nprint the URL to the output like this:\n\n(This assumes you are saving the files to the current working directory)\n\n\t$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI'])\n\t \t. '/' . $filename;\n\tprint \"$url\\n\";\n\n(See \"test.php\" for a working example.)\n\nFAQ\n\nQ. I cannot see the image from my camera!  What am I doing wrong?\n\nA. You probably have to setup the camera device in the Flash Camera settings\n   dialog first.  Often Flash doesn't auto-detect the right device.\n\n\t\twebcam.configure( 'camera' );\n\n   It is always a good idea to provide a \"Configure...\" button on your\n   page which calls this function, so users can easily get to it.\n\n\nQ. What is this ugly permission dialog?  Can't I just make it remember me?\n\nA. Yes, you certainly can!  In the Flash setup dialogs, click on the 2nd icon\n   from the left (i.e. Privacy Settings), and you can click \"Allow\", then \n   check the \"Remember\" checkbox.\n\n   You can send your users directly to the Privacy config panel by calling:\n\t\twebcam.configure( 'privacy' );\n\n   A cool trick is to detect \"new\" users (via a cookie) and register an onLoad\n   handler to send them directly to the Privacy settings.\n\n\twebcam.set_hook( 'onLoad', 'my_load_handler' );\n\tfunction my_load_handler() {\n\t\tif (is_new_user())\n\t\t\twebcam.configure( 'privacy' );\n\t}\n\t\t\n\tOf course, you have to write the is_new_user() function yourself.\n\tI no wanna be settin' no cookies on your domain.\n\t\t\nQ. How can you detect when a user has allowed access?\n\nA. You can detect whether webcam access has been allowed as below:\n\n\twebcam.set_hook( 'onLoad', 'my_load_handler' );\n\twebcam.set_hook( 'onAllow', 'my_allow_handler' );\n\tfunction allowed() {\n\t\talert('Hey, you allowed us to access your webcam!');\n\t}\n\tfunction my_load_handler(allowStatus) {\n\t\tif(allowStatus) {\n\t\t\tallowed();\n\t\t}\n\t}\n\tfunction my_allow_handler() {\n\t\tallowed();\n\t}","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattclements%2Fjpegcam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattclements%2Fjpegcam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattclements%2Fjpegcam/lists"}