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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Resizing Images - What's the Best Way?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
skippix Posted - Jul 15 2013 : 14:25:42
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!
3   L A T E S T    R E P L I E S    (Newest First)
skippix Posted - Jul 16 2013 : 10:45:14
Thanks! I'll post back once I get complete some performance testing!
xequte Posted - Jul 16 2013 : 03:10:20
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
w2m Posted - Jul 15 2013 : 14:59:11
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