reading android jpeg EXIF metadata from picture callback

To read metadata/EXIF from image byte[] (useful for Camera.takePicture()) using version 2.9.1 of the metadata extraction library in Java by Drew Noakes: try { // Extract metadata. Metadata metadata = ImageMetadataReader.readMetadata(new BufferedInputStream(new ByteArrayInputStream(imageData)), imageData.length); // Log each directory. for(Directory directory : metadata.getDirectories()) { Log.d(“LOG”, “Directory: ” + directory.getName()); // Log all errors. for(String error : … Read more

matplotlib savefig in jpeg format

You can save an image as ‘png’ and use the python imaging library (PIL) to convert this file to ‘jpg’: import Image import matplotlib.pyplot as plt plt.plot(range(10)) plt.savefig(‘testplot.png’) Image.open(‘testplot.png’).save(‘testplot.jpg’,’JPEG’) The original: The JPEG image:

How do you create a thumbnail image out of a JPEG in Java?

Image img = ImageIO.read(new File(“test.jpg”)).getScaledInstance(100, 100, BufferedImage.SCALE_SMOOTH); This will create a 100×100 pixels thumbnail as an Image object. If you want to write it back to disk simply convert the code to this: BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); img.createGraphics().drawImage(ImageIO.read(new File(“test.jpg”)).getScaledInstance(100, 100, Image.SCALE_SMOOTH),0,0,null); ImageIO.write(img, “jpg”, new File(“test_thumb.jpg”)); Also if you are concerned about speed … Read more

Is there a way to tell browsers to honor the jpeg exif orientation?

CSS image-orientation: from-image from the specs https://www.w3.org/TR/css4-images/#the-image-orientation 6.2. Orienting an Image on the Page: the ‘image-orientation’ property image-orientation: from-image from-image: If the image has an orientation specified in its metadata, such as EXIF, this value computes to the angle that the metadata specifies is necessary to correctly orient the image. If necessary, this angle is … Read more