Library to handle QRCode generation serverside and store within database? - php

What I want to accomplish:
When a user hits "Generate QRCode" javascript will take the local machine's datetime and create an md5 hash based on the MMDDYYHHMMSS format. I want to take that hash and have the server generate a QRCode based on that hash and store it within the server's media folder. However all the libraries for QRCode take input and generate the QRCode clientside with no image resources, so I have no way to store it.
Does anyone have any answers as to how I should approach such an implementation?

I created a server side PHP library which will generate a JPG / PNG / GIF or your QR code.
https://github.com/edent/QR-Generator-PHP/
So, take the hash, pass it to your webserver. Generate the QR code, and then save it.

Related

MongoDB - REST API Architecture For Images

I have thousands of Images (wihch are less then 16MB in size) in RAW BINARY DATA in MONGODB with its Meta-Data in JSON as Date, Time, Location etc from the Small Satellite (BSON Documents). I have to make REST API which can query the Images with its respective Meta-Data. Following things needs to be taken under observation.
Data = Data Screenshot
User's will query the Meta-Data with RestAPI, based on time, location etc.
Server will get the Request from Cilent with Query and DO Image-Processing and Returns the Images
Image Processing will be done on Server Side.
Requested Images will travel through RESTAPI from Server to Client with the GET Request.
NOTE : Just see the Attached Picture to Get the Idea of the DATA.
Tools Used : Data-Base = MongoDB
Questions
Which Server Side Programming Language is More feasible? PHP, Python or Node.js?
How I could do Image-Processing in this scenario? With Libraries on PHP, Python or Node.js?
Which Technology to be Used for making REST API for MongoDB which is best with Binary Data and Images.
How Images will travel from Server to client i-e In binary data. and then Renders at Client Side.
NodeJS and Python are equally suited for basic image processing. I would make a server side language determination more on the expertise of your team and/or current environment in that regard.
With Python PIL or Pillow is the primary image library to use. I've used https://github.com/aheckmann/gm for NodeJS which was not difficult to do basic image processing.
(and 4) In terms of retrieving images from an API I typical using a typical REST/CRUD set up to get the metadata and put the image one level deeper using by adding .../image? to the endpoint. For example:
GET ../picture/<id>
Would return the picture metadata with the image url included.
GET ../picture/<id>/image?<processing params>
Would return the image itself.
If you are making a web application using the <img> tag and the correct image URL is sufficient for displaying the image.
I would also recommend storing the images on the filesystem directly (not in the database) unless you have a specific reason to store them in the database. It tends to simplify both you storage code and retrieval since you don't need to deal with sending a BLOB to the database. Nginx (https://www.nginx.com/resources/wiki/modules/upload/) for example lets you set file upload location so literally just need to get the filename from the headers and copy/rename it to the location you want to store the file permanently. This also lets you easily remap a URL to the location on the filesystem. The biggest benefit is that it lets the webserver worry about the upload and download and you just have keep track of the filename in your code.
According to your questions, I will give you answer one by one.
nodejs is better as they have more then 15000 modules.
you can do image processing by using nodejs modules like sharp, Jimp and many more.
MongoDB is a document-oriented NoSQL database (Big Data ready). It stores data in JSON-like format and allows users to perform SQL-like queries against it, and nodejs is best for this purpose.
for this there are number of modules for travels from server to client, like webcamjs.

Store an image in MySQL database and display it in ImageView in Android?

I am new to Android development. I am just trying to store an image in MySQL database and want to display that image in an ImageView.
What should I do?
I think I have to store the URL of image in MySQL database but I don't know how to do it either.
I am using PHP too.
One method is to store the base64 version of image using a php script with
base64_encode() wich returns the base64 encryption of the image but i don't recommend it because this is increasing the size of the image.
You should upload the image to a server and only store in the database the path to the image and then load it inside the Android application.
Here is a nice Java tutorial that explains how to upload an image through HTTP http://www.jguru.com/faq/view.jsp?EID=62798 it should work for your application.
Try to avoid if you can, storing images in database (as it would increase the size)..
If you cannot avoid, try using BLOB in database.. as mentioned here.
NOTE: Also do some research before asking questions.

