Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3422100
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:10:40+00:00 2026-05-18T06:10:40+00:00

I have a JPEG image which is JFIF formatted. I want to decode it

  • 0

I have a JPEG image which is JFIF formatted. I want to decode it and get the dimension.

Here is my code:

while (binaryReader.ReadByte() == 0xff)
        {
            byte marker = binaryReader.ReadByte();
            ushort chunkLength = binaryReader.ReadLittleEndianInt16();

            if (marker == 0xc0)
            {
                binaryReader.ReadByte();

                int height = binaryReader.ReadLittleEndianInt16();
                int width = binaryReader.ReadLittleEndianInt16();
                return new Size(width, height);
            }

            binaryReader.ReadBytes(chunkLength - 2);
        }

Ok. This piece of code is common and you can find it all over the internet. It works fine for most of the JPEG images.

Now, this specific image which was taken by the camera – “Canon EOS 300D DIGITAL”, does not support this piece of code. The marker for the dimension is 0xFFC2 instead of 0xFFC0.

My question is which one is correct? If the code is correct, then how can a Canon camera produce a non-standard image? If the Canon camera is correct, then how can we fix the code to correct find the dimension of this image?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:10:40+00:00Added an answer on May 18, 2026 at 6:10 am

    FFC2 seems to be the marker for progressive images.

    please see for example http://en.wikipedia.org/wiki/JPEG which explains what “progressive” format is (see “JPEG compression” section).

    yes, i think you can change your if statement to check for both 0xc0 (SOF0 marker) and 0xc2 (SOF2 marker) because they seem to have similar structure (see “syntax and structure” section). see also here: http://fjcore.googlecode.com/svn/trunk/FJCore/Decoder/JpegDecoder.cs

    i am not expert in JPEG formats, so you might want to check with specialised forums if you are developing a mission critical code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JPEG image (actually a BLOB in a database) which I want
I have a lot of jpeg files with varying image size. For instance, here
I have the following code which takes an improperly saved Image from the database
I have a JPanel to which I'd like to add JPEG and PNG images
I'd like to have an HTML page which displays a single PNG or JPEG
I have a php dynamically generated image which I need to write to file
I have a file upload class which returns an image resize object if the
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I am working on images in iPhone. There are lots of jpeg images which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.