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

Add support for saving progressive jpegs #2749

Merged
merged 2 commits into from
Oct 22, 2020
Merged

Add support for saving progressive jpegs #2749

merged 2 commits into from
Oct 22, 2020

Conversation

SRHMorris
Copy link
Contributor

@SRHMorris SRHMorris commented Oct 22, 2020

Description

Allows saving progressive jpegs by adding the attribute "jpeg:progressive", an int which if non-zero will tell libjpeg to create a progressive file.

Tests

TODO

Checklist:

  • I have read the contribution guidelines.
  • If this is more extensive than a small change to existing code, I
    have previously submitted a Contributor License Agreement
    (individual, and if there is any way my
    employers might think my programming belongs to them, then also
    corporate).
  • I have updated the documentation, if applicable.
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary).
  • My code follows the prevailing code style of this project.

Comment on lines 189 to 190
ParamValue* progressive = m_spec.find_attribute("jpeg:progressive", TypeDesc::INT);
if (progressive && *(int*)progressive->data() != 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a new idiom that is a more compact way to express this!

if (m_spec.get_int_attribute("jpeg:progressive")) {

(The value it returns if the attrib doesn't exist is 0, so this works out perfectly in this case. Though you can also pass a second argument that is the default to use if there is no attribute.)

Or, since 2.1, this also works (which style you prefer might perhaps be a matter of personal taste):

 if (m_spec["jpeg:progressive"].get<int>()) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, thank you. I went with the first option as it looks a little cleaner to me.

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

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

LGTM!

I'll merge after the CI tests complete.

@lgritz lgritz merged commit d8d7661 into AcademySoftwareFoundation:master Oct 22, 2020
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Oct 22, 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