-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Support saving JPEG comments #6774
Conversation
Support saving JPEG comments
not sure what's going on with that MSYS2 MinGW 32-bit test failure, but it looks unrelated |
There are some intermittent failures in our CIs. I've rerun the job, and it has passed now. |
Use jpeg_write_marker to write comment
* means `comment=None` can be passed directly * no need to conditionally run `str.encode()` * clean up checking of whether a comment is passed
@@ -278,7 +278,7 @@ ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) { | |||
|
|||
case 4: | |||
|
|||
if (context->comment_size > 0) { | |||
if (context->comment) { |
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.
the rest of the code is conditional on comment != NULL
rather than comment_size > 0
they should be the same, but keeping things consistent feels nicer to me
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.
When you say "the rest of the code", what are you referring to?
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.
sorry, that wasn't explained well
PyImaging_JpegEncoderNew
seems to imply that comment_size
is only valid when comment
is non-NULL. e.g. comment
is initialised to NULL, but comment_size
isn't initialised to zero, and later in function (line 1109) it only sets comment = NULL
Free comment when returning early
Added releases notes for #6774
@radarhere thanks for all the help getting that merged! sorry for the silence the past couple of days. I've been a bit ill, but recovering now |
Fixes #6773
Changes proposed in this pull request:
Image.save
image.save(filename, format='JPEG', comment='comment to be written')
and the comment will be written to a COM segment