in

Archived Data Techniques Forums

TIFF to JPG conversion (size and quality of JPG's)

Last post 11-11-2009 10:59 AM by brianb. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 11-11-2009 9:51 AM

    • Ben
    • Not Ranked
    • Joined on 11-11-2009
    • Posts 2

    TIFF to JPG conversion (size and quality of JPG's)

    Hi,

    What's the best way to convert TIFF files from a fax machine into separate JPG files?

    If I leave the default settings, when I receive a 70K three page TIFF

    COMPRESS True

    TIFF_COMPRESS GROUP4

    And save this as JPG's I get three 800K pages.

    If I set LOSSY_QUALITY to one I get three 98K pages (and the quality is quite bad).

    Is there any way I can get three JPG's that total 70K?

    (am I missing some JPG attributes - I'm only setting the LOSSY_QUALITY at present).

     

    Code snippet

    procedure TForm1.Button1Click(Sender: TObject);
    var
      aImageMan : TImageControl;
      imageCount : integer;
      newFilename : string;
      attrs : OleVariant;
      iLossy : integer;
    begin
      if OpenDialog1.Execute then begin
        attrs := CreateOLEObject('IMActX8.Attributes');
        aImageMan := TImageControl.Create(nil);
        try
          aImageMan.Picture := OpenDialog1.FileName;
          attrs.Add( 'EXTENSION', 'JPG',  IMString);
          TryStrToInt( edtLossy.Text, iLossy);
          attrs.Add( 'LOSSY_QUALITY', iLossy,  IMInt32);
          for imageCount := 0 to aImageMan.Pages -1 do
          begin
            aImageMan.PageNumber := imageCount;
            newFilename := CreateTempFile('.jpg');
            aImageMan.SaveAs(newFilename, attrs);
          end;
        finally
          aImageMan.free;
        end;
      end;
    end;
     

    Thanks,

    Ben

  • 11-11-2009 10:05 AM In reply to

    • brianb
    • Top 10 Contributor
    • Joined on 09-29-2009
    • Burnsville, NC
    • Posts 58

    Re: TIFF to JPG conversion (size and quality of JPG's)

    Hi Ben,

    For TIFF compression Group 3 is good for black and white images and Group 4 is best for black and white document type images.  JPG is intended for continous tone color images.  We're curious as to why you'd want to seperate each of the TIFF pages into separate JPG's.

    Our best advice here, if you want to continue down the JPG route, is to set the loss quality to whatever gives you the maximum amount of compression and best quality for your situation (although you've already noted that the value of 1 will not work for you).  As you know already, JPG is not a lossless format and there are tradeoffs to be made depending on your use cases.

    Brian
    Technical Support
    Data Techniques
    Support Options

    Knowledgebase

    Forums
  • 11-11-2009 10:38 AM In reply to

    • Ben
    • Not Ranked
    • Joined on 11-11-2009
    • Posts 2

    Re: TIFF to JPG conversion (size and quality of JPG's)

    Hi Brian,

    Thanks for the quick response.

    The user wants to add layers to the image - ticking items, narratives etc (adding coloured icons for there tick - yes this is fine - red cross, this is wrong, different size and colour narative). as they view each page, they also want to detach pages as page 1-3 may relate to one deal 4 to another and 5 and 6 to another. Pages may be out of sequence, or a single page may contain multiple deals - so spilt the page and show colour split markers.

    We moved the TIFF to separate JPG images to ease the re-ordering adding colour etc. as our Delphi components worked well with JPG's.

    For users with uncompressed TIFF's the JPG conversion makes their documents (database) much smaller - for users with compressed TIFF's - I'm making them much bigger :o(

    I wondered if there was a way to get close to the Group4 compression with JPG's - it looks like I need to re-think the design and use the compressed TIFF if that's what we're given.

    Thanks again,

    Ben

  • 11-11-2009 10:59 AM In reply to

    • brianb
    • Top 10 Contributor
    • Joined on 09-29-2009
    • Burnsville, NC
    • Posts 58

    Re: TIFF to JPG conversion (size and quality of JPG's)

    Ben,

    Not to sound too much like a salesman, but our upcoming new release of ImageMan.NET will contain a new feature for annotating images which sounds like what you are trying to do.  We handle images, shapes, text, etc.  It should be out by the end of the month.  However, if you would like to give it a try to see if will cut back on your own custom coding, I could hook you up with a beta release.  If you are interested, let me know.  The annotation feature (and several other goodies will be part of an extended feature set called the Document Edition).

    However, after typing this, I realize that you are using Delphi and so are probably using the OCX version of ImageMan.  Is that correct?

    Brian
    Technical Support
    Data Techniques
    Support Options

    Knowledgebase

    Forums
Page 1 of 1 (4 items)
Copyright 2009 Data Techniques, Inc. All Rights Reserved.