How would you implement private images?

I'm developping an App in Android which somehow has avatars like Whatsapp do. As you know, in WhatsApp you can create a group, and set a group picture for it.
I don't have any problems on taking the image, saving, etc. The problem I have is that I'm developing the webservice in Symfony2 (PHP) and I want to receive the image and save it somewhere on the server. However, obviously those images are NOT public and should be only viewed for users with permissions. I've thought about traditional method: saving the image on a folder and giving the link or not, but this is totally easy to hack.
So guys, how would you do this? Maybe saving the binary data into MySql directly? Is there any clean way to achieve this?
Any tips are appreciated.
Thanks.
Another answer is to set the mime type of the PHP call to be an image. A call to a URL like http://xxx/images.php?id=8989031289130 would then return an image instead of an HTML file.
You then have access to the PHP security context and can validate whether the user actually has permissions to view this file.
There are some more details at:
Setting Mime type in PHP
The typical answer here is to use a file naming scheme that precludes guessing. For example, you could take the filename plus a secret salt, hash them together, and append the hash to the filename (before the extension). Thus, what would be /foo/bar/baz.jpg would become /foo/bar/baz_8843d7f92416211de9ebb963ff4ce28125932878.jpg.
So long as your hash salt remains secret, filenames are more or less mathematically protected from random or brute-force discovery. This is, for example, the core of how Facebook protects its' users pictures without having to actually require authentication for each image request (which doesn't scale well at all).

Unique image hash that does not change if EXIF info updated

I'm looking for a way to create a unique hash for images in python and php.
I thought about using md5 sums for the original file because they can be generated quickly, but when I update EXIF information (sometimes the timezone is off) it changes the sum and the hash changes.
Are there any other ways I can create a hash for these files that will not change when the EXIF info is updated? Efficiency is a concern, as I will be creating hashes for ~500k 30MB images.
Maybe there's a way to create an md5 hash of the image, excluding the EXIF part (I believe it's written at the beginning of the file?) Thanks in advance. Example code is appreciated.
Imagemagick already provides a method to get the image signature. According to the PHP documentation:
Generates an SHA-256 message digest for the image pixel stream.
So my understanding is that the signature isn't affected by changes in the exif information.
Also, I've checked that the PythonMagick.Image.signature method is available in the python bindings, so you should be able to use it in both languages.
In Python, you could use Image.tostring() to compute the md5 hash for the image data only, without the metadata.
import Image
import hashlib
img = Image.open(filename).convert('RGBA')
m=hashlib.md5()
m.update(img.tostring())
print(m.hexdigest())

save facebook photo to mysql BLOB

Just a quick question I am wanting to allow users to link there facebook account to my new product, and I am wondering how do I take there facebook photo URL and save it as an image in BLOB formate for MYSQL
I am using this example to connect to Facebook
https://github.com/facebook/connect-js/blob/master/examples/jquery/login.html
and to send the image to my server I use the $.ajax formate to submit it to the core.php (I have not coded this yet, as I need to know the best way.
Well my first recommandation is to NOT store image data in your database unless you absolutely need that in your database backups. You will clutter your database massively. Instead, just get the url to the picture using the server-side $facebook class, and just "file_get_contents" it to your php memory.
Then dump it on disk and save a reference of that dumped image in your database. It will do much more good to your database this way.
Else, if you really want to save it to a BLOB, use the same method to fetch the image to memory and then use the hex() function to transform it to a textual representation that can be fit into an INSERT/UPDATE query...
Just save a reference to the location where Facebook stores the image. That way you can abuse their servers (which are very nice/fast) and just serve image tags that refer to their servers.
Also when you save images to a database you lose the native compression that you get when you save an image to the filesystem, so you bloat your data storage size for not much reason (backups are easier I suppose).

Categories