Skip to content
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

Test: add set orientation #16

Merged
merged 4 commits into from
Jul 13, 2020

Conversation

TonyBrobston
Copy link
Contributor

@TonyBrobston TonyBrobston commented Jul 7, 2020

Here's the beginning of setOrientation if you're open to implementing it. I could look into the implementation, just figured I'd start with a test.

Relates to #15

@TonyBrobston TonyBrobston changed the title Test: add set orientation test Test: add set orientation Jul 7, 2020
src/index.ts Outdated
@@ -76,6 +76,13 @@ export async function getOrientation (
return info;
}

export async function setOrientation (
input: File | Buffer | ArrayBuffer,
orientation: number,
Copy link
Owner

@ginpei ginpei Jul 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to have this orientation type OrientationCode | IOrientationInfo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swapped to OrientationCode for now. I think I'll need a new test for to drive myself into adding IOrientationInfo.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I now think IOrientationInfo is a little bit too much. Only OrientationCode would be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the same thing

@TonyBrobston TonyBrobston force-pushed the implement-set-orientation branch 8 times, most recently from 73c77b5 to df3cf0e Compare July 10, 2020 00:54
Comment on lines +140 to +144
function getOrientationOffsetAndLittleEndian (view: DataView, segmentOffset: number) {
const tiffHeaderOffset = segmentOffset + statics.offsets.tiffHeader.fromSegment;
const littleEndian = isLittleEndian(view, tiffHeaderOffset);
const ifdPosition = findIfdPosition(view, tiffHeaderOffset, littleEndian);
const ifdFieldOffset = ifdPosition + statics.ifdFieldCountLength;
const orientationOffset = findOrientationOffset(
view,
ifdFieldOffset,
littleEndian,
);
return {littleEndian, orientationOffset};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this. Trying to reduce duplication.

@TonyBrobston
Copy link
Contributor Author

@ginpei I've finished my first round of coding, let me know what changes you would like.

@TonyBrobston
Copy link
Contributor Author

@ginpei Are you able to give me some feedback on these changes?

src/index.ts Outdated
@@ -76,6 +76,13 @@ export async function getOrientation (
return info;
}

export async function updateOrientation (
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you delete this updateOrientation() function? Let's have only updateOrientationCode().

The original idea of the difference between getOrientation() and readOrientationCode() is which type they return. The "code" one returns OrientationCode and the other returns IOrientationInfo. So this updateOrientation() should accept "info" if we implement.

I'm sorry I should've told you this before but I needed time to remember.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. No need to be sorry, I was asking for feedback :). I deleted the function as you requested.

@ginpei
Copy link
Owner

ginpei commented Jul 13, 2020

I added one last request. I will merge and release package soon right after updated.

@TonyBrobston
Copy link
Contributor Author

I just realized I haven't updated the readme at all, is that something you would mind handling? If not, I can give it a try.

@ginpei
Copy link
Owner

ginpei commented Jul 13, 2020

Good point. Please go ahead.

@TonyBrobston
Copy link
Contributor Author

@ginpei I updated the documentation. I tried to follow your pattern.

README.md Outdated
```ts
import * as exif from '@ginpei/exif-orientation';

await exif.updateOrientationCode(fileOrBuffer, 5);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use exif.OrientationCode.deg90Flipped instead please

@ginpei
Copy link
Owner

ginpei commented Jul 13, 2020

@TonyBrobston Requested one thing. Looks good to me other than that.

Do you want to do anything else before merging? I will prepare release note with your name and account.

@TonyBrobston
Copy link
Contributor Author

Done.

Everything seems good to me 👍 .

Copy link
Owner

@ginpei ginpei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@ginpei ginpei merged commit 3732dfe into ginpei:master Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants