JPEG image with wrong colors

I found a solution now, that works, at least if my resulting image is also a JPEG: First I read the image (from byte array imageData), and most important, I also read the metadata. InputStream is = new BufferedInputStream(new ByteArrayInputStream(imageData)); Image src = null; Iterator<ImageReader> it = ImageIO.getImageReadersByMIMEType(“image/jpeg”); ImageReader reader = it.next(); ImageInputStream iis = … Read more

How to create an animated GIF from JPEGs in Android (development)

See this solution. https://github.com/nbadal/android-gif-encoder It’s an Android version of this post. http://www.jappit.com/blog/2008/12/04/j2me-animated-gif-encoder/ To use this class, here is an example helper method to generate GIF byte array. Note here the getBitmapArray() function is a method to return all the Bitmap files in an image adapter at once. So the input is all the Bitmap files … Read more

JPEG images have different pixel values across multiple devices

The JPEG standard does not require that decoder implementations produce bit-for-bit identical output images. Unfortunately the standards document specifying decoder requirements, ISO 10918-2, is apparently not freely available online but Wikipedia says: …the JPEG standard (and the similar MPEG standards) includes some precision requirements for the decoding, including all parts of the decoding process (variable … Read more

libjpeg-turbo for android

Install Android NDK. Following instructions were verified with r8b, older versions may have problems, I don’t know. Get the Android sources for libjpeg-turbo from Benjamin Gaignard: git clone git://git.linaro.org/people/tomgall/libjpeg-turbo/libjpeg-turbo.git -b linaro-android In the libjpeg-turbo directory created by git, edit file Android.mk: after line 70, LOCAL_MODULE := libjpeg, add the following: ifeq ($(notdir $(MAKECMDGOALS)),libjpeg.a) LOCAL_SRC_FILES += … Read more

C# How can I test a file is a jpeg?

Several options: You can check for the file extension: static bool HasJpegExtension(string filename) { // add other possible extensions here return Path.GetExtension(filename).Equals(“.jpg”, StringComparison.InvariantCultureIgnoreCase) || Path.GetExtension(filename).Equals(“.jpeg”, StringComparison.InvariantCultureIgnoreCase); } or check for the correct magic number in the header of the file: static bool HasJpegHeader(string filename) { using (BinaryReader br = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read))) { UInt16 … Read more

Save inline SVG as JPEG/PNG/SVG

Nowadays this is pretty simple. The basic idea is: SVG to canvas canvas to dataUrl trigger download from dataUrl it actually works outside of the Stack Overflow snippet var btn = document.querySelector(‘button’); var svg = document.querySelector(‘svg’); var canvas = document.querySelector(‘canvas’); function triggerDownload (imgURI) { var evt = new MouseEvent(‘click’, { view: window, bubbles: false, cancelable: … Read more