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

Use jpeg_write_marker to write comment #2

Merged
merged 1 commit into from Dec 5, 2022

Conversation

radarhere
Copy link

Another suggestion for python-pillow#6774

I found https://www.freedesktop.org/wiki/Software/libjpeg/

You can write special markers immediately following the datastream header by calling jpeg_write_marker() after jpeg_start_compress() and before the first call to jpeg_write_scanlines(). When you do this, the markers appear after the SOI and the JFIF APP0 and Adobe APP14 markers (if written), but before all else. Specify the marker type parameter as "JPEG_COM" for COM or "JPEG_APP0 + n" for APPn. (Actually, jpeg_write_marker will let you write any marker type, but we don't recommend writing any other kinds of marker.) For example, to write a user comment string pointed to by comment_text:

  • jpeg_write_marker(cinfo, JPEG_COM, comment_text, strlen(comment_text));

So this PR switches from using the Python extra variable to calling jpeg_write_marker in C. See what you think

@smason
Copy link
Owner

smason commented Dec 5, 2022

very fancy!

would be worth switching over to using that functionality for other parts, e.g. the ICC PROFILE?

@smason smason merged commit 399975f into smason:write-jpeg-com Dec 5, 2022
@radarhere radarhere deleted the write-jpeg-com branch December 5, 2022 12:17
@radarhere
Copy link
Author

We could. It's just a bit more complex as it involves an array of markers, rather than just one.

smason pushed a commit that referenced this pull request Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants