I’ve taken my ofImage modifications and packaged them as an addon - ofxImage.

New functionality/methods:
mirror - mirror the image pixels horizontally and/or vertically
rotate - rotate the image pixels by an arbitrary angle
getFileName - get the fileName the image was loaded or saved to
setFileName - set a fileName that the image will load or save to

Overloaded/modified methods:
loadImage - loads the image, and stores fileName OR if fileName parameter is omitted, loads the image from fileName set with setFileName
saveImage - saves the image, and stores fileName OR if fileName parameter is omitted, saves the image to fileName set with setFileName

It is available for download (example included) at:

Tested with openFrameworks 0061.


New version 1.1 is now available.

New in this version is a saveImage method with a bool return value.




I try this usefull add and have an issue with the rotate function, as the size of my image was decreasing when I rotated it.

My use is
ofxImage myImage;

then somewhere after an allocation.

Inside ofxImage.cpp, in the rotate function, I change the line

convertedBmp = FreeImage_RotateClassic(bmp, angle);


convertedBmp = FreeImage_RotateEx(bmp, angle, 0, 0, pix.width/2, pix.height/2, false);

and now it works for me as it rotate the content of the image inside the size of the image (content at the corner makes unexpected behaviour) and that’s what I want.

By the way, many thanks for this plong0


ya… there are a few rotation functions available from FreeImage. Ideally I’d like to implement something that uses the RotateEx, and then replaces the black corners with transparent pixels.

I was working on a formula for calculating exactly where the black corners would be, but haven’t really needed it for a project yet so haven’t’ spent a lot of time.

Glad you like the add-on :slight_smile:


seems to have compile errors against the github OF due to swapRgb in saveImageFromPixels. i’ve run into this before, i can’t remember what the issue is. but i’ve commented it out for now.


kyle: yes, we had that problem before.

Basically it is because swapRgb is defined as a protected static inline method in ofImage. I guess the new compiler settings don’t allow it to be available to extended classes.

The solution we used was to copy the swapRgb method from the ofImage into the ofxImage class.

It seems strange that this needs to be done, but it at least solves the problem

I just uploaded a new version to the Google Code: http://code.google.com/p/tiof/downloads-…-e-v1.3.zip


I know this is 8 years old, but this code doesn’t work (getPixels() just says “it’s your job to get this to work” ) and I can’t find any other solutions to getting ofImage to rotate.

Any chance someone can link a working solution, or somebody update this?

It seems silly that after 8 years, ofImage STILL doesn’t have the ability to rotate less than 90 deg


I am dumb.
To anyone of the future who manages to find this link in the same desperate search I did, there is an official addon for open frameworks now.
Use this