Sign in to follow this  
Followers 0
Marlo

Couple of questions about the FreeImage library.

3 posts in this topic

Hello! So i have made an app that converts multiple images to a different type, colour and size using the library but have run into a couple of issues.

So here is an example of the code I use to convert my images.

_FreeImage_LoadDLL(@ScriptDir&"\FreeImage.dll")
_FreeImage_Initialise()

For $I = 1 To $Example[0]
_ProcessImage($ExampleInput[$I], $ExampleOutput)
Next

Func _ProcessImage($Input, $Output)

$sFile = $Input
$iTWidth = 600
$iTHeight = 800

$FIF = _FreeImage_GetFileTypeU($sFile)
If $FIF = $FIF_UNKNOWN Then
$FIF = _FreeImage_GetFIFFromFilenameU($sFile)
EndIf
$hImage = _FreeImage_LoadU($FIF, $sFile)

$oWidth = _FreeImage_GetWidth($hImage)
$oHeight = _FreeImage_GetHeight($hImage)

$Ratio = $oWidth / $oHeight
If $Ratio > 1 Then
$hImage = _FreeImage_RotateClassic($hImage, 90)
EndIf

$hImage = _FreeImage_Rescale($hImage, $iTWidth, $iTHeight, $FILTER_BILINEAR)
$hImage = _FreeImage_ConvertToGreyscale($hImage)

_FreeImage_SaveU($FIF_PNG, $hImage, $Output, $PNG_Z_BEST_COMPRESSION)

_FreeImage_Unload($hImage)

EndFunc

Okay so this actually works quite nicely and does exactly what i want it to but with 2 problems.

1) FreeImage doesn't seem to dump the image from memory after each iteration resulting in huge RAM consumption (i usually convert about 400-600 images at a time)

2) The filesize of the output files is usually bigger than the inputs despite being converted to grey-scale and scaled down in size. I would also like to somehow make the images crisper.

If anyone can shed some light on this for me i would be appreciative :)


Click here for the best AutoIt help possible.Currently Working on: Autoit RAT

Share this post


Link to post
Share on other sites



I may have solved the memory leak by de-initialising the FreeImage lib after about 100 conversions yet still don't know how to reduce the file size.


Click here for the best AutoIt help possible.Currently Working on: Autoit RAT

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0