How to confirm that image was taken with specific device? - java

I want to write function in my android application that will confirm that picture was
taken by specific mobile device.
Today I can tell, if the picture was taken by specific model. (like galaxy s3).
But,I want more than that.
I would like to get from image EXIF unique id and compare it to the device unique id.
Thanks for help.

Maybe instead of using a long code. You can use a pre-ready Library for that.
Metadata metadata = ImageMetadataReader.readMetadata(imageFile);
This is the example code used by the Library, https://drewnoakes.com/code/exif/
It would give you the MetaData for the image. Which is also the content you want, Like the GeoLocation, CellularInformation, Resolution, Focus and all other data attached to the image.
A qoutation from the link
It understands several formats of metadata, all of which may be present in a single image: In addition it can decode values that are specific to particular camera manufacturers and models.
Then you can check for the details on that image and show or hide or what so ever you want to do with that image.
You can get the code from Google Code too: https://code.google.com/p/metadata-extractor/
Good luck!

Related

BDD cucumber Web Service

I have read some articles regarding how we can implement BDD with cuuumber but i am not able to understand fully.
Lets say i have a service
/v1/picture?viewer=1&viewed=2&flag=1
For these 3 input i am looking for output as "1.jpg"
I am looking for
How can we implement above ? -- i.e output based on input
How can we build data ? -- mysql data basically stubs
Please help with examples and good links.
Thanks
It's hard to answer your question as there's not a lot of detail about what you're trying to achieve, but I'll give it a go.
You've got 3 different inputs there:
- The viewer
- Whether it's been viewed or not
- A flag.
So those inputs provide different contexts (Givens) for the scenarios.
Given a .jpg viewer
Given I have already viewed the image twice
Given the image has been flagged
How you set up the data for these givens is entirely up to you. You can hard-code it, use mysql data or input real data using an admin console, etc.. It shouldn't matter. The behaviour you're interested in is what happens when you apply the event (When):
When I retrieve the v1 picture
Presumably, the input provided in your contexts is relevant, and will provide different outcomes (Thens) depending on that input.
Then I should see a .jpg file
Then I should see the "Image flagged" banner
Then I should see the message "Viewed 2 times"
So I might have scenarios like:
Given a .jpg viewer
And an image that's been viewed 3 times
When I retrieve the v1 picture
Then the service should give me 1.jpg
And I should see the message "Viewed 3 times"
Given a .png viewer
When I retrieve the v1 picture
Then the service should give me 1.png
etc.
I don't know what your real service is doing, but hopefully this helps you see the pattern. Try to keep different aspects of the behaviour separated in the scenarios (more like the 2nd than the 1st) unless there are combinations you need to exemplify.

Read information from a Google Slides link with android studio

Basically, assuming I have a link to a google slide (as provided by user), for example:
https://docs.google.com/presentation/d/1c3TbLKMVwOqgP70l0ph2jSvIHAaZnZoSMnvW8cxs8Ik/edit?usp=sharing
Ultimately, I want to answer the following:
Is there a way to get the slides into an array of some sort of image file?
Then, is there a way to get the speaker notes into an array of Strings?
Since we have the link (assuming it is set as "Public-anyone can view"), we theoretically have access to all these information, as we can access it in the Google Slides page. However, how do we extract it algorithmically? Is there a specific place where these information is stored in the Google server where I can just retrieve it?
You can download the whole presentation in various formats:
https://docs.google.com/presentation/d/<PRESENTATION_ID>/export/<FORMAT>
Possible formats are: pdf, pptx, odp, txt (strings only)
e.g.
https://docs.google.com/presentation/d/1c3TbLKMVwOqgP70l0ph2jSvIHAaZnZoSMnvW8cxs8Ik/export/pptx
To download slides as images, you have to specify a particular slide (page):
https://docs.google.com/presentation/d/<PRESENTATION_ID>/export/<FORMAT>?pageid=<PAGE_ID>
Possible formats are: jpeg, svg, png
e.g.
https://docs.google.com/presentation/d/1c3TbLKMVwOqgP70l0ph2jSvIHAaZnZoSMnvW8cxs8Ik/export/jpeg?pageid=g1f5653c4cc_0_437
You can find the page id at the end of a URL (http://docs.google...slide=id.<PAGE_ID>).

How to create a progressive JPEG image on Android

I need to send images over a very low-bandwidth connection from an android phone (down to 10kByte/s) and would like to send them in progressive (interlaced) mode so that the user at the other end starts seeing the image already during the lengthy transfer. Right now, I am creating the image with the regular photo app:
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
But this creates non-progressive photos and I have not been able to discover how to convince it to do otherwise. The second option I explored (reading and re-compressing the taken image) got foiled because the Bitmap's compress method does not allow any encoding parameters besides format name and compression factor as far as I could determine:
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, out);
My preferred solution would be to instruct the photo app to save in progressive mode.
The next best option would be a Java algorithm that losslessly converts the stored jpeg to progressive (jpegtran does this on Linux, but it is in C and relies on libjepeg).
The next best would a method to specify the relevant encoding parameters to android allowing me to re-compress it, or an alternative Java library that does the same.
Further research revealed that the algorithms are already there (/system/lib/libjpeg.so) with the sources in ~/android-sdk-linux/source-tree/external/jpeg -- but there do not seem to be JNI wrappers readily available.
Have you seen this document?
http://docs.oracle.com/javase/6/docs/api/javax/imageio/plugins/jpeg/JPEGImageWriteParam.html
It seems to have write progressive support.
Alternatively, you could use e.g. OpenJPEG through JNI. See http://www.linux-mag.com/id/7697/ as a start.

