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

Added resolution unit option in tiff method #3023

Closed
wants to merge 7 commits into from

Conversation

ompal-sisodiya
Copy link
Contributor

  • Added resolution unit in option.param while using tiff method
  • Added required test cases

Copy link
Owner

@lovell lovell left a comment

Choose a reason for hiding this comment

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

Thank you Ompal for the PR, looks good. Please can you add a unit test that verifies the EXIF metadata in the output has the expected resolution unit based on this new option.

@lovell
Copy link
Owner

lovell commented Dec 24, 2021

Sorry, I should have been clearer, I was thinking of a unit test that verifies the EXIF metadata of the output image (rather than just inspecting internal options), perhaps using an approach similar to the existing metadata tests:

const exif = exifReader(metadata.exif);
assert.strictEqual('object', typeof exif);
assert.strictEqual('object', typeof exif.image);
assert.strictEqual('number', typeof exif.image.XResolution);

@ompal-sisodiya
Copy link
Contributor Author

@lovell All the required change are done on our end. could you review once.

@nishantjiit

This comment has been minimized.

@lovell
Copy link
Owner

lovell commented Jan 5, 2022

@ompal-sisodiya Thanks for the updates. I don't see any verification of output image EXIF metadata in the newly-added tests; am I missing something? (I note you've added to an existing unit test, but that logic is unrelated to this PR, I was merely using it as an example of using exif-reader to parse the output.)

@ompal-sisodiya
Copy link
Contributor Author

@lovell Thanks for your response. please review the below test for the verification of output image with EXIF metadata.
if this is fine then i will commit the code else you can help me with the test.

it('TIFF setting resolution unit(cm)', async () => {
    await sharp(fixtures.inputJpgWithExif)
      .tiff({ resolutionUnit: 'inch' })
      .metadata(function (err, metadata) {
        if (err) throw err;
        // EXIF
        assert.strictEqual('object', typeof metadata.exif);
        assert.strictEqual(true, metadata.exif instanceof Buffer);
        const exif = exifReader(metadata.exif);
        assert.strictEqual('object', typeof exif);
        assert.strictEqual('object', typeof exif.image);
        assert.strictEqual('number', typeof exif.image.XResolution);
        assert.strictEqual('number', typeof exif.image.ResolutionUnit);
      });
  });

@lovell
Copy link
Owner

lovell commented Jan 6, 2022

@ompal-sisodiya Please can you add an assertion on the value of exif.image.ResolutionUnit (as well as the type).

@ompal-sisodiya
Copy link
Contributor Author

@lovell I have added assertion for the value of resolution unit. could you review once.

@nishantjiit

This comment has been minimized.

@ompal-sisodiya
Copy link
Contributor Author

ompal-sisodiya commented Jan 18, 2022

@lovell Could please review PR?

@lovell
Copy link
Owner

lovell commented Jan 18, 2022

Thanks again for taking the time to submit a PR, I will review this when I am ready to do so. Coordinated pestering won't make that happen any sooner.

lovell added a commit that referenced this pull request Jan 29, 2022
lovell added a commit that referenced this pull request Jan 29, 2022
@lovell
Copy link
Owner

lovell commented Jan 29, 2022

Landed via commit f7bed69

I also added the (normalised) resolutionUnit property to the response from metadata(), which had the added advantage of making the tests a bit simpler.

This will be in v0.30.0, thanks again for the PR.

@lovell lovell closed this Jan 29, 2022
@lovell lovell added this to the v0.30.0 milestone Jan 29, 2022
Y2zz pushed a commit to Y2zz/sharp that referenced this pull request Feb 26, 2022
Y2zz pushed a commit to Y2zz/sharp that referenced this pull request Feb 26, 2022
martinj pushed a commit to aptoma/sharp that referenced this pull request Mar 31, 2022
martinj pushed a commit to aptoma/sharp that referenced this pull request Mar 31, 2022
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.

3 participants