Jump to content

FreeImage Library


ProgAndy
 Share

Recommended Posts

  • 5 months later...
  • 2 weeks later...

Does free image support image tagging?

Yes. The functions to manipulate them are descripbed in the helpfile under the topic "Metadata function reference". Thres also some description for the different formats ("FreeImage metadata models").

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

  • 4 weeks later...

I need help converting an image to greyscale

#include <FreeImage.au3>

$pDIB = "image01.bmp"

_FreeImage_ConvertToGreyscale($pDIB)

This code doesn't seem to do anything

oh sorry i totally forgot the

_FreeImage_SaveU

_FreeImage_Unload

Ill come back with future questions ;)

Link to comment
Share on other sites

I'm not sure which function I should use to remove colors?

Converting to blackandwhite was super easy but I need something that could alter the image more

I was taking a look at these two functions :

FreeImage_SetTransparent

FreeImage_Composite

Could anyone explain exactly what these do? Or please give some examples?

If you've ever used photoshop, this is what I'm trying to edit

Posted Image

Thanks,

Edited by WalkHappy
Link to comment
Share on other sites

Hello,

I do not really know, what FreeImage_SetTransparent is for. Maybe it is for manipualting GIF/PNG or something like that.

With FreeImage_Composite You can copy an image with transparent parts on an other image or a single colored background.

To create something like this dialog in Photoshop, you have to get the Bitmap-Bits and convert them on your own i think. Then you can set them back. Or maybe a combination of FreeImage_Dither or FreeImage_Threshold with the FreeImage_Adjust...-functions will give you the expected result.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Hello,

I do not really know, what FreeImage_SetTransparent is for. Maybe it is for manipualting GIF/PNG or something like that.

With FreeImage_Composite You can copy an image with transparent parts on an other image or a single colored background.

To create something like this dialog in Photoshop, you have to get the Bitmap-Bits and convert them on your own i think. Then you can set them back. Or maybe a combination of FreeImage_Dither or FreeImage_Threshold with the FreeImage_Adjust...-functions will give you the expected result.

Thank you thank you :evil:

Ive been stuck on this for hours.. hopefully it wont lead into days lol

I'll return with results ;)

Link to comment
Share on other sites

  • 1 month later...

ProgAndy,

Nice piece of work but as I am not an image specialist, could you help with a little problem that I think FreeImage can help with.

I have 4 images, one jpeg (call it the base image) and 3 transparent gif images.

I would like to combine the 4 into one by placing all of the gif images over the jpeg and creating a single combined file.

Can FreeImage do this, and if so, could you help a poor old (literally) programmer with an AutoIt example of how to do it.

Regards,

Jim

Link to comment
Share on other sites

ProgAndy,

Nice piece of work but as I am not an image specialist, could you help with a little problem that I think FreeImage can help with.

I have 4 images, one jpeg (call it the base image) and 3 transparent gif images.

I would like to combine the 4 into one by placing all of the gif images over the jpeg and creating a single combined file.

Can FreeImage do this, and if so, could you help a poor old (literally) programmer with an AutoIt example of how to do it.

Regards,

Jim

You can do this with FreeImage, but it would be easier with GDIplus. FreeImage forces you to care about Bit-depth and palettes, GDIPlus doesn't. Anyways, this code should work:
$hMainImage = _FreeImage_LoadU($FIF_JPEG, "C:\TheJPEG.jpg", 0)
$hMainImage32bit = _FreeImage_ConvertTo32Bits($hMainImage)
_FreeImage_Unload($hMainImage) ; we have the copy in 32bits

$hGIFImage = _FreeImage_LoadU($FIF_GIF, "C:\aGIF.gif", 0)
$hGIFImage32bit = _FreeImage_ConvertTo32Bits($hMainImage)
_FreeImage_Unload($hGIFImage)  ; we have the copy in 32bits

$iX = 12
$iX = 34
; both images have to be in same format, this is why they were converted.
_FreeImage_Paste($hMainImage32bit, $hGIFImage32bit, $iX, $iY, 300) ; last parameter > 255 for combiing without custom transpareny

_FreeImage_Unload($hGIFImage32bit)  ; now drawn, not needed anymore


