From 185fcfe635a113d5cf0c5c8bd8c781b145fc7882 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Sat, 5 Mar 2016 13:52:12 +0000 Subject: [PATCH] Improve entropy-based crop docs based on feedback. Fix includes to keep MSVC compiler happy. Additional memory leak suppressions for latest V8. --- docs/api.md | 11 +++++++---- docs/changelog.md | 2 +- src/operations.cc | 2 ++ src/operations.h | 1 + test/leak/sharp.supp | 37 ++++++++++++++++++++++++++++++++++++- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/docs/api.md b/docs/api.md index fd0cab2f..e422e012 100644 --- a/docs/api.md +++ b/docs/api.md @@ -138,11 +138,14 @@ Possible attributes of `sharp.gravity` are `north`, `northeast`, `east`, `southeast`, `south`, `southwest`, `west`, `northwest`, `center` and `centre`. -`sharp.strategy` currently contains only the experimental `entropy`, -which will retain the part of the image with the highest -[Shannon entropy](https://en.wikipedia.org/wiki/Entropy_%28information_theory%29) value. +Possible attributes of the experimental `sharp.strategy` are: -The default option is a `center`/`centre` gravity. +* `entropy`: resize so one dimension is at its target size +then repeatedly remove pixels from the edge with the lowest +[Shannon entropy](https://en.wikipedia.org/wiki/Entropy_%28information_theory%29) +until it too reaches the target size. + +The default crop option is a `center`/`centre` gravity. ```javascript var transformer = sharp() diff --git a/docs/changelog.md b/docs/changelog.md index 866114d4..09ea8ec4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -14,7 +14,7 @@ [#239](https://github.com/lovell/sharp/issues/239) [@chrisriley](https://github.com/chrisriley) -* Add entropy-based strategy to determine crop region. +* Add entropy-based crop strategy to remove least interesting edges. [#295](https://github.com/lovell/sharp/issues/295) [@rightaway](https://github.com/rightaway) diff --git a/src/operations.cc b/src/operations.cc index ad9f8406..555f183d 100644 --- a/src/operations.cc +++ b/src/operations.cc @@ -1,3 +1,5 @@ +#include +#include #include #include "common.h" diff --git a/src/operations.h b/src/operations.h index 5ece5743..48b14834 100644 --- a/src/operations.h +++ b/src/operations.h @@ -1,6 +1,7 @@ #ifndef SRC_OPERATIONS_H_ #define SRC_OPERATIONS_H_ +#include #include using vips::VImage; diff --git a/test/leak/sharp.supp b/test/leak/sharp.supp index bf224789..680ca215 100644 --- a/test/leak/sharp.supp +++ b/test/leak/sharp.supp @@ -248,6 +248,34 @@ ... fun:_ZN2v88internal12_GLOBAL__N_117CreateICUCollatorEPNS0_7IsolateERKN6icu_556LocaleENS0_6HandleINS0_8JSObjectEEE } +{ + leak_v8_CallInterfaceDescriptorData + Memcheck:Leak + match-leak-kinds: possible + ... + fun:_ZN2v88internal27CallInterfaceDescriptorData26InitializePlatformSpecificEiPNS0_8RegisterEPNS0_27PlatformInterfaceDescriptorE +} +{ + leak_v8_InitializePlatformSpecific14 + Memcheck:Leak + match-leak-kinds: possible + ... + fun:_ZN2v88internal14LoadDescriptor26InitializePlatformSpecificEPNS0_27CallInterfaceDescriptorDataE +} +{ + leak_v8_InitializePlatformSpecific15 + Memcheck:Leak + match-leak-kinds: possible + ... + fun:_ZN2v88internal15StoreDescriptor26InitializePlatformSpecificEPNS0_27CallInterfaceDescriptorDataE +} +{ + leak_v8_Malloced + Memcheck:Leak + match-leak-kinds: possible + ... + fun:_ZN2v88internal8Malloced3NewEm +} # vips__init warnings { @@ -279,7 +307,7 @@ fun:vips__magick_read_header } { - cond_magick_is_palette_image + cond_magick_is_palette_image_get_bands Memcheck:Cond fun:IsPaletteImage ... @@ -292,6 +320,13 @@ ... fun:get_bands } +{ + cond_magick_is_palette_image_parse_header + Memcheck:Cond + fun:IsPaletteImage + ... + fun:parse_header +} # glib g_file_read_link # https://github.com/GNOME/glib/commit/49a5d0f6f2aed99cd78f25655f137f4448e47d92