diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2016-09-26 14:56:06 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2016-10-02 17:11:34 +0200 |
| commit | ce1ae1ff69309ec7f1905e928a9d43eb8ae86dbe (patch) | |
| tree | 1333e1cf81b034681c4ac6b35665c17ccd984048 /src/gallery-utils.c | |
| parent | c80c60eb0623268112b5a0c37d80ada0384c3e90 (diff) | |
| download | cataract-ce1ae1ff69309ec7f1905e928a9d43eb8ae86dbe.tar.xz | |
jpeg-utils: Add support for custom resize options
This change brings the possibility to tweak resize options using standard
ImageMagick `convert` command syntax. Separate options are offered for
thumbnails.
Diffstat (limited to 'src/gallery-utils.c')
| -rw-r--r-- | src/gallery-utils.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gallery-utils.c b/src/gallery-utils.c index d97cef3..403b3c6 100644 --- a/src/gallery-utils.c +++ b/src/gallery-utils.c @@ -94,6 +94,40 @@ str_replace (gchar **dst, const gchar *search, const gchar *replace) /* + * str_trim_inside: trims any leading, trailing and repeated whitespaces in the whole string + */ +#define IS_WHITESPACE(s) (s == ' ' || s == '\t') + +void +str_trim_inside (gchar **s) +{ + gchar *dst; + gboolean was_whitespace; + int pos; + gchar *src; + + if (! s || strlen (*s) == 0 ) + return; + + /* suppose the new string is not longer than the input string */ + dst = g_malloc0 (strlen (*s) + 1); + was_whitespace = TRUE; /* handles beginning of the string */ + pos = 0; + for (src = *s; *src != '\0'; src++) + if (! IS_WHITESPACE (*src) || ! was_whitespace) { + dst[pos++] = *src; + was_whitespace = IS_WHITESPACE (*src); + } + if (IS_WHITESPACE (dst[pos - 1])) + dst[pos - 1] = '\0'; + + /* return fixed string */ + g_free (*s); + *s = dst; +} + + +/* * copy_file: copy file from src to dst */ gboolean |