_FreeImage_SaveU($FIF_JPEG, $hMainImage32bit, "C:\Combined.jpg", 0)
_FreeImage_Unload($hMainImage32bit) ; we saved it, not needed anymore

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

hey

thanks for the great udf

but im somehow too dumb to convert a .tga to a .bmp or .bmp to .tga..

is there some kind of convert command that i have missed?

i took your first example as base and tried _FreeImage_ConvertTo32Bits too, but i dont know exactly how to tell the program to convert

just load the .tga and save it as .bmp doesnt seem to work either, it says the bitmap is empty or corrupted

thanks for any help :huggles:

greets nuki

edit: this is my code:

#include <FreeImage.au3>

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

$sFile = "test.tga"


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

$dot = StringInStr($sFile,".",1,-1)
$Name = StringLeft($sFile,$dot-1)
;that one below was wrong
;_FreeImage_SaveU($FIF, $hImage, $Name &"_rsz.bmp")
;0 is the FIF code for BMP, 17 for TGA
_FreeImage_SaveU(0, $hImage, $Name &"_rsz.bmp")
_FreeImage_Unload($hImage)

_FreeImage_DeInitialise()

damn sorry for disturbing, i got it after reading the documentary a 2nd time... its too late already im in bed... the solution for makin it work is commented

thanks again for the great udf, helps me alot!

edit2:

whats wrong with that? autoit crashes. $return[0] returns a valid handle.

$return = DllCall("FreeImage.dll", "ptr", "_FreeImage_LoadU@12", "long", "17", "wstr", "test.tga", "int", "0")
DllCall("FreeImage.dll", "int", "_FreeImage_SaveU@16", "long", "0", "ptr", $return[0], "wstr", "test2.bmp", "int", "0")

thanks for answers, i go to bed now :D

edit3:

couldnt sleep cuz of it xD

solved now

$open = DllOpen("FreeImage.dll")
$return = DllCall($open, "ptr", "_FreeImage_LoadU@12", "long", "17", "wstr", "test.tga", "int", "0")
DllCall($open, "int", "_FreeImage_SaveU@16", "long", "0", "ptr", $return[0], "wstr", "test2.bmp", "int", "0")
DllClose($open)

finally good night :

greets

Edited by nuki
Link to comment
Share on other sites

Hello,

start to read documentation (huge, and very well done)

But can't find simple example to how :

- open file (png)

- resize

- save to different format (jpg)

I've directory with many .png, must resize them and save as .jpg.

Can anyone help me to start using this little gem ?

Thank you all for reading,

m.

Edited by myspacee
Link to comment
Share on other sites

Hello,

start to read documentation (huge, and very well done)

But can't find simple example to how :

- open file (png)

- resize

- save to different format (jpg)

I've directory with many .png, must resize them and save as .jpg.

Can anyone help me to start using this little gem ?

Thank you all for reading,

m.

There is already an example in the first post :D

The only thing you have to change is this:

$Ext = StringMid($sFile,$dot)
_FreeImage_SaveU($FIF, $hImageResized, $Name &"_rsz"&$Ext)

To use JPEG here, you have to do this:

$Ext = '.jpeg'
_FreeImage_SaveU($FIF_JPEG, $hImageResized, $Name &"_rsz"&$Ext)
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

  • 3 weeks later...

There is already an example in the first post :mellow:

...

To use JPEG here, you have to do this:

$Ext = '.jpeg'
_FreeImage_SaveU($FIF_JPEG, $hImageResized, $Name &"_rsz"&$Ext)

Hi ProgAndy,

I tried your code but all i get is a zero byte jpg image.

Thats the 2 lines I changed in your example from your first post:

$sFile = "test.tga"
...
_FreeImage_SaveU($FIF_JPEG, $hImageResized, $Name &"_rsz.jpg")

I also tried bmp as an input file but the result was the same.

However it works if I convert the targa file into a bmp!

Any help would be highly appreciated.

Have Fun

masc

Link to comment
Share on other sites

Sorry, I am not a master of FreeImage. I think you have to convert the image to 24bit or 8bit greyscale to use FIF_JPEG. It does not convert automatically.

Note that some bitmap save plugins have restrictions on the bitmap types they

can save. For example, the JPEG plugin can only save 24 bit and 8 bit greyscale bitmaps

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

  • 2 weeks later...

The download works fine (here). Which browser do you use?

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...