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
Let libvips check whether we received a valid image or not #166
Let libvips check whether we received a valid image or not #166
Conversation
Thanks again; loving these changes. This PR slightly changes the API in that the constructor no longer fails fast with an unsupported/invalid Buffer. Perhaps we should verify the Buffer synchronously? |
Yes, that's the only controversial change. The only downside to doing it synchronously is that it might cause a possible performance hit. But I suppose that doing a couple of memory comparisons won't be that slow. |
The more I think about about, the more I'd rather "break" the API and keep your change as it is. I'd describe it as very useful rather than "controversial" :) I'll wait for John to merge in the related libvips change before merging this PR. Thanks again! |
/* | ||
Determine image format of a buffer. | ||
*/ | ||
ImageType DetermineImageType(void *buffer, size_t const length) { | ||
ImageType imageType = ImageType::UNKNOWN; | ||
if (length >= 4) { | ||
if (memcmp(MARKER_JPEG, buffer, 2) == 0) { | ||
#if (VIPS_MAJOR_VERSION >= 7 && VIPS_MINOR_VERSION >= 42 && VIPS_MICRO_VERSION > 3) |
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.
I think this condition now needs to use VIPS_MAJOR_VERSION >= 8
.
Hi @mcuelenaere, John's merged the dependent PR. Are you able to rebase your |
75e27c1
to
2da4d7c
Compare
This removes the custom image fingerprinting code and uses the libvips is_a_buffer() infrastructure instead.
2da4d7c
to
125ee83
Compare
Changed, squashed and rebased. |
2 similar comments
Marvellous, thank you Maurus. |
Let libvips check whether we received a valid image or not
This removes the custom image fingerprinting code and uses the libvips
is_a_buffer() infrastructure instead.
This requires https://github.com/jcupitt/libvips/pull/240.