-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apply EXIF rotation information if libgd is linked with libexif #478
base: master
Are you sure you want to change the base?
Conversation
Thanks! That would solve #341. Just a few quick remarks:
|
gdImageFlipHorizontal|Vertical|Both changes source image itself, but rotating 90/270 degree can not be implemented like that because image size need to be changed. So for the consistency, I made a new functions for flipH/V which allocate a new image and copying pixels with horizontal/vertical flipping. How about changing name of add functions to gdImageCloneRotate90/180/270/FlipH/FlipHRotate90/... , and move to gd.c? (Also applying palette copy, ... to renamed functions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of the rotate functions do the same thing except for the gdImageCreateTrueColor
and gdImageSetPixel
calls. imo we should create one internal static transformation function which all the others build off of with a callback to do the actual reindexing.
untested, but should show what i mean. hopefully the overhead of the callbacks isn't significant perf wise. it does make the code a lot easier to maintain imo.
typedef int (*rotateHelper)(gdImagePtr dst, int x, int y);
static gdImagePtr gdImageRotate(gdImagePtr src, int ignoretransparent, int newWidth, int newHeight, rotateHelper transX, rotateHelper transY)
{
...
dst = gdImageCreateTrueColor(newWidth, newHeight);
...
for (uY = 0; uY<src->sy; uY++) {
int newY = transY(uY);
for (uX = 0; uX<src->sx; uX++) {
int newX = transX(uX);
...
if (ignoretransparent && c == dst->transparent) {
gdImageSetPixel(dst, newX, newY, dst->transparent);
} else {
gdImageSetPixel(dst, newX, newY, c);
}
...
static int rot90x(gdImagePtr dst, int x, int y)
{
return y;
}
static int rot90y(gdImagePtr dst, int x, int y)
{
return dst->sy - x - 1;
}
gdImagePtr gdImageRotate90(gdImagePtr src, int ignoretransparent)
{
return gdImageRotate(src, ignoretransparent, src->sy, src->sx, rot90x, rot90y);
}
@vapier : code is updated as you requested. please review again |
orientation fix.