How to get specific file details under windows?

Which is the easiest way I could get the file details / properties under windows?
I am not talking about common properties (such as file size, creation date), but the ones written by variuos software. In my particular case I need to get the detail called "Date taken" for a jpg image file.
I could use PHP, Java or VB.NET, whatever is easier.
My final goal: I have a bunch of images I took with different versions of Android on my phone. They are all named with different naming convention, most of them just something like IMG_[consecutive_numbers].jpg. So I want to rename them all, but for that I need their original creation date, and since I have moved them from my pc to the phone and back so many times, I cannot trust the "creation date" property. I found that all of them have a property which was set by the camera called "Date taken", which is still intact and valid.
Thanks in advance!
P.S.:
This is what I need:
Is this what you are looking for?
http://php.net/manual/en/function.exif-read-data.php
I believe the photo you have posted actually shows something pulled from the exif data.
Knowing this you can use any language that has the ability to extract the exif data.
For java their is no native way so you would use a library such as http://www.drewnoakes.com/code/exif/
I am a ava developer so I have provided a Java option; however, this can be done in any language.
Dim finfo As New System.IO.FileInfo(fdialog.FileName)
now you can play around with all the fileinfo attribures.
regards ...

Picture.writeToStream() not writing out all bitmaps

I'm using webview.capturePicture() to create a Picture object that contains all the drawing objects for a webpage.
I can successfully render this Picture object to a bitmap using the canvas.drawPicture(picture, dst) with no problems.
However when I use picture.writeToStream(fos) to serialize the picture object out to file, and then
Picture.createFromStream(fis) to read the data back in and create a new picture object, the resultant bitmap when rendered as above is missing any larger images (anything over around 20KB! by observation).
This occurs on all the Android OS platforms that I have tested 1.5, 1.6 and 2.1.
Looking at the native code for Skia which is the underlying Android graphics library and the output file produced from the picture.writeToStream() I can see how the file format is constructed.
I can see that some of the images in this Skia spool file are not being written out (the larger ones), the code that appears to be the problem is in skBitmap.cpp in the method
void SkBitmap::flatten(SkFlattenableWriteBuffer& buffer) const;
It writes out the bitmap fWidth, fHeight, fRowBytes, FConfig and isOpaque values but then just writes out SERIALIZE_PIXELTYPE_NONE (0). This means that the spool file does not contain any pixel information about the actual image and therefore cannot restore the picture object correctly.
Effectively this renders the writeToStream and createFromStream() APIs useless as they do not reliably store and recreate the picture data.
Has anybody else seen this behaviour and if so am I using the API incorrectly, can it be worked around, is there an explanation i.e. incomplete API / bug and if so are there any plans for a fix in a future release of Android?
Thanks in advance.
That's the way the API is meant to work. It was never intended for long term storage, but to store flattened in the current process, or to send to another process. What you are asking for will not be supported.
On the Honeycomb platform it appears that writeToStream() and createFromStream() now store and recreate the Picture object including large image data.
However it does come with the following caveats:
The image data used in a picture must be of an immutable type.
The image data must have been created with the following BitmapFactory.Options set to true, inInputShareable and inPurgeable. This can be done by using BitmapFactory.decodeResource() passing in the BitmapFactory.Options.
It so happens that Pictures created by WebView 'do' contain suitable images that meet this criteria and therefore can be serialized and restored.
I have not confirmed as yet that Ice Cream Sandwich also works but I am assuming/hoping that it will.

Categories