Setting up a live image stream on a website, using images from a webcam. Trying to work out the implementation of it. The webcam takes a picture and requires a crop, resize and upload (not necessarily in that order), before it is displayed to the user, with a new image every minute. Currently I have a php script that does the cropping and resizing, while a webcam program automates the picture taking and uploading. However...
Uploading directly over the existing image causes an issue if the user reloads the page while the upload is taking place, resulting in a missing image.
Uploading with a different filename, then renaming it causes an issue if the user reloads the page during the renaming, resulting in a combination of both images.
Using a sequential filename system then gets tricky with the webpage requiring to know the new upcoming file every minute, along with a potential backlog of images.
Any suggestions are appreciated. Hopefully I'm missing something simple.
Thanks.
Just upload your image with different name, set the current image name somewhere, either in config file or MySQL, and after upload change it.
Related
Think stock images. You have a full-size original that can only be downloaded after purchase. You only want to have that image once on your server, at full-size. But you want to display that image in various places in smaller sizes (responsively reduced for mobile devices as well).
I've got various pieces of this puzzle, but have not been able to make them all work together:
With TimThumb or CImage I can resize the images server-side, and using jQuery I can dynamically change the image source based on the user's screen size.
With PHP and .htaccess I can place the image files outside of the webroot and route a spoof URL containing image name to the PHP file that will read the actual image and send a header with the image data. Fine.
But TimThumb and CImage work with the real image URLs and they test to make sure that the given URL is the actual file path of the image.
If I could send the actual image data to the image resizing script rather than the URL to the image, it should work out from there. Since the PHP script would be reading the image data, I could check to see that the user has been given the proper credentials before doing the read.
Are there any other solutions you can think of besides hacking TimThumb or CImage or writing my own custom image resizing script?
Thank you
The answer just came to me.
With .htaccess, route all images through the image processing script. On the first line of the image processing script I will include my own custom script. My custom script will check the GET parameters against the actual image to determine if the user has the credentials to be served the image being requested at the size it is being requested.
If so, let the image processing script continue, if not, exit out or change the GET parameters to that the image processing script serves a placeholder image.
VoilĂ !
i created PHP form for my site, with image upload option on it.
but it only show the image name before image submitted, but i want to view/preview the image/file before submit so how this possible in this?
"file36":{"label":"Select/Upload a Student's Photo","accept":"jpg|jpeg|png|gif|bmt","files":true,"attach":true,"database":true,"maxbytes":204800,"fieldtype":"fileupload","required":true,}},
As far as I know this is not possible with php until you upload the image.
However, you are able to do so with jquery.
Check out http://blueimp.github.io/jQuery-File-Upload/
The old way is to upload the image to a temp folder, create an iframe and load the response there. Then link the temp image from the iframe to a hidden field in the final form with JavaScript. When you submit the form place the image in the right folder. Finally run a cron job every 24-48h to empty out the temp folder.
The new way is the File API supported in IE10+ and all modern browsers. Fallbacks in Flash and Silverlight exist for older browsers.
You obviously misunderstand how file uploads w/ PHP work.
PHP is server side programming language, meaning, it can only execute and access scripts, that are on the server. So, for PHP to access / analyze a picture in any way, it has to be on the server already.
You can upload the file in a temporary directory, analyze it and, if it suits your needs, move to a permanent folder. Otherwise, just delete it.
For now, i am able to download the image that i uploaded into my server. My upload is using php script to file open a image to store the .jpg file in the server. But i want to know how to retrieve the new image from my server to my android application. What i meant is every time the user upload the image, the image will replaced the old image file (using the same file name) in my server folder.
When i reload the image in my application, it still gives me the old image even though the image not longer exist. Later i found out that i need to go the url and refresh the image then the new image will be loaded in the android application. I want to know how can i refresh the url without using the browser to refresh the image every time the user upload new image. Thanks!
My question might not be clear/good but i really needed help and im new to android development
A pragmatic approach: When the user uploads a file, also make a txt/xml-file with the current date in it.
Make you Android application poll the txt/xml-file. Store the date in the txt/xml-file (in a database). When polling verify if the date in the file is newer then the one you stored. If it's newer, download your image.
After successfully replaced on server,you have to get url of new uploaded image as response & replace old url by new url.
Image this scenario:
There is a picture locally in my server, where a sketch is displayed, and there is a "blank hole" area on it.
Then, a user can upload another picture to my server.
What i'm trying to achieve is this:
After image upload is finished, the first image (the one with the "hole") is displayed, and behind it is displayed the user's photo, so that you can see it through the "blank hole" area of the first photo.
Then the user can move his picture (drag & drop style) so he can choose which area of it is visible through the "blank hole".
Then i would like to save the result - by merging the 2 photos or keeping the position of the user's picture in a db so i can display it again later.
(Something like this more or less)
What kind of technollogy should i look for? I'd guess javascript(for the drag & drop) or html5 or php(for merging the photo)?
Are there any libraries that i can use?
I hope my explanation isn't too messy, i didn't even know how to google for it.
I don't know if there are better solutions (and I suspect there are), but I suspect all of this can be done with not too much trouble. Here's a rundown of one way to approach the problem:
Use a JavaScript-powered "upload widget" such as uploadify to enable your user to upload "his" image to the server. The server will do some processing on the image (e.g. resize and crop to suitable dimensions) and save it using e.g. PHP's gd library. It will return a URL to the "prepared" image back to the browser -- all of this through AJAX.
The browser then has a URL to the user's image, so using more Javascript you can dynamically add an element that displays it inside the page and allow the user to move it around with e.g. jQuery draggable. Compositing the draggable image behind your static content (the image with the "hole") is a detail you will have to take care of using a combination of HTML, CSS and again Javascript.
When the user is done, use an AJAX call (e.g. again jQuery) to inform the server of the image's positioning (this will be available through the facilities of the Javascipt framework you have selected). The server can then "compose" the two images together (gd or something equivalent once more) and return to the browser a URL through which the final product can be accessed.
Of course there are lots of details to take care of here, but knowing exactly what the plan is should help you get started.
Have a look at the PHP GD extension. If it's installed, it's pretty easy to have an image (with a transparent center) to be merged on top of a second image that a user would upload.
Have a look at http://php.net/manual/en/function.imagecopymerge.php
Ok to get you started, yes use a JavaScript drag and drop module for the placing of the image. You can record the x /y cordinates relative to the container. Do the image merging with a PHP image library / Class. Something like this : http://www.phpclasses.org/package/3930-PHP-Generate-an-image-from-the-combination-of-2-images.html
I would like user to upload most of their photo albums online, would it feasible to create and save one in thumbnails folder and one in full size folder or generate thumbnails on the fly when the user access their album? It will be something like eBay does. Webspace is not a concern since I have an unlimited plan.
Store the thumbnails when they're uploaded, or better yet, create a thumbnail (and store it) when the image is first accessed.
Storing them means that the server won't have to do unnecessary processing on every page load.