ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Resizing Images - What's the Best Way?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

skippix

USA
68 Posts

Posted - Jul 15 2013 :  14:25:42  Show Profile  Reply
I've collected about 4 or 5 ways of downsizing original photo files, and they all basically work; but I've never tried doing it with ImageEn.

Can anyone point me to some code that would let me take an image down to 640x427 pixels 80-150kb, rotated if necessary, and "slightly" sharpened?

Thanks!

w2m

USA
1990 Posts

Posted - Jul 15 2013 :  14:59:11  Show Profile  Reply
There are several ways to do this with ImageEn, but if you are using JPEG files then probably this is the best:

TImageEnIO.LoadFromFileJPEGFast

Declaration

function LoadFromFileJPEGFast(const sFilename: string;
iMaxX, iMaxY: integer;
var iFastScaleUsed: Integer;
bAutoAdjustOrientation: Boolean = False
): boolean;
Description
Calls LoadFromFileJpeg to load a JPEG image and allows you to specify a maximum size that you require an image so that it can be loaded as fast as possible, by using JPEG_Scale.
You can also set EnableAdjustOrientation to automatically re-orient JPEG camera images.
Returns True if loading was successful, or False on error. iFastScaleUsed is set with the scaling that was used, i.e. 1 = loaded full size, 2 = loaded at half size, etc.

uses IEHelperFunctions;
begin
  { Load a jpeg file with dimensions of 640x427 and rotate the
     image }
  ImageEnView1.IO.LoadFromFileFast(OpenPictureDialog1.FileName, 640,
       427, False, True);
  { Sharpen the image "slightly"}
  ImageEnView.Proc.AutoSharp(5); 
end;

Alternative

var
  iAdjustment: integer; 
begin
  ImageEnView1.IO.LoadFromFile(OpenPictureDialog1.FileName);
    ImageEnView1.Proc.Resample(640, 427, rfNone); 
  { Auto Adjust }
  iAdjustment:= ImageEnView1.Proc.CalcOrientation;
  ImageEnView.Proc.Rotate(iAdjustment);
  { Sharpen the image "slightly"}
  ImageEnView.Proc.AutoSharp(5); 
end;

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

xequte

39076 Posts

Posted - Jul 16 2013 :  03:10:20  Show Profile  Reply
Please also consider the helper function:

function IEResampleImageFile(const sInFilename, sOutFilename: string;
                             iJpegQuality: Integer;
                             iMaxX: Integer;
                             iMaxY: Integer;
                             bCanStretch: boolean = False;
                             QualityFilter: TResampleFilter = rfLanczos3;
                             bAutoAdjustOrientation: Boolean = False
                             ): boolean;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

skippix

USA
68 Posts

Posted - Jul 16 2013 :  10:45:14  Show Profile  Reply
Thanks! I'll post back once I get complete some performance testing!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: