NO

Author Topic: How to read info about JPEG  (Read 3816 times)

luca.crovato

  • Guest
How to read info about JPEG
« on: November 14, 2011, 12:59:47 PM »
Hi all ,
I need to read info from jpg file ( H, W etc)  how i can do it?

Ciao
Luca

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: How to read info about JPEG
« Reply #1 on: November 14, 2011, 04:59:47 PM »
Hi all ,
I need to read info from jpg file ( H, W etc)  how i can do it?

Ciao
Luca
Are you asking about how to open and read a binary file or do you ask about the structure of the JPEG file format?

Ralf

luca.crovato

  • Guest
Re: How to read info about JPEG
« Reply #2 on: November 14, 2011, 05:53:28 PM »
Dear Ralf

I'm asking how to read the structure.
I'm tryng to build library based on libjpeg but without success.

br
Luca

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: How to read info about JPEG
« Reply #3 on: November 14, 2011, 07:54:45 PM »
Here is smaller library for that ?
http://keyj.emphy.de/nanojpeg/

EDIT:
Quote
I'm tryng to build library based on libjpeg but without success.
with source from http://www.ijg.org/
- copy jconfig.vc to jconfig.h
- use Import MSVC project wizard to import makejdsp.vc6

or try jpeglib.ppj from attachment

Code: [Select]
#include <stdio.h>
#include <stdlib.h>
#include <jpeglib.h>
#include <jerror.h>

#pragma comment(lib, "jpeglib.lib")

int main(int argc, char** argv)
{
  struct jpeg_decompress_struct cinfo;
  struct jpeg_error_mgr jerr;
  FILE *infile;

  if ((infile = fopen(argv[1], "rb")) == NULL)
  {
    fprintf(stderr, "Can't open %s\n", argv[1]);
    exit(1);
  }

  // Create decompression object.
  cinfo.err = jpeg_std_error(&jerr);
  jpeg_create_decompress(&cinfo);
  jpeg_stdio_src(&cinfo, infile);
 
  // Get all compression parameters.
  jpeg_read_header(&cinfo, TRUE);
  fprintf(stdout, "w: %d h: %d\n", cinfo.image_width, cinfo.image_height);

  // Destroy decompression object.
  jpeg_destroy_decompress(&cinfo);
  fclose(infile);
  return 0;
}
« Last Edit: November 15, 2011, 11:05:40 AM by timovjl »
May the source be with you

luca.crovato

  • Guest
Re: How to read info about JPEG
« Reply #4 on: November 15, 2011, 01:52:29 PM »
Dear timovjl

thanks a lot.

It works.

Ciao
Luca