Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can load jpeg binary data as a file and parse the jpeg headers yourself. The one you are looking for is the 0xFFC0 or Start of Frame header:</p> <pre><code>Start of frame marker (FFC0) * the first two bytes, the length, after the marker indicate the number of bytes, including the two length bytes, that this header contains * P -- one byte: sample precision in bits (usually 8, for baseline JPEG) * Y -- two bytes * X -- two bytes * Nf -- one byte: the number of components in the image o 3 for color baseline JPEG images o 1 for grayscale baseline JPEG images * Nf times: o Component ID -- one byte o H and V sampling factors -- one byte: H is first four bits and V is second four bits o Quantization table number-- one byte The H and V sampling factors dictate the final size of the component they are associated with. For instance, the color space defaults to YCbCr and the H and V sampling factors for each component, Y, Cb, and Cr, default to 2, 1, and 1, respectively (2 for both H and V of the Y component, etc.) in the Jpeg-6a library by the Independent Jpeg Group. While this does mean that the Y component will be twice the size of the other two components--giving it a higher resolution, the lower resolution components are quartered in size during compression in order to achieve this difference. Thus, the Cb and Cr components must be quadrupled in size during decompression. </code></pre> <p>For more info about the headers check out wikipedia's jpeg entry or I got the above info <a href="http://www.obrador.com/essentialjpeg/headerinfo.htm" rel="noreferrer">here</a>.</p> <p>I used a method similar to the code below which I got from <a href="http://forums.sun.com/thread.jspa?messageID=2717499#2717499" rel="noreferrer">this post</a> at the sun forums:</p> <pre><code>import java.awt.Dimension; import java.io.*; public class JPEGDim { public static Dimension getJPEGDimension(File f) throws IOException { FileInputStream fis = new FileInputStream(f); // check for SOI marker if (fis.read() != 255 || fis.read() != 216) throw new RuntimeException("SOI (Start Of Image) marker 0xff 0xd8 missing"); Dimension d = null; while (fis.read() == 255) { int marker = fis.read(); int len = fis.read() &lt;&lt; 8 | fis.read(); if (marker == 192) { fis.skip(1); int height = fis.read() &lt;&lt; 8 | fis.read(); int width = fis.read() &lt;&lt; 8 | fis.read(); d = new Dimension(width, height); break; } fis.skip(len - 2); } fis.close(); return d; } public static void main(String[] args) throws IOException { System.out.println(getJPEGDimension(new File(args[0]))); } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload